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

Renaming a file without overwiting an existing file name
Sometimes in a hurry you may move or copy a file using an already existent file name. If you aliased the cp and mv command with the -i option you are prompted for a confirmation before overwriting but if your aliases aren't there you will loose the target file! The -b option will force the mv command to check if the destination file already exists and if it is already there a backup copy with an ending ~ is created.

Extract the MBR ID of a device
Useful when you want to know the mbrid of a device - for the purpose of making it bootable. Certain hybridiso distros, for eg the OpenSUSE live ISO uses the mbrid to find the live media. Use this command to find out the mbrid of your USB drive and then edit the /grub/mbrid file to match it.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Find files that were modified by a given command
Traces the system calls of a program. See http://linuxhelp.blogspot.com/2006/05/strace-very-powerful-troubleshooting.html for more information.

Check wireless link quality with dialog box
The variable WIRELESSINTERFACE indicates your wireless interface

Quick screenshot
Requires ImageMagick. Takes a screenshot 5 seconds after it's run and saves it as desktop_screenshot.jpg Particularly handy when made into a menu option or button.

Find usb device
I often use it to find recently added ou removed device, or using find in /dev, or anything similar. Just run the command, plug the device, and wait to see him and only him

vim multiple files at one time, split vertically.

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Convert all WMF images to SVG recursively ignoring file extension case
This assumes you have the package installed necessary for converting WMF files. On my Ubuntu box, this is libwmf-bin. I used this command, as libwmf is not on my wife's iMac, so I archived the directories containing the WMF files from OS X, ran them on my Ubuntu box, archived the resulting SVGs, and sent them back to her. Quick, simple and to the point. Searches directories recursively looking for extensions ignoring case. This is much more readable and clean than -exec for find. The while loop also gives further flexibility on complex logic. Also, although there is 'wmf2svg --auto', it expects lowercase extensions, and not uppercase. Because I want to ignore case, I need to use the -o option instead. Works in ZSH and BASH. Haven't tested in other shells.


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: