All commands (14,045)

  • 5
    ss -plunt
    symgryph · 2019-12-09 17:44:55 6
  • This assumes you are in the cwd of where you put your s3 scripts. Its useful if someone decides to create aws cloudformation scripts and doesn't add the 'yaml' or .yml extension. Show Sample Output

    rg -l "AWSTemplateFormatVersion: '2010-09-09'" *
    symgryph · 2019-12-09 17:43:10 6
  • Python is installed on many boxes (in case you could not afford installing jq).

    curl -s "<username>/repos?per_page=1000" | python <(echo "import json,sys;v=json.load(sys.stdin);for i in v:; print(i['git_url']);" | tr ';' '\n')
    grault · 2019-12-07 10:49:58 5
  • in case you could afford installing jq

    curl -s "<username>/repos?per_page=1000" | jq '.[].git_url'
    grault · 2019-12-07 10:48:32 5
  • Using the csv tool `miller` you can transform a csv file into a json array of objects, where the properties are the values of the csv header line and the values are the values of the subsequent lines. Show Sample Output

    mlr --c2j --jlistwrap cat file.csv
    pepa65 · 2019-12-06 07:16:58 5

  • 5
    watch -n1 "ps aux --sort=-%mem,-%cpu | head -n 50"
    jgleeson · 2019-12-03 20:51:03 6
  • Use flag "--" to stop switch parsing Show Sample Output

    grep -- -
    knoppix5 · 2019-11-29 23:45:06 5

  • 14
    curl -s<username>/repos?per_page=1000 |grep git_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/'
    wuziduzi · 2019-11-19 20:31:19 5
  • Shell function which takes a bash command as its input, and displays the following formatted output: EXAMPLE: command OUTPUT: output from command Show Sample Output

    example() { echo "EXAMPLE:"; echo; echo " $@"; echo; echo "OUTPUT:"; echo ; eval "$@" | sed 's/^/ /'; }
    bartonski · 2019-11-10 19:08:23 7
  • Measure the cpu performance: In-case if the cpu is thermal throttling then you can find it using this command. Check the first line of the output. Example: Doing md5 for 3s on 16 size blocks: 11406892 md5's in 2.98s ? #(When cpu is not throttling) Doing md5 for 3s on 16 size blocks: 110692 md5's in 2.98s ?? #(When cpu is thermal throttling) Practical use case: Once we had cooling outage in data center which caused thermal throttling in some of the worker nodes. We used this tool to prove that some servers are not performing well because of the cpu thermal throttling. Show Sample Output

    openssl speed md5
    kharthigeyan · 2019-11-07 16:30:30 10
  • Click window to change its opacity. Source:

    yoyoyojomo · 2019-10-31 20:44:21 5
  • This command first determines whether a second screen is connected. If this is the case, it sets the screen's RGB gamma via xrandr. Useful for cheap or slightly defective monitors with a tint. In this example a yellowing/champagne color deviation is compensated for by decreasing the red and the green portion of the image.

    secondscreen=$(xrandr -q | grep " connected" | sed -n '2 p' | cut -f 1 -d ' '); [ "$secondscreen" ] && xrandr --output $secondscreen --gamma 0.6:0.75:1
    lordtoran · 2019-10-28 13:12:08 6
  • Change the file extension in batch. Useful to create output file names with same input name but distinct extension by including logic inside the loop

    for file in *.txt; do mv "$file" "${file%.txt}.xml"; done
    neomefistox · 2019-10-24 04:35:10 4

  • 5
    find /glftpd/site/archive -type f|grep '([0-9]\{1,9\})\.[^.]\+$'|parallel -n1 -j200% md5sum ::: |awk 'x[$1]++ { print $2 " :::"}'|sed 's/^/Dupe: /g'|sed 's,Dupe,\x1B[31m&\x1B[0m,'
    wuziduzi · 2019-10-22 16:02:15 5
  • I find the other timers are inaccurate. It takes some microseconds to perform the date function. Therefore, using date/time math to calculate the time for us results in millisecond accuracy. This is tailored to the BusyBox date function. May need to change things around for GNU date function. Show Sample Output

    let T=$(date +%s)+3*60;while [ $(date +%s) -le $T ]; do let i=$T-$(date +%s); echo -ne "\r$(date -d"0:0:$i" +%H:%M:%S)"; sleep 0.3; done
    davidk · 2019-10-22 15:04:21 5
  • Top 10 Memory Processes (reduced output to applications and %usage only) Show Sample Output

    ps aux | sort -rk 4,4 | head -n 10 | awk '{print $4,$11}'
    n0a110w · 2019-10-20 22:52:55 4
  • You will see it on the corner of your running terminal. Show Sample Output

    while sleep 1; do tput sc; tput cup 0 $(($(tput cols)-29)); date; tput rc; done &
    rakibfiha · 2019-10-19 20:50:48 9
  • Hides all Files and Folders on the MacOS Desktop. To show files and folders, type "true" instead of "false". "Finder" at the end is case sensitive, "finder" doesn’t work

    defaults write CreateDesktop -bool false;killall Finder
    vranx · 2019-10-18 12:13:56 9

  • 2
    for i in *; do sum=$(md5sum $i); mv -- "$i" "${sum%% *}"; done
    malsploit · 2019-10-17 08:46:22 6
  • Works for repos cloned via ssh or https. Show Sample Output

    git remote -v | sed -n '/*push/{s/^[^[:space:]]\+[[:space:]]\+//;s|||;s/\.git.*//;p}'
    bartonski · 2019-10-11 16:50:22 3
  • GNU grep's perl-compatible regular expression(PCRE).

    binaries () { dpkg -L "$1" | grep -Po '.*/bin/\K.*'; }
    metropolis · 2019-10-05 10:52:15 3
  • This shell function displays a list of binaries contained in an installed package; works on Debian based Linux distributions. Show Sample Output

    binaries () { for f in $(dpkg -L "$1" | grep "/bin/"); do basename "$f"; done; }
    lordtoran · 2019-10-05 10:37:51 7
  • With this command you can convert a tab separate file (TSV) into a JSON file with jq. For example, this input.tsv i-0b9adca882e5e6326 i-088dd69e5c3624888 i-0e70eac180537d4aa will produce the showed output. Show Sample Output

    cat input.tsv | jq --raw-input --slurp 'split("\n") | map(split("\t")) | .[0:-1] | map( { "id": .[0], "ip": .[1] } )'
    nordri · 2019-10-01 10:52:35 3
  • It displays the top 10 processes sorted by memory usage Show Sample Output

    ps aux | sort -rk 4,4 | head -n 10
    x3mboy · 2019-09-26 16:37:33 5
  • Copy this function to command line, press 'Enter' 'f'' 'Enter' to execute (sentence on the left written only for newbies). Hint 'e|x|v|1..9' in front of displayed last modified file name means: "Press 'e' for edit,'x' for execute,'v' for view or a digit-key '1..9' to touch one file from the recent files list to be last modified" and suggested (hidden files are listed too, else remove 'a' from 'ls -tarp' statement if not intended). If you find this function useful you can then rename it if needed and append or include into your ~/.bashrc config script. With the command . ~/.bashrc the function then can be made immediately available. In the body of the function modifications can be made, i.e. replaced joe editor command or added new option into case statement, for example 'o) exo-open $h;;' command for opening file with default application - or something else (here could not be added since the function would exceed 255 chars). To cancel execution of function started is no need to press Ctrl-C - if the mind changed and want to leave simple Enter-press is enough. Once defined, this function can with typeset -f f command be displayed in easy readable form Show Sample Output

    f() { ls -lart;e="ls -tarp|grep -v /|tail -9";j=${e/9/1};g=${e/9/9|nl -nln};h=$(eval $j);eval $g;read -p "e|x|v|1..9 $(eval $j)?" -n 1 -r;case $REPLY in e) joe $h;;v)cat $h;;x) eval $h;;[1-9]) s=$(eval $g|egrep ^$REPLY) && touch "${s:7}" && f;;esac ; }
    knoppix5 · 2019-09-26 11:58:37 3
  • ‹ First  < 3 4 5 6 7 >  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

