All commands (13,405)

  • use '*' instead of 'ls'

    for f in *;do echo $f;done
    famaral · 2018-09-21 14:27:23 1
  • wget && tar -xzf 1.15.3.tar.gz && cd nginx-1.15.3 Show Sample Output

    ./configure --help | grep -P "^ +--with-(?!(poll|select))[^=]+(_module( |$)| (module|support)$)" | sed -r 's/((dis|en)able|build) /# /'
    emphazer · 2018-09-14 12:54:06 0
  • opposite of ;-) Show Sample Output

    function URLEncode { local dataLength="${#1}"; local index; for ((index = 0;index < dataLength;index++)); do local char="${1:index:1}"; case $char in [a-zA-Z0-9.~_-]) printf "$char"; ;; *) printf "%%%02X" "'$char"; ;; esac; done; }
    emphazer · 2018-09-14 12:08:10 0
  • Unlock your VMS to avoid problems after some failed tasks ended. Show Sample Output

    for i in $(qm list | awk '{ print $1 }' | grep -v VMID); do echo "Unlocking:" $i; qm unlock $i; echo "Unlocked"; done
    arkalira · 2018-09-13 08:35:12 0

  • 1
    rpm -qa --last | head -n 16
    sparsile · 2018-09-13 02:55:51 0
  • Display a list of the 16 most recently installed RPM packages with newest first. Show Sample Output

    rpm -qa --queryformat '%{INSTALLTIME} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16 | awk '{printf("%3d %s %s\n", $1,strftime("%c",$2),$3)}'
    mpb · 2018-09-12 17:47:26 1

  • 1
    tcpdump -nnvvXSs 1514 -i <device> <filters>
    25killer · 2018-09-09 10:37:19 0

  • 1
    comm -12 <(sort -u File1) <(sort -u File2)
    guillaume1306 · 2018-09-07 11:36:15 0
  • If you want to code without a IDE, using java may be painful to discover correct full class names to import. This script google it with javadoc word, then with some luck we got the javadoc as first item. next it curl the target javadoc and extract full name from it. Can by customized to extract other javadoc infos. Pre-reqs: bash, google-chrome, html2text and core-utils Show Sample Output

    getJavaFullClassName SpringComponent
    glaudiston · 2018-09-06 18:22:02 0
  • sleep in microseconds instead of seconds Alternatively to usleep, which is not defined in POSIX 2008 (though it was defined up to POSIX 2004, and it is evidently available on Linux and other platforms with a history of POSIX compliance), the POSIX 2008 standard defines nanosleep Show Sample Output

    time usleep 100000
    emphazer · 2018-09-06 10:28:26 0
  • Binding a server to privileged port on Linux w/o running as root This is applicable to any service using privileged ports (< 1024), for instance to run a HTTP server on port 80 or a LDAP directory server on port 389 for example. Show Sample Output

    sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python2.7
    emphazer · 2018-09-04 17:30:47 0
  • Don't want to log out but you do want to get rid of a stored .zip file password in Windows? This will do that.

    FOR /f "tokens=2-3 delims==" %G IN ('cmdkey /list ^| find ".zip"') DO cmdkey /delete:"%G=%H"
    ayaksich · 2018-09-04 16:33:53 0

  • -1
    cal -n 2 8 2018
    actionless · 2018-09-04 13:31:03 0

  • 2
    pstree -plants $(pidof -s firefox)
    cbrchrt · 2018-09-04 12:22:57 0

  • 3
    cat databases.txt | while read db; do docker exec $container_name bash -c "mysqldump -uroot -p\$MYSQL_ROOT_PASSWORD ${db}" | gzip -9 > $HOME/backups/${db}_`date +%Y%m%d_%H%M%S`.sql.gz; done
    batandwa · 2018-09-02 15:23:32 0

  • 0
    mkdir -p src && chmod 777 src && docker run -v $(pwd)/src:/var/www/html wordpress:cli core download && chmod 755 src
    nabil_kadimi · 2018-09-01 18:06:42 0

    lynx -dump -nonumbers|grep '/USER/'|cut -d'/' -f1,2,3,4,5|uniq|xargs -L1 git clone
    wuziduzi · 2018-09-01 06:03:23 0
  • Good old bracket expansion :-) For large numbers of files, "rename" will spare you the for-loop, or the find/exec...

    mv {,prefix_}yourfile.txt
    joedhon · 2018-08-30 18:18:50 0
  • Find and Convert all libre office files to PDF without libreoffice GUI Show Sample Output

    find /home/foo/Documents/ -type f -iname "*.odt" -exec libreoffice --headless --convert-to pdf '{}' \;
    switch · 2018-08-29 21:44:26 0
  • Displays last month, current month, and next month side by side. Show Sample Output

    cal -3
    arglborps · 2018-08-28 20:37:33 0

  • -1
    cal -A 1 8 2018
    jscolaire · 2018-08-28 20:23:03 0
  • Here is another way to show the path, one directory per line. The command `tr` translates the colon into the new line, taking input from the $PATH variable Show Sample Output

    tr : \\n <<<$PATH
    haivu · 2018-08-28 20:01:04 0
  • The Linux's `cal` command is nice, but there are times when I need to see two months side by side and this command will do it. Show Sample Output

    paste <(cal 8 2018) <(cal 9 2018)
    haivu · 2018-08-28 19:54:05 0
  • Find recursively all files in ~/Notes with the extension '.md' and pipe that via xargs to rename command, which will replace every '.md' to '.txt' in this example (existing files will not be overwritten).

    find ~/Notes -type f -iname '*.md' -print0 | xargs -0 rename --no-overwrite .md .txt {}
    Sommerfalke · 2018-08-24 09:41:51 1
  • HDMI-1 is the interface in the example, which can be obtained just by typing xrandr and surfing through the output. There are a hell lot of configurations that can be done but I prefer auto because it works in most cases. Lifesaver Show Sample Output

    xrandr --output < interface-name > --auto
    praton · 2018-08-23 17:51:20 0
  •  1 2 3 >  Last ›

What's this? 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

Adding Prefix to File name

Show me a histogram of the busiest minutes in a log file:
Busiest seconds: $ cat /var/log/secure.log | awk '{print substr($0,0,15)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Delete all non-printing characters from a file
tr has some predefined sets of characters that are more convenient to use than characters codes

grep -v with multiple patterns.
That's what the sed command should've been, sorry.

Temporarily ignore mismatched SSH host key
This command will bypass checking the host key of the target server against the local known_hosts file. When you SSH to a server whose host key does not match the one stored in your local machine's known_hosts file, you'll get a error like " WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" that indicates a key mismatch. If you know the key has legitimately changed (like the server was reinstalled), a permanent solution is to remove the stored key for that server in known_hosts. However, there are some occasions where you may not want to make the permanent change. For example, you've done some port-forwarding trickery with ssh -R or ssh -L, and are doing ssh user@localhost to connect over the port-forwarding to some other machine (not actually your localhost). Since this is usually temporary, you probably don't want to change the known_hosts file. This command is useful for those situations. Credit: Command found at Further discussion of how it works is there also. Note this is a bit different than command #5307 - with that one you will still be prompted to store the unrecognized key, whereas this one won't prompt you for the key at all.

Download a numbered sequence of files

Mysql uptime
show Mysql uptime

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"

Python extract json

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.


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: