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

determine if tcp port is open
@putnamhill, no need if statement in that case. && is a AND and || is a OR

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/

Top ten (or whatever) memory utilizing processes (with children aggregate) - Can be done without the multi-dimensional array

Show apps that use internet connection at the moment.
show only the name of the apps that are using internet

Find out how much ram memory has your video (graphic) card

Read just the IP address of a device

External IP (raw data)

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"

Does a traceroute. Lookup and display the network or AS names and AS numbers.
From the man page. lft ? display the route packets take to a network host/socket using one of several layer-4 protocols and methods; optionally show heuristic network information in transitu -A Enable lookup and display of of AS (autonomous system) numbers (e.g., [1]). This option queries one of several whois servers (see options 'C' and 'r') in order to ascertain the origin ASN of the IP address in question. By default, LFT uses the pWhoIs service whose ASN data tends to be more accurate and more timely than using the RADB as it is derived from the Internet's global routing table. -N Enable lookup and display of network or AS names (e.g., [GNTY-NETBLK-4]). This option queries Prefix WhoIs, RIPE NCC, or the RADB (as requested). In the case of Prefix WhoIs or RADB, the network name is displayed. In the case of RIPE NCC, the AS name is displayed.

how to export a table in .csv file
Exports the result of query in a csv file


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: