Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.
Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Hide

Credits

Commands using sudo from sorted by
Terminal - Commands using sudo - 429 results
trickle sudo apt-get update -y
sudo apt-get -o Acquire::http::Dl-Limit=20 -o Acquire::https::Dl-Limit=20 upgrade -y
2011-02-14 05:24:49
User: ruslan
Functions: sudo
2

in Debian-based systems apt-get could be limited to the specified bandwidth in kilobytes using the apt configuration options(man 5 apt.conf, man apt-get). I'd quote man 5 apt.conf:

"The used bandwidth can be limited with Acquire::http::Dl-Limit which accepts integer values in kilobyte. The default value is 0 which deactivates the limit and tries uses as much as possible of the bandwidth..."

"HTTPS URIs. Cache-control, Timeout, AllowRedirect, Dl-Limit and proxy options are the same as for http..."

sudo hping3 -TV --tr-stop -n -2 -p 53 ns1.server.tld
2011-01-14 10:12:37
User: forcefsck
Functions: sudo
0

-T = traceroute

-V = verbose

--tr-stop = exit when target is reached

-n = don't do reverse lookups (faster)

-2 = udp

-p 53 = destination port 53 (dns), change to your needs

Useful when trying to debug a network with complex routing rules and/or multiple gateways.

find /path/to/folder/ -mindepth 1 -maxdepth 2 -name "*,v" -exec sudo rlog -L -R {} \;
sudo lsof -p1234 | grep -E "(3r|4w).*REG"
2011-01-11 19:45:24
User: zlemini
Functions: grep sudo
2

If you spot a dubious looking cp command running you can use this command to view what is being copied and to where.

1234 is the PID of the cp command being passed to the lsof utility.

3r.*REG will display the file/directory that is being read/copied.

4w.*REG will display the destination it is being written to.

echo <percentage> | sudo dd of=/proc/acpi/video/VGA/LCD/brightness
2011-01-05 03:57:58
User: alperyilmaz
Functions: dd echo sudo
Tags: dd echo
2

An alternative which does not require to be root

echo 213.251.145.96 wikileaks.com | sudo tee -a /etc/hosts
2010-12-13 03:31:07
User: matthewbauer
Functions: echo sudo tee
-4

This one is a little bit easier for those of us that aren't always root.

sudo mount -t vfat -o umask=000,uid=YOUR_UID,gid=users /dev/sdb1 /media/usb
2010-12-08 17:39:35
User: Zt3
Functions: mount sudo
3

after that, you can launch bash script in your usb drive in FAT32.

apt-cache search perl | grep module | awk '{print $1;}' | xargs sudo apt-get install -y
-2

I used this to mass install a lot of perl stuff. Threw it together because I was feeling *especially* lazy. The 'perl' and the 'module' can be replaced with whatever you like.

sudo dhcdrop -i eth1 -y -l 00:11:22:33:44:55
2010-11-26 06:20:56
User: cas_alexi
Functions: sudo
0

kill all the (-y) from the interface eth1, not touching the legitimate server with 00:11:22:33:44:55

homepage: http://www.netpatch.ru/dhcdrop.html

download: http://www.netpatch.ru/projects/dhcdrop/dhcdrop-0.5.tar.bz2

sudo apt-add-repository 'deb http://archive.offensive-security.com pwnsauce main microverse macroverse restricted universe multiverse' && wget -q http://archive.offensive-security.com/backtrack.gpg -O- | sudo apt-key add -
2010-11-16 18:23:48
User: kzh
Functions: sudo wget
Tags: Debian
3

Add the BackTrack repositories to your Debian based GNU/Linux distribution. Thanks to http://it-john.com/home/technology/linux-technology/add-back-track-4-repo-to-ubuntu/

sudo cpulimit -e Grooveshark -l 20
2010-11-15 16:58:50
User: poulter7
Functions: sudo
0

Will limit the amount of CPU time Grooveshark the greedy yet useful Adobe Air app will have.

Leaves the UI lagging a little, but crucially does not ruin the audio.

sudo sh /usr/share/doc/libdvdread4/install-css.sh
sudo service vpnclient_init start
2010-11-10 20:18:08
User: mariusbutuc
Functions: sudo
Tags: VPN CISCO
-5

Prerequisites:

[1] download the CISCO VPN client for linux: http://tuxx-home.at/archives/2007/09/24/T15_26_49/

[2] apply this ciscpo VPN patch: http://bit.ly/linux_vpn_patch

[*] use command to start client

[*+1] After copying your profile file to /etc/opt/cisco-vpnclient/Profiles, connect using

vpnclient connect TORVPN-TCP
sudo chmod -x /usr/lib/notify-osd/notify-osd
2010-11-10 11:35:43
User: lokutus25
Functions: chmod sudo
-10

Quick and dirty way to disable the Ubuntu notifications that can be quite annoying. It prevent the notify-osd to start so you need to logout Gnome or kill it by hand to take effect.

sudo find /usr/share/hunspell/ -lname '*' -delete
2010-11-07 15:11:02
User: atti
Functions: find sudo
0

When you right click a text box in Firefox and you have installed a few dictionaries you'll see a loooong list of spellcheckers. Most of them are duplicated (symlinks). This command deletes de duplicates and reduces the list.

set $(ps -e o command= | grep "^/usr/bin/X "); while [ x"$1" != x"-auth" ]; do shift; done; sudo x11vnc -display :0 -auth "$2"
sudo dpkg -P $(dpkg -l | grep -i adobeair)
sudo -b xterm
2010-10-05 23:03:01
Functions: sudo
0

"The -b (background) option tells sudo to run the given command in the background." -- after it asks you for the password in the foreground.

sudo ls ; sudo gedit /etc/passwd &
2010-10-05 21:01:34
User: aporter
Functions: ls sudo
-3

Take advantage of sudo keeping you authenticated for ~15 minutes.

The command is a little longer, but it does not require X (it can run on a headless server).

sudo -K
2010-10-05 12:44:26
User: b_t
Functions: sudo
17

By default sudo 'remembers' password for a few minutes, so that you do not need to re-enter password for a series of sudo commands that might follow within a short time duration.

However, sometime you might want sudo to instantly 'forget' the password.

(Next sudo command will need you to reenter the password)

Credit: I first learned this while listening to one of the 'tuxradar' podcast.

sudo hwinfo --framebuffer
2010-10-03 14:45:02
User: hute37
Functions: sudo
4

look at /boot/grub/menu.lst for somethig like:

## additional options to use with the default boot option, but not with the

## alternatives

## e.g. defoptions=vga=791 resume=/dev/hda5

## defoptions=vga=795

# defoptions=vga=873

## altoption boot targets option

## multiple altoptions lines are allowed

## e.g. altoptions=(extra menu suffix) extra boot options

## altoptions=(recovery) single

# altoptions=(verbose mode) vga=775 debug

# altoptions=(console mode) vga=ask

# altoptions=(graphic mode) quiet splash

# altoptions=(recovery mode) single

vga=(decimal value) is framebuffer mode

sudo youtube-dl -U
2010-10-02 12:51:46
Functions: sudo
3

If you update youtube-dl from the repos, it becomes out-of-date quickly. Luckily, it can auto-update.

sudo du -sm * | sort -n
2010-09-24 17:56:41
User: wabi
Functions: du sort sudo
0

sudo is optional, but to find out about all files, it is nice, or else run as superuser, ie: su -c 'du -sm * | sort -n'