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.

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:



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!

Top Tags



Commands using sudo from sorted by
Terminal - Commands using sudo - 441 results
sudo aptitude purge ~ilinux-image-\[0-9\]\(\!`uname -r`\)
2011-03-28 13:54:21
User: ootync
Functions: sudo

Removes piling kernels from /boot, save the current one.

This command DOES NOT remove the 'linux-image-generic' package, so you'll continue getting kernel updates

sudo pacman -Rns packagename
2011-03-20 21:07:14
User: ibnarrashid
Functions: sudo

Removes the package, 'packagename' in the example ,from your system. '-R' is the actual removal option, 'n' is for removing backup configuration files saved by pacman, and 's' is for removing the dependencies of the given package which are not required by other packages. pacman does not remove configuration files, etc. created by the package.

sudo pacman -Scc
2011-03-20 20:57:42
User: ibnarrashid
Functions: sudo

Clears the package cache of all packages, installed and uninstalled packages. Do NOT USE if you might want to downgrade a package later.

sudo pacman -Sc
2011-03-20 20:55:32
User: ibnarrashid
Functions: sudo

Clears the package cache of all uninstalled packages. Does not remove package configuration files in user's home directory.

sudo reflector -l 5 -r -o /etc/pacman.d/mirrorlist
2011-03-20 20:33:35
User: ibnarrashid
Functions: sudo

Requires 'reflector' package from official repository. '5' in the example is the number of mirrors you want in the mirrorlist, could be other numbers of course.

sudo -i; add-apt-repository ppa:webupd8team/sublime-text-2; apt-get update; apt-get install sublime-text-2
2011-03-16 23:57:41
User: xmonkey
Functions: install sudo

This is the first version of the Sublime Text 2 packaging so there might be bugs.

sudo scutil --set HostName MY_NEW_HOSTNAME
sudo tcpdump -i eth0 -s 65535 -A -ttt port 11211
sudo update-alternatives --config java
2011-03-07 23:43:52
User: mccalni
Functions: sudo
Tags: java

You have openjdk and sun java installed. Many of your java plugins will not work properly. Something called IcedTea (the java web plugin) keeps crashing. Run this and select sun java to use sun java.

fdupes -r -1 path | while read line; do j="0"; for file in ${line[*]}; do if [ "$j" == "0" ]; then j="1"; else sudo ln -f ${line// .*/} $file; fi; done; done
sudo arp-scan -l
2011-02-21 21:58:27
Functions: sudo
Tags: Arp arp-scan

A much quicker and (not dirtier) option. use the man page for help. On linux/ubuntu you will need to `sudo apt-get -y install arp-scan`.

sudo usermod -a -G adm "$(whoami)"
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

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

-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

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

An alternative which does not require to be root

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

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

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

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

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

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

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