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 - 408 results
sudo shutdown -h now
sudo !-1
2013-04-22 03:45:14
User: datamining
Functions: sudo
0

this command also can run the last command as root

what's more, sudo !-2 can run the second last command as root , and so on

sudo shutdown -h <hour:minute>
sudo dmidecode --type 17
2013-04-18 20:13:07
User: FadeMind
Functions: sudo
Tags: ram dmidecode
0

Advanced information about RAM.

sudo apt-get install linux-headers-`uname -r`
2013-04-18 03:18:26
User: farazyashar
Functions: install sudo
2

Install the Linux kernel headers for currently running kernel version on Debian-based systems via apt-get

sudo sed -i 's/Exec=skype %U/Exec=skype --disable-cleanlooks -style GTK %U/' /usr/share/applications/skype.desktop
2013-04-17 08:43:00
User: FadeMind
Functions: sed sudo
0

Replace default command in skype.desktop file.

sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config -y && git clone https://github.com/hanschen/ksuperkey.git && cd ksuperkey && make && sudo mv ksuperkey /usr/bin/ksuperkey && cd ~ && rm -rf ksuperkey
2013-04-17 07:12:46
User: FadeMind
Functions: cd gcc install make mv rm sudo
0

Install Ksuperkey one command in Kubuntu.

You must manually add ksuperkey to autostart in System Settings KDE.

sudo sed -i 's/raspberrypi/pita1/' /etc/hosts /etc/hostname; sudo reboot
2013-04-16 07:27:41
User: egeoffray
Functions: sed sudo
0

Your computer's name is raspberrypi and you want to rename it to pita1.

This command will change both the hostname and the name used for netwrk communications.

sudo shutdown 3600 -P
2013-04-14 16:14:23
Functions: shutdown sudo
-4

You can easily stop shutdowning process by CTRL+C

sudo -u apache find . -not -perm /o+r
sudo -u apache find . -not -readable
sudo port selfupdate ; echo '---------' ; sudo port upgrade outdated
dpkg --list | grep '^rc\b' | awk '{ print $2 }' | xargs sudo dpkg -P
sudo apt-get update && sudo apt-get upgrade && sudo apt-get clean
sudo cp /usr/share/zoneinfo/Europe/Paris /etc/localtime
sudo ifconfig wlan0 | grep inet | awk 'NR==1 {print $2}' | cut -c 6-
2013-02-18 14:10:07
User: mouths
Functions: awk cut grep ifconfig sudo
-1

On wired connections set 'eth0' instead of 'wlan0'

sudo find / -type f -name config.inc.php -exec vim -p {} +
2013-02-12 11:00:02
User: sinevar
Functions: find sudo vim
2

Opening several files at once in Vim can be very easy in connection with find command.

sudo apt-get <apt-get command and options> --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > dowload_deb_list.txt
sudo dd if=/dev/sdc bs=4096 | pv -s `sudo mount /dev/sdc /media/sdc && du -sb /media/sdc/ |awk '{print $1}' && sudo umount /media/sdc`| sudo dd bs=4096 of=~/USB_BLACK_BACKUP.IMG
export BLOCKSIZE='sudo blockdev --getsize64 /dev/sdc' && sudo dd if=/dev/sdc bs=1MB | pv -s $BLOCKSIZE | gzip -9 > USB_SD_BACKUP.img.gz
2013-02-05 18:10:25
User: hur1can3
Functions: dd export gzip sudo
2

This is a useful command to backup an sd card with relative total size for piping to pv with a progressbar

sudo nethogs eth0
alias locate='if [ $((`date +%s`-`eval $(stat -s /var/db/locate.database); echo $st_mtime`)) -gt 3600 ]; then echo "locate: db is too old!">/dev/stderr; sudo /usr/libexec/locate.updatedb; fi; locate -i'
2013-01-21 17:45:50
User: jhyland87
Functions: alias echo locate stat sudo
Tags: locate osx mac
0

MAC OSX doesn't come with a locate command, This will do the same thing as the locate command on a typical Linux OS.

Simply add it to your ~/.bash_profile

sudo pm-hibernate
for ARG in * ; do sudo -u USER 7z x -o"$(echo $ARG|sed 's/\(.*\)\..*/\1/')" "$ARG" ; done
2012-12-31 19:47:24
User: n158
Functions: sudo
0

Magic line will extract almost all possible archives from current folder in its own folders. Don't forget to change USER name in sudo command. sed is used to create names for folders from archive names w/o extension. You can test sed expression, used in this command:

arg='war.lan.net' ; x=$(echo $arg|sed 's/\(.*\)\..*/\1/') ; echo $x

If some archives can't be extracted, install packages:

apt-get install p7zip-full p7zip-rar

Hope this will save a lot of your time. Enjoy.

sudo !!
2012-12-21 03:37:40
User: Travis
Functions: sudo
Tags: sudo
0

you will be sad after you run a command and find out it needs root, so you should run it again but with prefix sudo.

so this line is to make it simple. just 'sudo !!'