alt + 1 .
alt + number + dot will insert last command argument at $number place, alt + 0 + . will print last command name. For example $ ls /tmp /var $ ls /usr /home alt + 1 + . will result in '/usr' , if you press alt + . again, it will result in '/tmp' alt + 0 + . -> 'ls'

list processes with established tcp connections (without netstat)
Uses lsof to list open network connections (file descriptors), grepping for only those in an established state

Relocate a file or directory, but keep it accessible on the old location throug a simlink.
Used for moving stuff around on a fileserver

find an unused unprivileged TCP port
perl-less way

List latest 5 modified files recursively
The output format is given by the -printf parameter: %T@ = modify time in seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. Mandatory, hidden in the end. %TY-%Tm-%Td %TH:%TM:%.2TS = modify time as YYYY-MM-DD HH:MM:SS. Optional. %p = file path Refer to for more about -printf formatting. ------------------------ sort -nr = sort numerically and reverse (higher values - most recent timestamp - first) head -n 5 = get only 5 first lines (change 5 to whatever you want) cut -f2- -d" " = trim first field (timestamp, used only for sorting) ------------------------ Very useful for building scripts for detecting malicious files upload and malware injections.

show rpm packages scriptlets

move cursor to beginning of command line
Pressing Ctrl combined with 'a' will move the cursor to the beginning of the command under bash (other shells?). I used to do this after arrowing up for the last command, then typing 'sudo ' to run the last command as root, but of course the all time greatest command here `sudo !!` is more succinct. Still Ctrl+A can be very useful when you want to edit something at/close to the beginning of the command line.

Press enter and take a WebCam picture.
This command takes a 1280x1024 p picture from the webcam. If prefer it smaller, try changing the -s parameter: qqvga is the tiniest, vga is 640x480, svga is 800x600 and so on. Get your smile on and press enter! :)

[vim] Clear trailing whitespace in file
% acts on every line in the file. \s matches spaces. \+ matches one or more occurrences of what's right behind it. Character '$' matches end-of-line.

list block devices
Shows all block devices in a tree with descruptions of what they are.

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: