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.

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

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using sudo from sorted by
Terminal - Commands using sudo - 419 results
sudo dmidecode | grep Serial\ Number | head -n1
2009-02-18 14:54:28
User: nlinux
Functions: grep head sudo
14

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
8

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

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

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
3

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.

Alternatively,

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
-8

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
9

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
-5

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
2

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
-1

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
-7

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"
sudo echo 1 > /proc/acpi/asus/camera
2009-02-07 21:57:01
User: orie
Functions: echo sudo
0

In some applications on eeepc xandros 7, default OS, video ccamera is not available untill you enter this command

sudo -u username bash
2009-02-06 00:52:18
User: troelskn
Functions: sudo
5

You need sudo privileges for this command.

Replace username with actual username.

sudo netstat -punta
sudo lsof | awk '{printf("%s %s %s\n", $1, $3, $NF)}' | grep -v "(" | sort -k 4 | gawk '$NF==prv{ct++;next} {printf("%d %s\n",ct,$0);ct=1;prv=$NF}' | uniq | sort -nr