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 tagged Ubuntu from sorted by
Terminal - Commands tagged Ubuntu - 74 results
alias install='sudo apt-get install'
2011-10-27 19:53:01
User: haivu
Functions: alias
Tags: Ubuntu alias
-6

I put this line in my ~/.bashrc file (which I source via ~/.bash_profile). Now, when I need to install a package, I typed *install* instead of the longer version.

dpkg -c deb_package
aptitude search ~i -F %p
2011-10-15 00:31:10
User: dbbolton
0

This will print the name of every installed package on a Debian system.

aptitude search ~d<string>
2011-08-02 05:19:13
-1

Especially useful for latex packages, which are listed in the description of their Ubuntu package E.g. say I want to find the Ubuntu package containing latex package aeguill:

aptitude search ~daeguill

p texlive-lang-french - TeX Live: French

sudo sh -c 'gunzip -c source.gz > destination'
2011-07-05 23:51:01
User: UnixNeko
Functions: sh sudo
0

Extracting .gz files and placing the output in another directory in one command line is convenient thing.

I just followed some how-to to install Nagios on Ubuntu Lucid Lynx but they give the method to install from archives. I wished to install from the repository. If you do so some files are missing. I've not tested yet but this is an example command line I did to extract

sudo sh -c 'gunzip -c /usr/share/doc/nagios3-common/examples/template-object/templates.cfg.gz > /etc/nagios3/objects/templates.cfg'

We need privilege to write the destination file.

pgrep -lf gnome-panel | awk '{if ($2=="gnome-panel") print $1}' | xargs kill -9
2011-06-12 12:23:27
User: UnixNeko
Functions: awk kill xargs
-2

I have some problems with gnome panel which does not load completely leaving me without the actual GUI. This commands helps to kill the gnome-panel process then it should be relaunch automatically.

dlocate /path/to/file
2010-11-18 19:07:12
User: towo
7

Works similar to dpkg -S, but uses the locatedb and is thus inarguably a lot faster - if the locatedb is current.

sudo sh /usr/share/doc/libdvdread4/install-css.sh
sudo chmod -x /usr/lib/notify-osd/notify-osd
2010-11-10 11:35:43
User: lokutus25
Functions: chmod sudo
-10

Quick and dirty way to disable the Ubuntu notifications that can be quite annoying. It prevent the notify-osd to start so you need to logout Gnome or kill it by hand to take effect.

ffmpeg -i 100_0029.MOV -ss 00:00:00 -t 00:04:00 100_0029_1.MOV
2010-08-08 23:43:28
User: nickleus
2

i have a large video file, 500+ MB, so i cant upload it to flickr, so to reduce the size i split it into 2 files. the command shows the splitting for the first file, from 0-4 minutes. ss is start time and t is duration (how long you want the output file to be).

credit goes to philc: http://ubuntuforums.org/showthread.php?t=480343

NOTE: when i made the second half of the video, i got a *lot* of lines like this:

frame= 0 fps= 0 q=0.0 size= 0kB time=10000000000.00 bitrate= 0.0kbit

just be patient, it is working =)

sudo dpkg-reconfigure -a
chmod -R u=rw-x+X,g=r-x+X,o= .
2010-07-16 18:42:00
User: donnoman
Functions: chmod
Tags: bash Ubuntu
-1

forces user to rw, group to r, and other to no access.

files will not be marked executable.

directories will be executable for users and groups only.

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
2010-06-10 20:33:32
User: mitzip
Functions: sed sudo xargs
4

This will remove all installed kernels on your debian based install, except the one you're currently using.

From:

http://tuxtweaks.com/2009/12/remove-old-kernels-in-ubuntu/comment-page-1/#comment-1590

ubuntu-bug
2010-05-02 20:24:32
User: rkulla
2

As of 10.04 LTS, you need to use this command-line to reports bugs to the launchpad.net tracking system (you need a launchpad acct for this to work). This command is preferred over using the website because it collects/sends info about your system to help developers.

ubuntu-bug is a symlink to apport-bug which sees if KDE/Gnome is running and calls apport-gtk/apport-kde dialogs, otherwise apport-cli, so you can fill out a bug report.

First run 'ubuntu-bug' without args to see a list of known symptoms. If there's no matching symptom, or you know which package is to blame, then run 'ubuntu-bug <package>'. If the process is still running, use 'ubuntu-bug <PID>'

APP=wine; if [ $(sudo apt-get --print-uris -y install $APP | sed -ne 's/^After this operation, \([0-9]\{1,\}\).*MB.*/\1/p') -gt 50 ]; then gnometris 2>/dev/null & sudo apt-get install $APP; else sudo apt-get install $APP; fi
2010-04-18 19:32:26
User: rkulla
Functions: install sed sudo
2

Change the APP variable's value to whatever you want to install. Depending on how fast your machine is, you'll want to adjust the value 50 to something else. You might also want to play a different game than Gnometris - just make sure it's a GUI game.

watch -n 1 "sudo asterisk -vvvvvrx 'core show channels' | grep call"
2010-03-26 15:42:13
User: mheadd
Functions: watch
5

Show active calls as the happen on an Asterisk server. Note that the Asterisk command (in single quotes) is formatted for Asterisk 1.6. Use the -n flag on the watch command to modify the refresh period (in seconds - default is 2 seconds).

sudo chattr -i <file that cannot be modified>
2010-03-25 03:14:34
User: leovailati
Functions: chattr sudo
Tags: Ubuntu chattr
1

I had problems in Ubuntu while trying to edit /etc/resolv.conf, even with sudo I couldn't make any change. After a 2 minutes search on google I found this command.

Hope someone finds it useful.

It works like chmod, with + and - to denote which attributes are being added and which are being removed.

See other attributes on man pages or on wikipedia http://en.wikipedia.org/wiki/Chattr

sudo apt-get -o Acquire::http::Dl-Limit=30 upgrade
2010-03-22 01:29:44
User: alemani
Functions: sudo
16

Limits the usage of bandwidth by apt-get, in the example the command will use 30Kb/s ;)

It should work for most apt-get actions (install, update, upgrade, dist-upgrade, etc.)

flac -cd input.flac |lame -h - output.mp3
2010-03-05 23:54:21
User: nickleus
1

if you haven't already done so, install lame and flac:

sudo apt-get install lame flac

echo "pretty realistic virtual typing" | randtype -m 4
2010-02-25 15:30:28
User: tehdog
Functions: echo
4

this also generates errors (change 4 to higher number for more mistakes)

sudo aptitude update; sudo apt-get -y --print-uris upgrade | egrep -o -e "http://[^\']+" | sudo aria2c -c -d /var/cache/apt/archives -i -; sudo aptitude -y safe-upgrade
2010-02-18 16:02:29
User: freethinker
Functions: egrep sudo
2

Please install aria2c before you try the above command. On ubuntu the command to install aria2c would be:

sudo aptitude install aria2
ffmpeg -i /var/lib/mythtv/pretty/Chuck20100208800PMChuckVersustheMask.mpg -s 800x480 -vcodec mpeg4 -acodec libfaac -ac 2 -ar 16000 -r 13 -ab 32000 -aspect 16:9 Chuck20100208800PMChuckVersustheMask.mp4
2010-02-12 12:11:02
User: PLA
2

This command will transcode a MythTV recording. The target device is a Google Nexus One mobile phone. My recordings are from a HDHomerun with Over The Air content. Plays back nicely on the N1.

sudo sed -iorig '/\(up\|down\)/s/^/#/' /etc/zsh/zshrc
2010-02-02 23:17:08
User: cbrinker
Functions: sed sudo
Tags: Ubuntu vi zsh
1

Use sed to comment out any up/down bindings in zsh