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 - 407 results
for file in *.iso; do mkdir `basename $file | awk -F. '{print $1}'`; sudo mount -t iso9660 -o loop $file `basename $file | awk -F. '{print $1}'`; done
sudo fc-cache -f -v
2009-10-07 11:01:29
User: eastwind
Functions: fc-cache sudo
4

Refresh the cache of font directory , usefull after you download font (.ttf or other) from various website and you don't want to reboot or relogin . Close your word processor before using the command , after the refresh reopen your word processor , new fonts is avaible !

sudo alien --to-deb Your_PackAge.rpm
2009-09-27 13:49:07
User: eastwind
Functions: sudo
-5

convert to debian package file (deb) a redhat package file (rpm) , then you can install it by using dpkg , require alien package ( sudo apt-get install alien first )

echo "blacklist pcspkr"|sudo tee -a /etc/modprobe.d/blacklist.conf
2009-09-27 11:42:47
User: sliceoflinux
Functions: echo sudo tee
4

This command will disable the beep sound from the PC speaker.

sudo tasksel install lamp-server
2009-09-26 08:15:03
User: sliceoflinux
Functions: install sudo
5

The execution of this command will install a LAMP server (Linux, Apache, MySQL and PHP) in a Debian based distribution. For example, in Ubuntu.

sudo dpkg -i packagename.deb
2009-09-25 09:54:04
User: bkn390
Functions: sudo
-7

Install a deb package you have downloaded (synaptic has to be closed).

(dpkg-dev needs to be installed)

After that you may have to run following:

sudo apt-get install -f

(that should fix any dependency problems)

I am using ubuntu linux

sudo lshw -C cpu|grep width
sudo chown -R user2:user2 /../../somedirectory
2009-09-23 21:27:45
User: bkn390
Functions: chown sudo
-1

This will change the ownership of /../../somedirectory as well as all its subdirectories so they will be be owned by user2 - typically used when a directory is owned by root:root

(echo "set terminal png;plot '-' u 1:2 t 'cpu' w linespoints;"; sudo vmstat 2 10 | awk 'NR > 2 {print NR, $13}') | gnuplot > plot.png
find repMainPath -maxdepth 1 -mindepth 1 -type d | while read dir; do echo processing $dir; sudo svnadmin dump --deltas $dir >dumpPath/`basename $dir`; done
2009-09-15 20:14:51
User: Marco
Functions: dump echo find read sudo
Tags: bash svn
2

This command dumps all SVN repositories inside of folder "repMainPath" (not recursively) to the folder "dumpPath", where one dump file will be created for each SVN repository.

sudo tune2fs -m 1 /dev/sda4
2009-09-14 21:11:55
User: bassel
Functions: sudo tune2fs
2

According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition.

http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/

sudo arp -s 192.168.1.200 00:35:cf:56:b2:2g temp && ssh root@192.168.1.200
2009-09-11 07:49:28
User: svg
Functions: arp ssh sudo
8

Instead of looking for the right ip address, just pick whatever address you like and set a static ip mapping.

sudo dd if=/dev/hda1 of=/dev/hdb2
2009-09-05 09:16:52
User: 0disse0
Functions: dd sudo
5

This command clone the first partition of the primary master IDE drive to the second partition

of the primary slave IDE drive (!!! back up all data before trying anything like this !!!)

sudo mknod /dev/ttyS4 c 4 68
2009-09-05 09:12:44
User: 0disse0
Functions: c++ mknod sudo
Tags: serial mknod tty
0

When you need to add another tty device that can automatically start at boot time

sudo dscl localhost -append /Local/Default/Groups/admin GroupMembership username
2009-09-03 04:40:10
User: kulor
Functions: sudo
0

adding users to groups on OS X is not a straightforward process, you need to use the new in built in Directory Service command line utility...

sudo grub-install --recheck /dev/sda1
sudo /bin/netstat -tpee
2009-08-28 04:02:10
User: unixbhaskar
Functions: sudo
Tags: shell
3

To get the connection information of protocol tcp and extended infortmation.

sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
2009-08-27 14:18:47
User: alvinx
Functions: du find sudo tail xargs
2

get diskusage of files (in this case logfiles in /var/log) modified during the last n days:

sudo find /var/log/ -mtime -n -type f | xargs du -ch

n -> last modified n*24 hours ago

Numeric arguments can be specified as

+n for greater than n,

-n for less than n,

n for exactly n.

=> so 7*24 hours (about 7 days) is -7

sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
sudo aptitude unmarkauto $(apt-cache depends some-deb-meta-package-name | grep Depends | cut -d: -f2)
2009-08-26 12:56:33
User: yra
Functions: cut grep sudo
2

Debian: Mark all dependent packages as manually installed. So they are not automatically removed if you remove some meta package - like gnome-desktop-environment for example.

sudo iptables-save > /etc/iptables.up.rules
2009-08-19 14:55:05
User: kamiller
Functions: iptables-save sudo
-3

Stores the currently active iptables rules to a file that will be applied upon reboot

sudo iptables-restore < /etc/iptables.test.rules
2009-08-19 14:38:08
User: kamiller
Functions: iptables-restore sudo
Tags: iptables
-2

If you don't save the rule set it won't be applied during a reboot

sudo dmesg
sudo du -ks $(ls -d */) | sort -nr | cut -f2 | xargs -d '\n' du -sh 2> /dev/null
2009-08-17 22:21:09
User: Code_Bleu
Functions: cut du ls sort sudo xargs
Tags: disk usage
7

This allows the output to be sorted from largest to smallest in human readable format.

vditool COPYDD my.vdi my.dd ; sudo mount -t ntfs -o ro,noatime,noexex,loop,offset=32256 my.dd ./my_dir