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 - 400 results
sudo hal-get-property --udi /org/freedesktop/Hal/devices/computer --key 'system.formfactor'
sudo hal-get-property --udi /org/freedesktop/Hal/devices/computer --key 'system.hardware.product'
sudo svn co svn+ ciccio_diverso://root@192.160.150.151/svn-repo/progettino
2012-02-03 18:16:02
User: 0disse0
Functions: sudo
Tags: subversion
0

first need to Edit the configuration file

/home/cicciobomba/.subversion

and under the [tunnels] add this line

ciccio_diverso = /usr/bin/ssh -p 12345

sudo cpupower frequency-set -f <frequency in MHz>
2012-01-27 07:56:34
User: ThatMexikan
Functions: sudo
0

Allows for manual set of the CPU's frequency. First look at "cpupower frequency-info" for all the available frequency steps your processor can be set at.

e.g.

sudo cpupower frequency-set -f 1100MHz

sudo cpupower frequency-set -g <frequency governor>
2012-01-27 07:48:10
User: ThatMexikan
Functions: sudo
0

Lets you change/set a governor to handle the frequency of your CPU.

Available governors are: "powersave", "conservative", "ondemand", "performance", and "userspace".

ssh user@server.com sudo tcpdump -i eth0 -w - 'port 80'| /Applications/Wireshark.app/Contents/Resources/bin/wireshark -k -i -
sudo sh -c "echo '127.0.0.1 www.facebook.com' >> /etc/hosts"
2012-01-16 14:06:51
User: devalnor
Functions: sh sudo
6

or

echo '127.0.0.1 facebook.com' | sudo tee -a /etc/hosts

Do not execute this command if you don't know what you are doing.

sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
2011-12-16 10:39:13
User: Dhinesh
Functions: iptables sudo
Tags: iptables
-2

This command will open tcp port 3000 in your machine

sudo update-rc.d -f gdm remove
2011-12-16 10:12:21
User: kev
Functions: sudo
Tags: update-rc.d
-2

run `sudo update-rc.d gdm defaults` to get it back

checkport() { sudo nmap -sS -p $1 $2 }
2011-12-13 11:46:15
Functions: sudo
Tags: nmap scan port
0

Check to see if a port is open or closed on a given host.

sudo ps aux --sort:rss | awk '{print $2"\t"$11": "$6/1024" MB"}' | column -t | less
sudo dd if=/dev/block/device bs=1MB | pv -s `sudo blockdev --getsize64 /dev/block/device' | gzip -9 > output.img.gz
sudo ethtool -i eth0
2011-12-01 13:48:09
User: Dhinesh
Functions: sudo
Tags: ethtool
1

Queries the specified ethernet device for associated driver information

t=$(df|awk 'NR!=1{sum+=$2}END{print sum}');sudo du / --max-depth=1|sed '$d'|sort -rn -k1 | awk -v t=$t 'OFMT="%d" {M=64; for (a=0;a<$1;a++){if (a>c){c=a}}br=a/c;b=M*br;for(x=0;x<b;x++){printf "\033[1;31m" "|" "\033[0m"}print " "$2" "(a/t*100)"% total"}'
2011-12-01 01:21:11
User: kevinquinnyo
Functions: awk du sed sort sudo
13

i'm using gawk, you may get varying mileage with other varieties. You might want to change the / after du to say, /home/ or /var or something, otherwise this command might take quite some time to complete. Sorry it's so obsfucated, I had to turn a script into a one-liner under 255 characters for commandlinefu. Note: the bar ratio is relative, so the highest ratio of the total disk, "anchors" the rest of the graph. EDIT: the math was slightly wrong, fixed it. Also, made it compliant with older versions of df.

sudo cpulimit -p pid -l 50
2011-11-21 08:43:57
User: Dhinesh
Functions: sudo
Tags: cpu
20

This will limit the average amount of CPU it consumes.

sudo update-rc.d <scriptname> defaults
2011-11-19 08:55:38
User: Dhinesh
Functions: sudo
Tags: Ubuntu
2

This script will run each time you boot up.The script must be in /etc/init.d directory.

!w sudo tee %
lxc-ls | sort -u | xargs -i sudo lxc-info -n {}
2011-10-28 11:10:02
User: Rhonda
Functions: sort sudo xargs
Tags: status lxc
0

This short snippet outputs the state of all containers available on your system. It is quite helpful to see which ones are running and which are stopped. Please notice that the "sort -u" is needed, otherwise running containers will be reported twice (see output of "lxc-ls" on its own for why)

sudo /opt/nessus/sbin/nessusd
2011-10-22 19:04:43
User: ozzy
Functions: sudo
Tags: Nessus
0

Starts the Nessus daemon, downloads and processes the plugins.

for D in `mount -lt cifs | sed 's/.*on \(\/.\+\) type.*/\1/'`; do echo -n "UNMOUNTING $D..."; sudo umount $D; echo " [DONE]"; done;
2011-10-19 18:14:19
User: crazedsanity
Functions: echo sed sudo umount
0

Unmounts all CIFS-based network drives. Very nice for shutting down network mounts on a Linux laptop just prior to going to sleep.

sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo tcpdump -n -i eth0 -w data.pcap -v tcp or udp and 'not host 192.168.1.2'
sudo dpkg -i `ls -tr *.deb | tail -n4`
2011-10-09 14:20:11
User: _john
Functions: sudo tail
0

after kernel build with make deb-pkg, I like to install the 4 newest packages that exist in the directory. Beware: might be fewer for you....

sudo grub-install --root-directory=/media/ubuntu /dev/sda
2011-09-27 17:51:56
User: totti
Functions: sudo
Tags: grub boot fix
-2

From live CD mount(open) the Ubuntu installed drive.

Copy the location (press Ctrl+l, Ctrl+c ) eg: /media/ubuntuuuu

Open terminal (Apllication->accessories->terminal)

Type this:

sudo grub-install --root-directory=/media/ubuntuuuu /dev/sda

(replace /media/ubuntuuuu with what u got (ie paste))

Will show success message. Now reboot