All commands (14,187)


  • -4
    tar -C <source_dir> -cf . | tar -C <dest_dir> -xf
    Tekhne · 2009-07-08 22:19:04 6

  • -4
    :!>test.txt
    amaymon · 2009-08-19 13:45:23 4
  • It will return the absolute location of the called a script. If is in $PATH, it will search it using which. You can combine this function with this other one: http://www.commandlinefu.com/commands/view/9252/readlink-equivalent-using-shell-commands-and-following-all-links, to get a way to know where is the real location of a called script: # Returns the realpath of a called command. whereis_realpath() { local SCRIPT_PATH=$(whereis $1); myreadlink ${SCRIPT_PATH} | sed "s|^\([^/].*\)\$|$(dirname ${SCRIPT_PATH})/\1|"; } Show Sample Output


    -4
    get_absolute_path() { echo $1 | sed "s|^\([^/].*/.*\)|$(pwd)/\1|;s|^\([^/]*\)$|$(which -- $1)|;s|^$|$1|"; }
    keymon · 2011-09-13 11:06:55 6

  • -4
    ip a
    huazhihao · 2012-09-20 01:44:58 5

  • -4
    perl -e 'print crypt("PASSWORD",int(rand(128))).$/;'
    cicatriz · 2010-09-30 12:58:39 3
  • This command might not be useful for most of us, I just wanted to share it to show power of command line. Download simple text version of novel David Copperfield from Poject Gutenberg and then generate a single column of words after which occurences of each word is counted by sort | uniq -c combination. This command removes numbers and single characters from count. I'm sure you can write a shorter version. Show Sample Output


    -4
    wget -q -O- http://www.gutenberg.org/dirs/etext96/cprfd10.txt | sed '1,419d' | tr "\n" " " | tr " " "\n" | perl -lpe 's/\W//g;$_=lc($_)' | grep "^[a-z]" | awk 'length > 1' | sort | uniq -c | awk '{print $2"\t"$1}'
    alperyilmaz · 2009-05-04 16:00:39 11
  • It extracts X number of lines from file1 and dumps them to file2.Using grep with the empty string '' extracts the complete lines (i.e. no filtering takes place) and the -m flag indicates how many lines to extract out from the given file. Then using the redirect > operator we send the extracted lines to a new file.


    -4
    grep '' -m X file1 > file2
    sardanapalos · 2009-03-22 04:34:43 17
  • See smbstatus Output within a 5 second interval (for monitoring smb access)


    -4
    while (( $i != 0 )) { smbstatus; sleep 5; clear }
    unixmonkey4084 · 2009-06-03 13:26:30 9
  • After a command is run in bash, !$ is set to the last (space-delimited) argument of the command. Great for running several commands against the same file in a row.


    -4
    svn status app/models/foo.rb; svn commit -m "Changed file" !$
    ggoodale · 2009-03-22 23:14:06 5

  • -4
    sh default values
    rootgeek · 2010-03-26 02:36:57 4
  • # define user pid to kill PID=httpd ; # kill all pids ps aux | grep $PID | grep -v grep | awk '{print $2}' | xargs kill -9 Show Sample Output


    -4
    PID=httpd ; ps aux | grep $PID | grep -v grep | awk '{print $2}' | xargs kill -9
    esaenz · 2012-02-21 23:27:47 6
  • I use these command to validate twitter accounts, we can use a "for a in $(cat list.txt)" to validate a complete list of twitter accounts.


    -4
    if lynx --dump http://twitter.com/xmuda | grep -q "Sorry, that page does"; then echo "Dont Exist"; else echo "Exist"; fi
    xmuda · 2013-03-23 16:12:24 4
  • The sample output, is the command with a ?, to show you all the stuff you can look at. Show Sample Output


    -4
    dm ?
    rootgeek · 2010-03-26 02:42:21 3

  • -4
    Place a filename at the beginning of the line to make it easier to edit the search at the end of the command.
    iveney · 2009-02-07 12:03:19 12

  • -4
    alias w3m='w3m -cookie'
    freestyler · 2009-07-09 09:01:55 4
  • This command marks it as "dirty" NTFS partition, forcing Windows to do the scandisk during boot. It is convenient if you work hard to NTFS partitions under Linux


    -4
    ntfsfix /dev/hda1
    0disse0 · 2011-07-02 17:49:48 3
  • changes the PS1 to something better than default. [username.hostname.last-2-digits-of-ip] (current directory) Show Sample Output


    -4
    newhostname=$(hostname | awk -F. '{print $1 "." $2}'); ipaddress=$(nslookup `hostname` | grep -i address | awk -F" " '{print $2}' | awk -F. '{print $3 "." $4}' | grep -v 64.142);PS1="[`id -un`.$newhostname.$ipaddress]"' (${PWD}): '; export PS1
    simardd · 2009-02-16 20:11:53 8
  • I have come across multiple situations where I could only get to a server from a very restrictive bounce point which would not allow file transfers. I was able to uuencode a file, copy the output to a text file over putty, and then uudecode the file to transfer it. This works with any kind of file. Show Sample Output


    -4
    uuencode -m <filename> <filename>
    leprasmurf · 2009-12-22 15:28:59 3

  • -4
    grep --exclude-dir=.svn --exclude=*~ -i "TODO" -rl .
    saibbot · 2011-04-06 20:25:41 5
  • deletes first 55 lines; change the 55 to whatever number


    -4
    sed '1,55d'
    grep · 2009-02-16 20:36:25 8
  • On Linux and Mac systems (I have not tested with other Unix systems), the ping command will keep on pinging until the user interrupts it with Ctrl+C. On Windows system, ping will execute for a number of times then quit. The -c flag on Linux and Mac will make this happen


    -4
    ping -c 10 hostname
    haivu · 2009-03-04 06:14:52 6
  • This is based on the Windows Version of VirtualBox. From the /? ... VBoxManage clonehd | [--format VDI|VMDK|VHD|RAW|] [--variant Standard,Fixed,Split2G,Stream,ESX] [--type normal|writethrough|immutable|shareable] [--remember] [--existing] From the online help.. http://www.virtualbox.org/manual/ch08.html#id2676537 VBoxManage clonehd This command duplicates a registered virtual hard disk image to a new image file with a new unique identifier (UUID). The new image can be transferred to another host system or imported into VirtualBox again using the Virtual Media Manager; see the section called ?The Virtual Media Manager? and the section called ?Cloning disk images?. The syntax is as follows: VBoxManage clonehd | [--format VDI|VMDK|VHD|RAW|] [--variant Standard,Fixed,Split2G,Stream,ESX] [--type normal|writethrough|immutable] [--remember] where the parameters mean: format Allow to choose a file format for the output file different from the file format of the input file. variant Allow to choose a file format variant for the output file. It is a comma-separated list of variant flags. Not all combinations are supported, and specifying inconsistent flags will result in an error message. type Only honored if --remember is also specified. Defines what kind of hard disk type this image should be. remember Keep the destination image registered after it was successfully written. Show Sample Output


    -4
    vboxmanage clonehd --format VMDK <source image|uuid> <destination image>
    dreffed · 2010-10-04 16:42:12 3

  • -4
    find . -name \*.pyc -delete
    zluyuer · 2016-09-07 01:49:59 17
  • Easy way to find out what Debian version your machine is running Show Sample Output


    -4
    cat /etc/debian_version
    caiosba · 2009-08-05 14:47:05 5
  • netstat has two lines of headers: Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State Added a filter in the awk command to remove them


    -4
    netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
    letterj · 2011-07-04 20:23:21 8
  • ‹ First  < 539 540 541 542 543 >  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

Change/Modify timestamp

Rename files in batch

List your installed Chromium extensions (with url to each page)
Gives you a list for all installed chrome (chromium) extensions with URL to the page of the extension. With this you can easy add a new Bookmark folder called "extensions" add every URL to that folder, so it will be synced and you can access the names from every computer you are logged in. ------------------------------------------------------------------------------------------------------------------ Only tested with chromium, for chrome you maybe have to change the find $PATH.

no # comments, blank lines, white space. # can start in any column
The shortest and most complete comment/blank line remover... Any line where the first non-whitespace character is # (ie, indented # comments), and all null and blank lines are removed. Use the alias as a filter: $ noc /etc/hosts or $ grep server /etc/hosts | noc Change to nawk depending awk versions.

find and reduce 8x parallel the size of JPG images without loosing quality via jpegoptim

Sort dotted quads
Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}

convert .bin / .cue into .iso image
bchunk [-v] [-p] [-r] [-w] [-s]

Multiplication table
The multiplication table for math study

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"

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }


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: