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 - 429 results
sudo find / -type f \( -perm /4000 -a -user root \) -ls -o \( -perm /2000 -a -group root \) -ls
2009-03-02 18:48:17
User: atoponce
Functions: find sudo

Discovering all executables on your system that can be run as another user, especially root, is critical for system security. The above command will find those files with have SUID or SGID bits set and are owned by the root user or group.

sudo find / -mmin 60 -type f
2009-03-01 23:03:31
User: atoponce
Functions: find sudo

Useful mainly for debugging or troubleshooting an application or system, such as X11, Apache, Bind, DHCP and others. Another useful switch that can be combined with -mmin, -mtime and so forth is -daystart. For example, to find files that were modified in the /etc directory only yesterday:

sudo find /etc -daystart -mtime 1 -type f
sudo mount -o remount,rw /
2009-03-01 13:36:05
User: blindgaenger
Functions: mount sudo
Tags: mount remount rw

Saved my day, when my harddrive got stuck in read-only mode.

sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
2009-02-27 20:23:37
User: bandit36
Functions: dd sudo
Tags: backup dd

This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations.

sudo dd if=/media/disk/backup/sda.backup of=/dev/sda

Alternatively, you can use an SSH connection to do your backups:

dd if=/dev/sda | ssh user@ssh.server.com dd of=~/backup/sda.backup
sudo ufw allow proto tcp from to any port 80
function miso () { mkdir ~/ISO_CD && sudo mount -o loop "$@" ~/ISO_CD && cd ~/ISO_CD && ls; } function uiso () { cd ~ && sudo umount ~/ISO_CD && rm -r ~/ISO_CD; }
2009-02-25 03:41:35
User: vududevil
Functions: cd mkdir mount rm sudo umount

Add the functions to the .bashrc to make it work

Example: First go to the iso file directory and type:


user@box:~$ miso file.iso


It will put you into a temporary mounting point directory (ISO_CD) and will show the files

You can umount the iso file whatever the directory you are


user@box:~/ISO_CD$ uiso


It wil umount the iso file and remove the temporary directory in your home

sudo !!
2009-02-25 00:52:28
User: silbermm
Functions: sudo

I often forget to type sudo before a command that needs it. This is the quickest way to rerun the command prefixed by sudo.

sudo route add xxx.xxx.xxx.xxx gw lo
2009-02-23 19:58:09
Functions: route sudo
Tags: Security

Someone might attack on your system. You can drop attacker IP using IPtables. However, you can use route command to null route unwanted traffic. A null route (also called as blackhole route) is a network route or kernel routing table entry that goes nowhere. Matching packets are dropped (ignored) rather than forwarded, acting as a kind of very limited firewall. The act of using null routes is often called blackhole filtering.

sudo hdparm -Tt /dev/sda
apt-get () { [ "$1" = source ] && (command apt-get "$@";true) || sudo apt-get "$@" }
2009-02-19 04:17:24
User: mulad
Functions: apt command sudo

An apt-get wrapper function which will run the command via sudo, but will run it normally if you're only downloading source files.

This was a bit of an excuse to show off the framework of

cmd && echo true || echo false

...but as you can see, you must be careful about what is in the "true" block to make sure it executes without error, otherwise the "false" block will be executed.

To allow the apt-get return code to pass through, you need to use a more normal if/else block:

apt-get () { if [ "$1" = source ]; then command apt-get "$@"; else sudo apt-get "$@"; fi }
sudo dmidecode | grep Serial\ Number | head -n1
2009-02-18 14:54:28
User: nlinux
Functions: grep head sudo

This will give you the Dell Service tag number associated with your machine. Incredibly useful when you need that number for tech support or downloads.

sudo -l
2009-02-18 14:17:39
User: raphink
Functions: sudo

List the commands you have the right to use with sudo.

sudo su
2009-02-18 14:03:27
User: Vulpine
Functions: sudo

Opens a new shell as root. Useful if you want to run a lot of commands as superuser without needing to sudo each of them.

echo "foo bar" | sudo tee -a /path/to/some/file
2009-02-18 13:54:25
User: raphink
Functions: echo sudo tee

This is the solution to the common mistake made by sudo newbies, since

sudo echo "foo bar" >> /path/to/some/file

does NOT add to the file as root.


sudo echo "foo bar" > /path/to/some/file

should be replaced by

echo "foo bar" | sudo tee /path/to/some/file

And you can add a >/dev/null in the end if you're not interested in the tee stdout :

echo "foo bar" | sudo tee -a /path/to/some/file >/dev/null
sudo find / -user root -perm -4000 -print
sudo /etc/init.d/networking restart
2009-02-16 07:30:54
User: StephSD3
Functions: sudo

when I turn on my wifi, I always have to put in this command in order to make my laptop notice the wifi.

sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoclean && sudo apt-get autoremove
sudo dmidecode | more
2009-02-16 03:32:30
User: oreo
Functions: sudo

wanna know something about your hardware? how about EVERYTHING?? then this should do ya well

sudo alsa force-reload
2009-02-16 03:30:13
User: oreo
Functions: sudo

if you lose your sound, this will restart alsa and you will get your sound back

sudo dpkg --purge `dpkg -l | awk '/^r/{print $2}'`
2009-02-16 02:18:02
User: elleryq
Functions: awk sudo

After you install/remove lots of packages, there are many packages marked with 'rc'. This script help you to purge these packages, it will save some spaces from your disk.

sudo aptitude -y install iasl && sudo cat /sys/firmware/acpi/tables/DSDT > dsdt.dat && iasl -d dsdt.dat
2009-02-15 23:13:50
User: brettalton
Functions: cat install sudo

In July 2008, there was an uproar over Foxconn motherboards feeding Linux installs incorrect ACPI information (http://ubuntu-virginia.ubuntuforums.org/showthread.php?t=869249).

Foxconn has gladly corrected their mistake, but make sure it's not happening on your motherboard!

After running the command, just view the 'dsdt.dsl' in any editor you like.

sudo apt-get install preload
2009-02-13 19:34:57
User: danfernbanck
Functions: install sudo

this application monitors the apps you use most often and load them into memory with their libraries and other dependencies.

So now, when you launch Firefox or Thunderbird or OpenOffice, the display is immediate as on Mac.

sudo date mmddhhxxyyyy
sudo date -s "26 OCT 2008 19:30:00"