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 144
  • -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 23

  • -2
    mysqlslap  --query=/root/select_query_cp.sql --concurrency=10 --iterations=5  --create-schema=cvts1
    shantanuo · 2020-02-15 10:40:39 83
  • 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 16

  • -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

Transfer SSH public key to another machine in one step
This command sequence allows simple setup of (gasp!) password-less SSH logins. Be careful, as if you already have an SSH keypair in your ~/.ssh directory on the local machine, there is a possibility ssh-keygen may overwrite them. ssh-copy-id copies the public key to the remote host and appends it to the remote account's ~/.ssh/authorized_keys file. When trying ssh, if you used no passphrase for your key, the remote shell appears soon after invoking ssh user@host.

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Read aloud a text file in Mac OS X

Get Hardware UUID in Mac OS X
Formats the output from `ioreg` into XML, then parses the XML with `xmllint`'s xpath feature.

Tracklist reaplace backspace to '-'
Requires perl 5.14 or greater

Download all PDFs from an authenificated website
Replace *** with the appropiate values

Multi-thread any command
For instance: $ find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8 will encode all .wav files into FLAC in parallel. Explanation of xargs flags: -P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage]. -n [max-args]: Max number of arguments from the list to send to each invocation. -0: Stdin is a null-terminated list. I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa

disable caps lock
a quick one-line way to disable caps lock while running X.

Image to color palette generator
Extract a color palette from a image useful for designers. Example usage: $extract-palette myawesomeimage.jpg 4 Where the first argument is the image you want to extract a palette from. The second argument is the number of colors you want. It may be the case where you want to change the search space. In that case, change the -resize argument to a bigger or smaller result. See the ImageMagick documentation for the -resize argument.

Setting reserved blocks percentage to 1%
According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition. http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/


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: