All commands (14,184)


  • 4
    for file in `find . -type f`; do cat $file; done | wc -l
    tejparkash · 2009-03-18 06:50:10 17
  • Thanks to OpenSSL, you can quickly and easily generate MD5 hashes for your passwords. Alternative (thanks to linuxrawkstar and atoponce): echo -n 'text to be encrypted' | md5sum - Note that the above method does not utlise OpenSSL. Show Sample Output


    18
    echo -n 'text to be encrypted' | openssl md5
    Zenexer · 2009-03-18 00:11:46 12
  • A simple but effective replacement for ps aux. I used to waste my time running ps over and over; top is the way to go. It also allows complex sorting options. Press q to exit "nicely" (Ctrl + C is always an option, of course). Note that the list updates each second, resorting in the process; if you're trying to grab a specific PID, you might be better off with ps. htop Alternatively, htop is available, though it may not come pre-installed. htop is slightly more interactive than top and includes color coding, visuals, and a nice interface for selecting and then killing processes. (Thanks to bwoodacre for this great tool.) Show Sample Output


    -5
    top
    Zenexer · 2009-03-18 00:03:42 10
  • You're running a script, command, whatever.. You don't expect it to take long, now 5pm has rolled around and you're ready to go home... Wait, it's still running... You forgot to nohup it before running it... Suspend it, send it to the background, then disown it... The ouput wont go anywhere, but at least the command will still run... Show Sample Output


    53
    ^Z $bg $disown
    fall0ut · 2009-03-17 21:52:52 27
  • Ever had a file with a list of numbers you wanted to add, use: cat file | sed ':a;N;$!ba;s/\n/+/g' | bc


    0
    sed ':a;N;$!ba;s/\n/ /g'
    cidiom · 2009-03-17 20:54:04 20
  • This will send a test print job to a networked printer.


    1
    echo "test" | lp -d $PRINTER
    nauseaboy · 2009-03-17 20:07:41 16
  • This command shows if there are any locked AFS volumes. The output is a list of AFS volume IDs (or nothing if there are none locked). Show Sample Output


    0
    vos listvldb | agrep LOCKED -d RWrite | grep RWrite: | awk -F: '{print $2}' | awk '{printf("%s ",$1)} END {printf("\n")}'
    mpb · 2009-03-17 19:55:39 7
  • Show the webcam output with mplayer.


    9
    mplayer tv:// -tv driver=v4l:width=352:height=288
    Robertof · 2009-03-17 19:37:23 8

  • -2
    startx > startx.log 2>&1
    ed · 2009-03-17 19:08:47 8
  • Change bash autocomplete case search to insensitive when pressing tab for completion.


    3
    shopt -s nocaseglob
    josx · 2009-03-17 17:51:42 7

  • 6
    shopt -s cdspell
    josx · 2009-03-17 17:49:44 4
  • Substitute spaces in filename with underscore, it work on the first space encountered.


    4
    ls -1 | rename 's/\ /_/'
    servermanaged · 2009-03-17 17:33:41 7

  • 2
    for i in `find /sys/devices/*/*/usb* -name level` ; do echo -n "$i: " ; cat $i ; done
    path · 2009-03-17 16:22:15 6
  • Find out which RPMs were installed on a particular date. These would (naturally) include update RPMs. This example shows searching for "Thu 05 Mar" (with grep). Alternatively, pipe it to less so you can search inside less (with less's neat text highlighting of the search term): rpm -qa --queryformat '%{installtime} \"%{vendor}\" %{name}-%{version}-%{release} %{installtime:date}\n' | less # (this example) search term: Thu 05 Mar Show Sample Output


    4
    rpm -qa --queryformat '%{installtime} \"%{vendor}\" %{name}-%{version}-%{release} %{installtime:date}\n' | grep "Thu 05 Mar"
    mpb · 2009-03-17 13:38:20 12
  • "play" is part of "SoX" SoX - Sound eXchange, the Swiss Army knife of audio manipulation. For details, see: man sox Show Sample Output


    -3
    play $audio_file
    mpb · 2009-03-17 11:30:02 14
  • Create backup (.tar.gz) for all first-level directory from current dir. Show Sample Output


    3
    find -maxdepth 1 -type d -print0 | xargs -0 -I {} tar -cvzf {}.tar.gz {}
    piemme · 2009-03-17 11:12:53 7
  • This command will tell lynx to read keystrokes from the specified file - which can be used in a cronjob to auto-login on websites that give you points for logging in once a day *cough cough* (which is why I used -accept_all_cookies). For creating your keystroke file, use: lynx -cmd_log yourfile


    26
    lynx -accept_all_cookies -cmd_script=/your/keystroke-file
    Alanceil · 2009-03-17 00:38:36 13
  • At the start of a vi session and *before* saving any changes use ":!cp % %-" to make a backup of the current file being edited. example: vi /data/some/long/path/file :!cp% %- creates /data/some/long/path/file-


    5
    :!cp % %-
    mpb · 2009-03-17 00:34:24 18
  • #

    Using the "#" in shell is surprisingly useful. Some of the uses I found: a) As a visible copy buffer in shell history (caveat: do not use for passwords :-) b) To build complex commands until ready then hit the HOME, DEL, ENTER keys to run it c) Placing reference data into shell history (search for tags with CTRL-R TAGNAME) d) Putting aside a "work in progress" command to focus on another task (HOME # ENTER) Show Sample Output


    -4
    # indicates a comment in shell
    mpb · 2009-03-16 23:15:33 11
  • Hold ctrl and press z to pause the current thread. Run fg to resume it.


    11
    ctrl-z
    mallegonian · 2009-03-16 20:58:31 23
  • Add calendar to desktop wallpaper , mess with the coordinates to place where you like


    15
    convert -font -misc-fixed-*-*-*-*-*-*-*-*-*-*-*-* -fill black -draw "text 270,260 \" `cal` \"" testpic.jpg newtestpic.jpg
    dasmna · 2009-03-16 16:09:58 16

  • 9
    alias lvim="vim -c \"normal '0\""
    lowkey · 2009-03-16 15:41:00 9
  • ./* is for copying files starting with - .[!.]* is for copying hidden files and avoiding copying files from the parent directory. ..?* is for copying files starting with .. (avoids the directory ..) /path/to/dir the path to the directory where the files should be copied Can also be used as a script. Input argument is /path/to/dir in tcsh, replace .[!.]* with .[^.]*


    1
    cp ./* .[!.]* ..?* /path/to/dir
    ako · 2009-03-16 13:27:36 16
  • With: -vcodec, you choose what video codec the new file should be encoded with. Run ffmpeg -formats E to list all available video and audio encoders and file formats. copy, you choose the video encoder that just copies the file. -acodec, you choose what audio codec the new file should be encoded with. copy, you choose the audio encoder that just copies the file. -i originalfile, you provide the filename of the original file to ffmpeg -ss 00:01:30, you choose the starting time on the original file in this case 1 min and 30 seconds into the film -t 0:0:20, you choose the length of the new film newfile, you choose the name of the file created. Here is more information of how to use ffmpeg: http://www.ffmpeg.org/ffmpeg-doc.html


    22
    ffmpeg -vcodec copy -acodec copy -i orginalfile -ss 00:01:30 -t 0:0:20 newfile
    ako · 2009-03-16 12:58:07 14
  • This command is a powerful "detoxifier" that eliminates special chars, spaces and all those little chars we don't like. It support several "sequences" so be sure to check your /usr/local/etc/detoxrc while at it... and maybe define your own Show Sample Output


    16
    detox -r -s utf_8 /path/to/old/win/files/dir
    renich · 2009-03-16 07:50:36 15
  • ‹ First  < 518 519 520 521 522 >  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

A command to copy mysql tables from a remote host to current host via ssh.
In the example above 3 tables are copied. You can change the number of tables. You should be able to come up with variants of the command by modifying the mysqldump part easily, to copy some part of remote mysql DB.

recursive search and replace old with new string, inside files
Search and replace recursively. :-) Shorter and simpler than the others. And allows more terms: replace old new [old new ...] -- `find -type f`

Install pip with Proxy
Installs pip packages defining a proxy

how many packages installed on your archlinux?

check web server port 80 response header

Display any tcp connections to apache
Sometimes apache will get stuck in an established state where you can't get a list of the connecting IP's from mod_status... not a good thing when you need to ban an abusive ip.

Block all IP addresses and domains that have attempted brute force SSH login to computer
Searches all log files (including archived bzip2 files) for invalid user and PAM authentication errors, both of which are indicative of brute force attempts at logging into computer. A list of all unique IP addresses and domain names is appended to hosts.deny. The command (and grep error messages) will work on Mac OS X 10.6, small adjustments may be needed for other OSs.

Expand shortened URLs
This relies on a public API from http://longurl.org. So, this has the weakness that if the service disappears, the function will break. However, it has the advantage that the shortened URL service will not be tracking your IP address and other metrics, but instead will track longurl.org. Thus, you can remain anonymous from the shortened URL services (although not anonymous from longurl.org). It does no sanity checking that you have provided an argument. If you do not provide one, "message" is displayed to STDOUT.

ignore .DS_Store forever in GIT
With a couple of little commands, you?ll be able to ignore the .DS_Store files forever from your git repositories on mac! The following command will add the .gitignore file to the git configuration git config --global core.excludesfile ~/.gitignore then, the following, will add the .DS_Store to the list echo .DS_Store >> ~/.gitignore

What is my ip?


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: