All commands (14,187)


  • -2
    find ./ -name $1 -exec grep -H -n $2 '{}' ';'
    packetloss · 2009-11-24 07:25:27 4

  • -2
    xfwm4 --replace
    Bonster · 2012-04-03 14:05:09 3
  • Finds files modified today since 00:00, removes ugly dotslash characters in front of every filename, and sorts them. *EDITED* with the advices coming from flatcap (thanks!)


    -2
    find -maxdepth 1 -type f -newermt "00:00" -printf "%f\n" | sort
    TetsuyO · 2013-03-23 12:50:01 8
  • If the 'lm' flag is present, then the CPU is 64-bit. If no output, then CPU is 32-bit. Show Sample Output


    -2
    grep lm /proc/cpuinfo
    bobbydale · 2009-02-19 22:48:47 6
  • Sometimes I need a quick visual way to determine if there is a particular server who is opening too many connections to the database machine.


    -2
    netstat | grep EST | awk '{print $5}' | sort
    unixoid · 2009-11-24 13:38:28 4
  • The sample output, is a display of the values you can change, using this command. After a change of of these settings you will need to reload the box, by typing...wait...wait for IT: 'reload'. This comes in handy when working with the RX hardware, for example, which has a base limitation of 32 (RSTP (802-1w) instances. For all of you paying attention that means if you run RSTP on a RX you can only have 32 VLANs. Sure, you can have common groups of VLANs, like back in the day style MSTP, PVST, PVST+ (and all that old STP (802.1d) mess), before "per vlan spanning-tree", RSTP (802-1w), was made. But who wants to do all that? Show Sample Output


    -2
    system max <some value>
    rootgeek · 2010-03-26 02:39:00 5
  • # put into .bashrc function trash() { if [ -z "$*" ] ; then echo "Usage: trash filename" else local TRASH="${HOME}/.local/share/Trash" if [ ! -d "$TRASH/files" ]; then mkdir -p "$TRASH/files"; fi if [ ! -d "$TRASH/info" ]; then mkdir -p "$TRASH/info"; fi local IFS_BKP=$IFS IFS=' ' for FILE in $@ ; do local BASE=$( basename "$FILE" ) local TRASH_NAME="$BASE" local COUNTER=1 while [ -e "$TRASH/files/$TRASH_NAME" ]; do COUNTER=`expr $COUNTER + 1` TRASH_NAME="$BASE.$COUNTER" done local FULL_PATH=$( readlink -f "$FILE" ) local DATE=$( date +%Y-%m-%dT%H:%M:%S ) mv "$FULL_PATH" "$TRASH/files/$TRASH_NAME" if [ $? -eq 0 ]; then echo "[Trash Info] Path=$FULL_PATH DeletionDate=$DATE" > "$TRASH/info/$TRASH_NAME.trashinfo" fi done IFS=$IFS_BKP fi }


    -2
    trash <file>
    bkmeneguello · 2012-11-22 18:05:11 4

  • -2
    stat -f '%Su' /dev/console
    thealanberman · 2016-01-13 20:53:13 10
  • Forward connections to $HOSTNAME:8080 out to $HOST:80


    -2
    ssh -g -L 8080:localhost:80 root@$HOST
    kayowas · 2009-10-24 20:56:00 3
  • Original submitted version would break if any filenames had whitespaces in them. The command is a Bad Idea anyhow, because you will end up `cat`ing a binary or something else specacularly bad.


    -2
    for file in ./*; do cat "$file"; sleep 0.3
    DopeGhoti · 2011-11-28 20:10:57 3

  • -2
    ls | while read line; do ln -s "$(pwd)/$line" "/usr/bin/$line"; done
    rawm · 2015-03-24 06:47:56 10
  • PmWiki stores wiki pages as Group.Name. Simply split the directory listing and count frequency of group occurances. Show Sample Output


    -2
    cd /path/to/pmwiki/wiki.d;/bin/ls -1 | perl -ne 'my ($group,$name)=split(/\./);$counts{$group}++;' -e 'END { foreach $group (sort keys %counts) {printf("%d\t%s\n",$counts{$group},$group);} }'|sort -rn
    tamouse · 2011-09-14 19:33:39 4
  • Show the maximum settings in effect for PHP at the command line. Show Sample Output


    -2
    php -i|grep -i max
    rjamestaylor · 2009-02-20 03:29:11 6
  • Recursively remove .svn directories from the current location.


    -2
    rm -rf `find . -name .svn`
    jfcalvo · 2010-02-23 08:35:06 5

  • -2
    wget http://www.whatismyip.org --quiet -O - | cat
    wr8cr8 · 2010-07-30 08:40:16 13
  • With this command you can resize an NTFS partition by specifying the new size (X) in Kbytes, Mbytes or Gbytes. If you plan to do this it is advisable to precede --no-action parameter to size see more: http://ubuntuforums.org/showthread.php?t=1244058 and http://en.wikipedia.org/wiki/Ntfsresize


    -2
    ntfsresize --size X[k,M.G] /dev/hda1
    0disse0 · 2011-07-02 17:47:05 3
  • Dump 389ds schema, putting "\n " on one line with perl. You have to specify the objectclasses, attributetypes operational attributes too, otherwise they won't be dumped!


    -2
    ldapsearch -xLLL -b "cn=schema" "(objectclass=*)" \ \* objectclasses attributetypes | perl -p0e 's/\n //g'
    ioggstream · 2012-04-04 13:31:31 4
  • For quick validation of folder's file-contents (structure not taken into account) - I use it mostly to check if two folders' contents are the same. Show Sample Output


    -2
    find path/to/folder/ -type f -print0 | xargs -0 -n 1 md5sum | awk '{print $1}' | sort | md5sum | awk '{print $1}'
    mcover · 2009-02-16 19:39:37 10

  • -2
    7za x \*.zip
    andrew112358 · 2010-01-25 21:50:15 2

  • -2
    nmap -sS -O -v -oS - 192.168.2.0/24
    ene2002 · 2014-01-31 18:04:06 135
  • -F, use , as field separator gsub() deletes all spaces for(){} loops over all input fields and print their index and value exit exit after first line Show Sample Output


    -2
    awk -F, '{gsub(/ /,"");for(f=1;f<=NF;f++) print f,$f;exit}' file.csv
    sesom42 · 2015-08-26 09:30:43 11

  • -2
    free && sync && echo 3 > /proc/sys/vm/drop_caches && free
    ironmarc · 2016-11-02 08:51:01 22

  • -2
    mysqlslap  --query=/root/select_query_cp.sql --concurrency=10 --iterations=5  --create-schema=cvts1
    shantanuo · 2020-02-15 10:40:39 79
  • An alias i made for myself to play music in a faster way. Works great when you have Guake / Tilda installed (Console that drops down like in the game QUAKE) --- I put this in my bash_alias file (I'm on ubuntu, the bash_alias file does autostart with the right config) but it works putting it in bashrc too. Or anything that autostarts when the console is opened. --- Needs Mplayer and music files to work. With out music theres nothing to play! Oh, and also, without modification, this alias will try to play stuff from your ~/Music folder! (case sensitive). Make sure that folder exists and has music OR edit this alias to fit your needs. Show Sample Output


    -2
    alias mux='clear && cd ~/Music/ && ls && echo -n "File> " && read msi && mplayer ~/Music/$msi'
    Noxn · 2009-03-23 10:45:27 15

  • -2
    sed 's/$'"/`echo \\\r`/"
    fooMan · 2009-02-16 20:07:08 11
  • ‹ First  < 505 506 507 508 509 >  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

most used commands in history (comprehensive)
Most of the "most used commands" approaches does not consider pipes and other complexities. This approach considers pipes, process substitution by backticks or $() and multiple commands separated by ; Perl regular expression breaks up each line using | or < ( or ; or ` or $( and picks the first word (excluding "do" in case of for loops) note: if you are using lots of perl one-liners, the perl commands will be counted as well in this approach, since semicolon is used as a separator

check open ports without netstat or lsof

Move a folder and merge it with another folder
This will move a folder and merge it with another folder which may contain duplicates. Technically it's just creating hardlinks of everything in the folder, and after it's done, delete the source (with rm -r source/ ) to complete the move. This is much faster than, for example, using rsync to merge folders which would actually copy the entire contents and so for a lot of files would take much longer. This uses macutils gcp port of cp so it can be used on osx/MacOS. If using in linux or some unix where cp includes the ability to create links with -l you can just use cp instead of gcp.

download a list of urls

Find the package that installed a command

Generate a random password 30 characters long

Generate a random left-hand password
Generates a random 8-character password that can be typed using only the left hand on a QWERTY keyboard. Useful to avoid taking your hand off of the mouse, especially if your username is left-handed. Change the 8 to your length of choice, add or remove characters from the list based on your preferences or kezboard layout, etc.

vi a new file with execution mode
$ vix /tmp/script.sh Open a file directly with execution permission. Put the function in your .bashrc You can also put this in your vimrc: $ command XX w | set ar | silent exe "!chmod +x %" | redraw! and open a new file like this: $ vi +XX /tmp/script.sh

Extract tarball from internet without local saving

Swap a file or dir with quick resotre
This lets you replace a file or directory and quickly revert if something goes wrong. For example, the current version of a website's files are in public_html. Put a new version of the site in public_html~ and execute the command. The names are swapped. If anything goes wrong, execute it again (up arrow or !!).


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: