All commands (14,187)

  • If run in bash, this will display all executables that are in your current $PATH Show Sample Output


    4
    ls `echo $PATH | sed 's/:/ /g'`
    archlich · 2009-03-09 19:01:41 8
  • Run this in the directory you store your music in. mp3gain and vorbisgain applies the ReplayGain normalization routine to mp3 and ogg files (respectively) in a reversible way. ReplayGain uses psychoacoustic analysis to make all files sound about the same loudness, so you don't get knocked out of your chair by loud songs after cranking up the volume on quieter ones.


    9
    find . -iname \*.mp3 -print0 | xargs -0 mp3gain -krd 6 && vorbisgain -rfs .
    Viaken · 2009-03-09 18:11:35 12
  • I'm sure this can be piped into another way. Please share!


    2
    nohup <command> 2> /dev/null > /dev/null &
    AmadeusZull · 2009-03-09 16:54:04 10
  • I used this when I had a directory of movies from a camera. I wanted to watch a little of each movie, then rename it depending on what was in the movie. This did the trick for me.


    5
    for f in *;do mplayer $f;read $n;mv $f $n;done
    cobrajs272 · 2009-03-09 16:08:14 6
  • Listen to different voices in the system--useful for picking the voice you like


    -5
    for person in Alex Bruce Fred Kathy Vicki Victoria ; do say -v $person "Hello, my name is $person"; sleep 1; done
    haivu · 2009-03-09 15:42:13 6
  • cd into the directory that contains the file. this is just the usual move command but shortcut'd. say you wanted to move a photo img1.png from ~/photos/holidayphotos into the parent directory which is ~/photos command would be: ~/photos/holidayphotos$ mv img1.png .. I use Ubuntu so this'll work in debian but not sure what else.


    -3
    mv file_name.extension ..
    takealeft · 2009-03-09 15:35:58 7
  • I put that line in my .bash_profile (OS X) and .bashrc (Linux). Here is a summary of what the \char means: n=new line, u=user name, h=host, !=history number, w=current work directory The \[\e[32m\] sequence set the text to bright green and \[\e[0m\] returns to normal color. For more information on what you can set in your bash prompt, google 'bash prompt'


    7
    export PS1='\n[\u@\h \! \w]\n\[\e[32m\]$ \[\e[0m\]'
    haivu · 2009-03-09 15:34:22 9
  • Recursively removes all those hidden .DS_Store folders starting in current working directory.


    4
    find . -name .DS_Store -exec rm {} \;
    Svish · 2009-03-09 13:59:30 15
  • Swap TRUE with FALSE to turn it off again. Note: Finder must be relaunched afterwards to see the effect. For example like this: killall Finder && open /System/Library/CoreServices/Finder.app


    0
    defaults write com.apple.Finder AppleShowAllFiles TRUE
    Svish · 2009-03-09 13:55:31 5
  • Sometimes I need to create a directory of files to operate on to test out some commandlinefu I am cooking up. The main thing is the range ({1..N}) expansion.


    11
    touch {1..10}.txt
    slaney · 2009-03-09 12:54:45 14

  • 0
    svn diff ARGUMENTS_FOR_DIFF | source-highlight --out-format=esc --src-lang=diff
    troelskn · 2009-03-09 11:00:40 13
  • even when another instance is already open. Great for testing purposes when you need to be 2 people at once on the same site.


    14
    firefox -no-remote -P
    asmoore82 · 2009-03-09 07:03:55 11
  • the good: Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.4 with Suhosin-Patch the bad: Server: Microsoft-IIS/6.0 and the ugly: Server: Apache/2.2.10 (Win32) mod_ssl/2.2.10 OpenSSL/0.9.8i PHP/5.2.6


    8
    wget -S -O/dev/null "INSERT_URL_HERE" 2>&1 | grep Server
    asmoore82 · 2009-03-09 06:54:54 7
  • This is the result of a several week venture without X. I found myself totally happy without X (and by extension without flash) and was able to do just about anything but watch YouTube videos... so this a the solution I came up with for that. I am sure this can be done better but this does indeed work... and tends to work far better than YouTube's ghetto proprietary flash player ;-) Replace $i with any YouTube ID you want and this will scrape the site for the _real_ URL to the full quality .FLV file on Youtube's server and will then will hand that over to mplayer (or vlc or whatever you want) to be streamed. In some browsers you can replace $i with just a % or put this in a shell script so all YouTube IDs can be handed directly off to your media player of choice for true streaming without the need for Flash or a downloader like clive. (I do however fully recommend clive if you wish to archive videos instead of streaming them) If any interest is shown I would be more than happy to provide similar commands for other sites. Most streaming flash players use similar logic to YouTube. Edit: 05/03/2011 - Updated line to work with current YouTube. It could be a lot prettier but I will probably follow up with another update when I figure out how to get rid of that pesky Grep. Sed should take that syntax... but it doesn't. Original (no longer working) command: mplayer -fs $(echo "http://youtube.com/get_video.php?$(curl -s $youtube_url | sed -n "/watch_fullscreen/s;.*\(video_id.\+\)&title.*;\1;p")") Show Sample Output


    58
    i="8uyxVmdaJ-w";mplayer -fs $(curl -s "http://www.youtube.com/get_video_info?&video_id=$i" | echo -e $(sed 's/%/\\x/g;s/.*\(v[0-9]\.lscache.*\)/http:\/\/\1/g') | grep -oP '^[^|,]*')
    lrvick · 2009-03-09 03:57:44 53
  • This command lets you see and scroll through all of the strings that are stored in the RAM at any given time. Press space bar to scroll through to see more pages (or use the arrow keys etc). Sometimes if you don't save that file that you were working on or want to get back something you closed it can be found floating around in here! The awk command only shows lines that are longer than 20 characters (to avoid seeing lots of junk that probably isn't "human readable"). If you want to dump the whole thing to a file replace the final '| less' with '> memorydump'. This is great for searching through many times (and with the added bonus that it doesn't overwrite any memory...). Here's a neat example to show up conversations that were had in pidgin (will probably work after it has been closed)... sudo cat /proc/kcore | strings | grep '([0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\})' (depending on sudo settings it might be best to run sudo su first to get to a # prompt)


    15
    sudo cat /proc/kcore | strings | awk 'length > 20' | less
    nesquick · 2009-03-09 02:19:47 19
  • only for sudo-style systems. Use this construct instead of I/O re-directors ``>'' or ``>>'' because sudo only elevates the commands and *not* the re-directors. ***warning: remember that the `tee` command will clobber file contents unless it is given the ``-a'' argument Also, for extra security, the "left" command is still run unprivileged. Show Sample Output


    4
    echo "Whatever you need" | sudo tee [-a] /etc/system-file.cfg
    asmoore82 · 2009-03-09 01:33:31 7
  • using `cat` under *NIX - just because you help manage M$ Windoze *doesn't* mean you should have to resort to using it! You can also make custom win32 installers with the 7zip "extras" package: cat /path/to/7zSD.sfx /path/to/config.txt /path/to/archive > setup.exe


    4
    cat /path/to/7z.sfx /path/to/archive > archive.exe
    asmoore82 · 2009-03-09 00:54:33 7

  • 5
    export PS1="${PS1%\\\$*}"' \t \$ '
    asmoore82 · 2009-03-09 00:34:08 7
  • [re]verify those burned CD's early and often - better safe than sorry - at a bare minimum you need the good old `dd` and `md5sum` commands, but why not throw in a super "user-friendly" progress gauge with the `pv` command - adjust the ``-s'' "size" argument to your needs - 700 MB in this case, and capture that checksum in a "test.md5" file with `tee` - just in-case for near-future reference. *uber-bonus* ability - positively identify those unlabeled mystery discs - for extra credit, what disc was used for this sample output? Show Sample Output


    10
    dd if=/dev/cdrom | pv -s 700m | md5sum | tee test.md5
    asmoore82 · 2009-03-09 00:11:42 13

  • 0
    find . -iname "*wav" > step1 ; sed -e 's/\(^.*\)wav/\"\1wav\" \"\1mp3\"/' step1 > step2 ; sed -e 's/^/lame /' step2 > step3 ; chmod +x step3 ; ./step3
    bigbrovar · 2009-03-08 17:22:38 5
  • simple find and exec example


    -4
    find -name ".svn" -exec rm -rf {} \;
    ugiflezet · 2009-03-08 15:53:24 6

  • 4
    cd !$
    web_mogul · 2009-03-08 14:57:27 8
  • Many like to use 'dd' for creating CD/DVD iso images. This is bad. Very bad. The reason this is, is 'dd' doesn't have any built-in error checking. So, you don't know if you got all the bits or not. As such, it is not the right tool for the job. Instead, 'reaom' (read optical media) from the wodim package is what you should be using. It has built-in error checking. Similarly, if you want to burn your newly creating ISO, stay away from 'dd', and use: wodim -v -eject /path/to/image.iso


    59
    readom dev=/dev/scd0 f=/path/to/image.iso
    atoponce · 2009-03-08 13:21:23 23
  • This command will delete files i a given path (/dir_name) , which older than given time in days (-mtime +5 will delete files older than five days.


    5
    find /dir_name -mtime +5 -exec rm {} \
    eleffie · 2009-03-08 12:03:44 10
  • This command will display all lines between 2 patterns: word-a and word-b useful for grepping command outputs from file


    3
    perl -0777 -ne 'print "$1\n" while /word-a(.*?)word-b/gs' filename.txt
    eleffie · 2009-03-08 11:47:18 7
  • ‹ First  < 522 523 524 525 526 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Kill google chrome process

Get absolut path to your bash-script

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

find large files

Merge PDFs into single file

Prepend a text to a file.
The original command is great, but I often want to prepend to every line.

Wait for file to stop changing
This loop will finish if a file hasn't changed in the last 10 seconds. . It checks the file's modification timestamp against the clock. If 10 seconds have elapsed without any change to the file, then the loop ends. . This script will give a false positive if there's a 10 second delay between updates, e.g. due to network congestion . How does it work? 'date +%s' gives the current time in seconds 'stat -c %Y' gives the file's last modification time in seconds '$(( ))' is bash's way of doing maths '[ X -lt 10 ]' tests the result is Less Than 10 otherwise sleep for 1 second and repeat . Note: Clever as this script is, inotify is smarter.

Set a Reminder for yourself via the notification system
This will be seen through your system's visual notification system, notify-osd, notification-daemon, etc. --- sleep accepts s,m,h,d and floats (date; sleep .25m; date) --- notify-send (-t is in milliseconds && -u low / normal / critical) man notify-send for more information --- notification-daemon can use b/i/u/a HTML

retrieve the source address used to contact a given host
on multihomed hosts, connected to several networks, could be usefull to know the source address (local ip address) used to reach the target host, this command does not require root priviledges. The command use a TCP socket, if there is any error the command return an empty string, elsewhere return a valid ip address.

Router discovery


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: