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 ssh -D 88 -fN user@xxxx.no-ip.info
sudo shred -vz -n 0 /dev/sdb
sudo /etc/init.d/dns-clean
2012-08-06 18:40:49
User: varghjarta
Functions: sudo
Tags: Network Ubuntu
0

Flush the DNS cache under Ubuntu (Debian?)

sudo find / \( -nouser -o -nogroup \)
2012-07-13 07:09:08
User: gwd
Functions: find sudo
1

suspicious/anomalous ownership may indicate system breach; should return no results

sudo find / -perm -2 ! -type l -ls
sudo apt-get remove $(dpkg -l|awk '/^ii linux-image-/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic-pae//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic*\nlinux-image-%s-generic*\n",$0,$0,$0)}')
can(){ shift 2; sudo "$@"; }
sudo lshw -C network
sudo bash -c "sleep 30m; pm-hibernate"
2012-05-21 17:56:11
Functions: bash sudo
0

Can use minute - m, hour - h

Eg: sudo bash -c "sleep 2h; pm-hibernate"

will hibernate the system after 2hours.

while pgrep wget || sudo shutdown -P now; do sleep 1m; done
cd /System/Library/LaunchDaemons; sudo launchctl load -w com.apple.metadata.mds.plist
sudo killall -HUP mDNSResponder
2012-05-15 18:33:51
User: Xeno
Functions: killall sudo
0

Purges DNS cache of OS X.

dscacheutil -flushcache does not work since OS X 10.7.

sudo scp <file or folder> <name of pc 1>@<IP of pc 2>:
sudo echo "package url" >> /etc/apt/sources.list
2012-05-01 21:32:51
User: Gunni
Functions: echo sudo
0

">>" appends to the file

">" replaces the entire file

make sure to use ">>"

find . -user root | xargs sudo chown me:me
2012-04-24 18:29:13
Functions: chown find sudo xargs
-2

be careful where you execute this from

do a 'sudo ls' beforehand to prime sudo to not ask for your password

while true; do sudo cat /dev/input/mouse0|read -n1;streamer -q -o /tmp/cam.jpeg -s 640x480 > /dev/null 2>&1; sleep 10;done
2012-04-22 01:51:30
User: SQUIIDUX
Functions: cat read sleep sudo
Tags: cat streamer
4

This takes a webcam picture every everytime the mouse is moved (waits 10 seconds between checking for movement) and stores the picture wherever you want it.

Ideas:

Use in conjunction with a dropbox type application to see who is using your computer

Use /dev/input/mice if /dev/input/mouse* doesn't work

Use the bones of this to make a simple screensaver

echo "[some repository]" | sudo tee -a /etc/apt/sources.list
2012-04-21 17:54:08
Functions: echo sudo tee
-2

For instance, to add mongodb 10gen package

echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list

echo mem|sudo tee /sys/power/state
sudo usermod -a -G vboxusers <username>
sudo locale-gen en_GB.UTF-8 && sudo locale-gen --purge && sudo dpkg-reconfigure locales
2012-04-09 08:33:22
User: WMP
Functions: sudo
1

Fix for ubuntu error:

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = "en_GB:en",

LC_ALL = (unset),

LANG = "en_GB.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

locale: Cannot set LC_CTYPE to default locale: No such file or directory

locale: Cannot set LC_MESSAGES to default locale: No such file or directory

locale: Cannot set LC_ALL to default locale: No such file or directory

sudo apt-get remove $(dpkg -l|awk '/^ii linux-image-/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
2012-04-02 10:53:40
User: mtron
Functions: awk sed sudo
-1

small update for this command to work with linux kernels 3.x

sudo dpkg-reconfigure keyboard-configuration
2012-03-27 21:07:45
Functions: sudo
1

Bash snippet to force GNU/Linux keyboard settings, layout and configuration.

Usefull when some GNU/Linux distributions such as *Ubuntu's store only limited configation options due to demonstration purposes on LiveUSB or Live persistent devices.

Overcomes the English QWERTY to French AZERTY settings failure.

Code bash en ligne de commande pour forcer l'adoption du clavier AZERTY sur les cl? USB bootable en Ubuntu.

ps h --ppid $(cat /var/run/apache2.pid) | awk '{print"-p " $1}' | xargs sudo strace
2012-03-21 01:59:41
Functions: awk cat ps sudo xargs
2

Like the original version except it does not include the parent apache process or the grep process and adds "sudo" so it can be run by user.

sudo find foldername -type f -exec chmod 644 {} ";"
sudo find foldername -type d -exec chmod 755 {} ";"