All commands (13,335)


  • 2
    function hibp() { sha1=$(echo -n "$1"|sha1sum|awk '{print toupper($0)}'|tr -d '\n'); curl -s -H $'Referer: https://haveibeenpwned.com/' https://api.pwnedpasswords.com/range/$(echo -n $sha1|cut -c1-5)|grep -i $(echo -n $sha1|cut -c6-40); }
    zmonkey · 2018-08-14 07:41:55 0

  • 0
    ffmpeg -i input.mp4 -vcodec libx264 -crf 30 output.mp4
    ctcrnitv · 2018-08-13 23:29:50 0
  • This snippet allows to process the output of any bash command line by line.


    0
    while read -r line; do echo $line; done < <(YOUR COMMAND HERE);
    paulera · 2018-08-13 10:03:11 0
  • The file should be a text file formatted like this example: 1 Introduction 10 Chapter 1 +10 Chapter 1, Part A +25 Chapter 1, Part B ++25 Chapter 1, Part B, Subsection 1 ++27 Chapter 1, Part B, Subsection 2 +30 Chapter 1, Part C 50 Chapter 2 70 Chapter 3 The '+' indicates a sub-level heading (multiple +'s for multiple sub-levels). The first number on the line is the source page reference number. The rest of the text on the line is the name of the chapter / subheading.


    0
    k2pdfopt -mode copy -n -toclist $tocFile $inFile -o $outFile
    HaoZeke · 2018-08-13 08:08:40 0

  • 0
    find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \;
    HaoZeke · 2018-08-13 07:31:54 0

  • 0
    echo -e "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/dev/x86_64" | sudo tee -a /etc/pacman.conf
    HaoZeke · 2018-08-13 07:30:55 0
  • Converts an OGG file to MP3 at desired quality, preserving the id3v2 tags.


    0
    ffmpeg -i input.ogg -ab 256k -map_metadata 0:s:0 output.mp3
    woohoo · 2018-08-11 21:44:27 0
  • You need to use the aws ec2 describe instances to get the JSON file. Show Sample Output


    0
    cat aws.json | jq -r '.Reservations[].Instances[] | [.PrivateIpAddress, .SecurityGroups[].GroupId,.SecurityGroups[].GroupName,.NetworkInterfaces[].NetworkInterfaceId,(.Tags[] | select(.Key =="Name") | .Value),([.InstanceId| tostring] | join(";"))]|@csv'
    symgryph · 2018-08-08 19:22:58 1

  • 0
    ifconfig $(route -n |awk '/0[.]0[.]0[.]0/{print $NF;exit}') | awk '/inet/{print $2}'
    pawelkl · 2018-08-06 17:39:25 0

  • 1
    docker ps -aq --filter status=exited | xargs docker rm
    p1ngouin · 2018-08-06 11:48:24 0
  • Apart from an exact copy of your recent contents, also keep all earlier versions of files and folders that were modified or deleted. Inspired by the excellent EVACopy http://evacopy.sourceforge.net Show Sample Output


    2
    backup() { source=$1 ; rsync --relative --force --ignore-errors --no-perms --chmod=ugo=rwX --delete --backup --backup-dir=$(date +%Y%m%d-%H%M%S)_Backup --whole-file -a -v $source/ ~/Backup ; } ; backup /source_folder_to_backup
    pascalv · 2018-08-02 21:27:29 0

  • 0
    docker image rm $(docker image list -f "dangling=true" -qa)
    mate · 2018-08-01 08:16:20 0
  • This will do a clean up of stopped containers and volumes used by them Show Sample Output


    0
    docker system prune --volumes -f
    cfsalguero · 2018-07-31 12:20:02 0

  • 0
    docker images | grep <none> | awk '{ print $3; }' | xargs docker rmi
    hiepdev · 2018-07-31 03:25:58 0
  • Removed grep and simplified if statement. -- Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale. Show Sample Output


    0
    for i in {2018..2025}-{01..12}-13; do [[ $(date --date $i "+%u") == 5 ]] && echo "$i Friday the 13th"; done
    cpqlinux · 2018-07-30 15:54:24 0
  • The original overwrites any previous backups, and only saves exactly the last hours worth, but not 1 hour + 1 minute. This version creates or appends files, and backs up everything since the last backup (using the backups timestamp as the reference), plus it uses TMPDIR if set.


    0
    echo "function backup() { local CA=c T=${TMPDIR:+/tmp}/backup.tar.gz; [[ -f $T ]]&& C=r; find ~ -type f -newer $T | tar ${CA}vfz $T -T - ;}" >> ~/.bashrc
    uberbaud · 2018-07-29 16:09:31 0

  • 0
    for i in $(aws ec2 describe-regions --output text --region "" | cut -f 3); do aws ec2 describe-images --output text --region $i --filter Name=name,Values=myimage | cut -f 6 | grep ami* | xargs -I {} aws ec2 deregister-image --region $i --image-id {};done
    leatherface · 2018-07-27 13:41:51 0

  • 0
    echo "some text `date +%Y-%m-%d\_%H:%M:%S`" >> /path/to/filename
    test666v2 · 2018-07-26 23:44:49 0
  • It will generate a new file ending with "_ThumbnailImage.jpg" which is the embedded thumbnail inside the JPG for example.


    0
    exiftool -a -b -W %d%f_%t%-c.%s -preview:all YourFileOrDirectory
    bugmenot · 2018-07-26 09:41:08 0
  • -n reads input, line by line, in a loop sending to $_ Equivalent to while () { mycode } -e execute the following quoted string (i.e. do the following on the same line as the perl command) the elipses .. operator behaves like a range, remembering the state from line to line.


    2
    perl -ne 'print if /start_pattern/../stop_pattern/' file.txt
    SunKing2 · 2018-07-24 03:23:12 1

  • 0
    find . -type d
    fredericorama · 2018-07-23 20:17:11 0
  • Uses the shell builtin `declare` with the '-f' flag to output only functions to grep out only the function names. You can use it as an alias or function like so: alias shfunctions="builtin declare -f | command grep --color=never -E '^[a-zA-Z_]+\ \(\)'" shfunctions () { builtin declare -f | command grep --color=never -E '^[a-zA-Z_]+\ \(\)'; } Show Sample Output


    2
    builtin declare -f | command grep --color=never -E '^[a-zA-Z_]+\ \(\)'
    sciro · 2018-07-23 05:24:04 0

  • 0
    docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull
    imjoseangel · 2018-07-19 09:14:14 0
  • Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale. Show Sample Output


    2
    for i in {2018..2025}-{01..12}-13; do [[ $(date --date $i +"%u" | grep 5) != 5 ]] || echo "$i Friday the 13th"; done
    test666v2 · 2018-07-10 21:31:02 0

  • 1
    ip route add default via 192.168.2.1 dev ens33
    kdetony · 2018-07-10 17:55:25 0
  •  1 2 3 >  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

execute command on all files of certain types excluding folders that match pattern

Recursively Find Images, Convert to JPEGS and Delete
Simple command to convert a large number of images into jpeg-format. Will delete originals after conversion.

Display the list of all opened tabs from Firefox via a python one-liner and a shell hack to deal with python indentation.
You have to do that before : $ cd ~/.mozilla/firefox/ Require bash. If you use something else, you may use $ echo | python Forked from ArkSeth python script.

a function to create a box of '=' characters around a given string.
First argument: string to put a box around. Second argument: character to use for box (default is '=') Same as command #4962, cleaned up, shortened, and more efficient. Now a ' * ' can be used as the box character, and the variables get unset so they don't mess with anything else you might have. They marked c++ as a function for this command, but I'm not sure why. Must be a bug.

Sort all running processes by their memory & CPU usage
you can also pipe it to "tail" command to show 10 most memory using processes.

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"

Webcam view with vlc
Quick command to test your webcam. Press 'f' to toggle fullscreen. Can also use 'vlc v4l2://' if you want gui controls. For higher/smoother framerate lower the default resolution: $ cvlc v4l2:// :v4l2-width=320 :v4l2-height=240 &

Install pip with Proxy
Installs pip packages defining a proxy

Leap year calculation

LDAP search to query an ActiveDirectory server
These are the parameters to ldapsearch (from ldap-utils in Ubuntu), for searching for the record for Joe Blogg's user. sAMAccountName is the LDAP field that ActiveDirectory uses to store the user name. 'DOMAIN\Joe.Bloggs' where "DOMAIN" is the the active directory domain. Othewise you could use "CN=Joe.Bloggs,DC=example,DC=com" instead of "DOMAIN\Joe.Bloggs"


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: