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.


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.

Universal configuration monitoring and system of record for IT.
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

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using sudo from sorted by
Terminal - Commands using sudo - 440 results
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 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
3

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 {} ";"
sudo sync && sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
2012-03-17 08:27:58
User: StephenJudge
Functions: echo sudo sync tee
Tags: memory cache
-1

"That's it. Not much to see here. The first command writes any cache data that hasn't been written to the disk out to the disk. The second command tells the kernel to drop what's cached. Not much to it. This invalidates the write cache as well as the read cache, which is why we have the sync command first. Supposedly, it is possible to have some cached write data never make it to disk, so use it with caution, and NEVER do it on a production server. You could ... but why take the risk?

As long as you are running a post 2.6.16 kernel,..."

Source: http://ubuntuforums.org/showpost.php?p=3621283&postcount=1

sudo xvfb-run --server-args="-screen 0, 1024x768x24" ./webkit2png.py -o google.png http://www.google.com
sudo `which adb` ppp "shell:pppd nodetach noauth noipdefault /dev/tty" nodetach noauth noipdefault notty 192.168.0.100:192.168.0.200
sudo find . -name "syslog*.gz" -type f | xargs gzip -cd | grep "Mounted"
sudo curl "http://hg.mindrot.org/openssh/raw-file/c746d1a70cfa/contrib/ssh-copy-id" -o /usr/bin/ssh-copy-id && sudo chmod 755 /usr/bin/ssh-copy-id
2012-02-09 20:29:24
User: misterich
Functions: chmod sudo
-1

Mac install ssh-copy-id

From there on out, you would upload keys to a server like this:

(make sure to double quote the full path to your key)

ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" [email protected]

or, if your SSH server uses a different port (often, they will require that the port be '2222' or some other nonsense:

(note the double quotes on *both* the "/path/to/key" and "[email protected] -pXXXX"):

ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" "[email protected] -pXXXX"

...where XXXX is the ssh port on that server

x="/tmp/auth.html";sudo cat /var/log/auth.log | logtool -o HTML >$x;xdg-open $x;rm $x
2012-02-09 13:36:21
Functions: cat rm sudo
0

similar to previous except this exports to a temporary file, opens that file with your default web browser, then deletes it.

sudo dmidecode -s system-product-name
sudo dmidecode | grep Product
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:[email protected]/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
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
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 [email protected] 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
7

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.