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

memory usage

Transfer Entire recursive from one host to another. Only copies files that are newer or do not exist
From opposite host To copy remote to local rsync -aE -e "ssh -pPortnumber" user@hostA:directory target_dir

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Key binding to search commandlinefu.com
This is a simple bash function and a key binding that uses commandlinefu's simple and easy search API. It prompts for a search term, then it uses curl to search commandline fu, and highlights the search results with less.

mplayer webcam window for screencasts
When recording screencast some people like to have the image from their webcam, so the can show something, that can't be seen on the desktop. So starting mplayer with these parameters you will have a window with no frames, borders whatsoever, and selecting the window a hitting the "F" key you will bring it in fullscreen. if you want to position the frame somewhere else, you could play with the --geomeptry option where 100%:100% mean bottom right corner. The HEIGHT and WIDTH can't be changed as you like, since the most webcams support specified dimensions, so you would have to play with it to see what is supported

Find out how old a web page is
I used to use the Firefox "View page info" feature a lot to determine how stale the web page I was looking at was. Now that I use mostly Chrome I miss that feature, so here is a command line alternative using wget. The -S says to display the server response, the --spider says to not download any files/pages, just fetch the header. The output goes to stderr, so to grep it you use 2>&1 to combine the stderr stream with stdout, the pipe that to grep for Last-Modified. You can use curl instead if you have it installed, like this: $ curl --head -s http://osswin.sourceforge.net | grep Mod

Delete a file/directory walking subdirectories (bash4 or zsh)

ps with parent/child process tree
Shows a tree view of parent to child processes in the output of ps (linux). Similar output can be achieved with pstree (also linux) or ptree (Solaris).

Manipulate the metadata when the photo was taken, this will shift with +15hours + 30min

Fix borked character coding in a tty.
Often you find some tty programs are messed up and confused about character encoding - 'man' is a common problem and sometimes displays weird characters for apostrophes, hyphens etc etc. Another class of programs that suffer from this are those that try to use the line drawing characters - eg RedHat's tty system admin functions such as system-config-firewall-tui system-config-network-tui etc. Adding 'LC_ALL=C' fixes most of these problems (as long as you want English! Perhaps speakers of other languages can add a comment here). For bonus points, I've added the '-c' option to the man command so that it ignores it's cache and re-computes the man page using the C locale.


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: