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

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Perl One Liner to Generate a Random IP Address

Create thumbnails and a HTML page for listing them (with links to sources)
The input images are assume to have the "JPG" extension. Mogrify will overwrite any gif images with the same name! Will not work with names with spaces.

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

Alias for lazy tmux create/reattach
If a tmux session is already running attach it, otherwise create a new one. Useful if you often forget about running tmuxes (or just don't care)

Install a LAMP server in a Debian based distribution
The execution of this command will install a LAMP server (Linux, Apache, MySQL and PHP) in a Debian based distribution. For example, in Ubuntu.

find text in a file
this will find text in the directory you specify and give you line where it appears.

locating packages held back, such as with "aptitude hold "
locating packages held back, such as with "aptitude hold "

Readd all files is missing from svn repo
When working on a big proeject with SVN, you create quite much files, for now! Can just sit here and type svn add for all of them! svn status will return a list of all of file which get ?(not add), "M"(Modified), "D"(Deleted)! This code just grep "?" flag, then add it into SVN again!

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh 127.0.0.1 -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.


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: