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 - 415 results
sudo echo 0 > /sys/block/sdb/queue/rotational
2009-11-27 12:16:17
User: nickleus
Functions: echo sudo
5

if you still get a permissions error using sudo, then nano the file:

sudo nano -w /sys/block/sdb/queue/rotational

and change 1 to 0

this thread:

http://www.ocztechnologyforum.com/forum/showpost.php?p=369836&postcount=15

says that this will "help the block layer to optimize a few decisions"

sudo mount -t cifs -o credentials=/path/to/credenials //hostname/sharename /mount/point
2009-11-23 23:55:20
User: magma_camel
Functions: mount sudo
-2

mounts a samba share on a remote machine using a credentials file that can be in a file tht is not accessable by other users the file will look like:

username="username"

password="password"

best option i belive

sudo mount -t cifs -o user,username="samba username" //$ip_or_host/$sharename /mnt
sudo mount -t cifs //$ip_or_host/$sharename /mnt
2009-11-23 14:24:02
User: sb
Functions: mount sudo
-2

Mount a Windows share. Usually the IP is needed for the $ip_or_host option. Getting hostnames working on a local network never seems to work.

mount | awk '/:/ { print $3 } ' | xargs sudo umount
sudo ifconfig -a | grep eth | grep HW | cut -d' ' -f11
sudo touch /forcefsck
2009-10-29 17:04:47
User: johnraff
Functions: sudo touch
37

The empty file /forcefsck causes the file system check fsck to be run next time you boot up, after which it will be removed.

This works too:

sudo >/forcefsck
sudo mount -t vfat /dev/sdb1 /mnt/sdb1
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.