All commands (14,187)


  • 0
    ssh-keygen -t rsa -b 4096
    aysadk · 2017-07-03 09:25:21 14
  • Changes files like "temp (2).txt" to "temp.txt". Does not overwrite files that already exist.


    0
    find . -name "*\(2\)*" -exec rename -s \ \(2\) '' -n {} +
    buddacow · 2017-06-30 04:33:50 17
  • It's a tool of the great csvkit https://csvkit.readthedocs.io/en/1.0.2/scripts/csvjson.html


    0
    csvjson -k "CityID" city.csv
    aborruso · 2017-06-28 06:36:32 16
  • Based / Inspired by malathion's below command http://www.commandlinefu.com/commands/view/20528/convert-csv-to-json Is written for python3 and is very easy to use csv2json *csv will convert all files ending in csv to json eg csv2json file.csv will output a file to file.json Validity of json tested in python3 and below site https://jsonformatter.curiousconcept.com/


    1
    csv2json() { for file in $@; do python -c "import csv,json,fileinput; print(json.dumps(list(csv.reader(fileinput.input()))))" "$file" 1> "${file%%csv}json"; done; }
    snipertyler · 2017-06-28 04:28:32 16

  • 0
    obase=16; echo "$(date +%s)" | bc | xxd -r -p | base32
    malathion · 2017-06-26 16:58:38 22
  • see summary. if you want to set dpi right away try this: xrandr --query | sed -n 's@\([A-Z0-1-]*\).* \(.*\)x\(.*\)+.*+.* \([0-9]\+\)mm x \([0-9]\+\)mm@"--output \1 --dpi ";(\2/\4+\3/\5)*12.7@p;'|bc -l|xargs -L1 xrandr all syntax should be POSIX compliant. Show Sample Output


    0
    xrandr --query | sed -n 's@\([A-Z0-1-]*\).* \(.*\)x\(.*\)+.*+.* \([0-9]\+\)mm x \([0-9]\+\)mm@"\1: ";(\2/\4+\3/\5)*12.7@p;'|bc -l
    hydrogenization · 2017-06-23 03:44:40 16

  • 1
    echo "http://commandlinefu.com" | curl -F-=\<- qrenco.de
    malathion · 2017-06-22 22:27:16 19
  • Extract a color palette from a image useful for designers. Example usage: extract-palette myawesomeimage.jpg 4 Where the first argument is the image you want to extract a palette from. The second argument is the number of colors you want. It may be the case where you want to change the search space. In that case, change the -resize argument to a bigger or smaller result. See the ImageMagick documentation for the -resize argument. Show Sample Output


    1
    extract-palette() { convert "$1" -resize 300x -dither None -colors "$2" txt: | tail -n +2 | tr -s ' ' | cut -d ' ' -f 3 | sort | uniq -c | sort -rn | tr -s ' ' | cut -d ' ' -f 3;}
    seabre · 2017-06-21 22:07:26 51
  • Removes the package, 'packagename' in the example ,from your system. '-R' is the actual removal option, 'n' is for removing backup configuration files saved by pacman, and 's' is for removing the dependencies of the given package which are not required by other packages. pacman does not remove configuration files, etc. created by the package.


    -1
    sudo pacman -Rns packagename
    newnumber · 2017-06-20 12:14:03 17

  • -1
    sudo fuser -vki /var/lib/dpkg/lock; sudo dpkg --configure -a
    newnumber · 2017-06-20 12:00:02 22

  • -1
    chmod 777 -R <filename>
    newnumber · 2017-06-20 11:59:17 17

  • -1
    dconf reset -f /org/compiz/
    newnumber · 2017-06-20 11:56:21 20

  • -1
    winecfg
    newnumber · 2017-06-20 11:55:35 17

  • -1
    wine uninstaller
    newnumber · 2017-06-20 11:55:06 24

  • -1
    java -version
    newnumber · 2017-06-20 11:54:31 17

  • -1
    wine --version
    newnumber · 2017-06-20 11:54:03 18

  • -1
    service --status-all
    newnumber · 2017-06-20 11:53:22 17

  • -1
    df -h
    newnumber · 2017-06-20 11:52:47 17

  • -1
    ls -a
    newnumber · 2017-06-20 11:52:19 17

  • -1
    upower -i /org/freedesktop/UPower/devices/battery_BAT0
    newnumber · 2017-06-20 11:50:59 35

  • -1
    sudo dpkg -i *.deb
    newnumber · 2017-06-20 11:45:35 16
  • Revert a Digital Cinema Package back to a ProRes file, to (kind of) verify if the DCP creation wen't well Show Sample Output


    0
    ffmpeg -i VIDEODCP.mxf -i AUDIODCP.mxf -vcodec h264 -acodec aac reverse-prores.mov
    ghms · 2017-06-16 18:00:48 18
  • This command KIND OF play a Digital Cinema Package files through VLC using FFMPEG realtime encoding. For a smooth playback you'll need a REALLY powerful computer, possibly a rig with two or more processors (really!) Otherwise, it may be better to just convert the DCP to ProRes and playing it afterwards.


    0
    ffmpeg -re -i VIDEODCP.mxf -i AUDIODCP.mxf -vcodec h264 -acodec aac -f mpegts udp://127.0.0.1:1234
    ghms · 2017-06-16 17:57:50 18
  • The Piano Phase piece, by Steve Reich is a minimalist composition which is played on two pianos played at slightly different tempos, a task that's very difficult to accomplish by human players. The auditive effects produced by the cell displacement produce beautiful patterns. See https://en.wikipedia.org/wiki/Piano_Phase . My rendered version: https://ydor.org/SteveReich/piano_phase.mp3 Requires sox to be installed on the system. There are multiple videos on youtube showing different approaches and experiences to this interpretation. There is also a synthesized version. Even if Bash can behave as a powerful pianist, a simple threaded version leaves full room to several time glitches and even negative displacements, the same issues that human pianists experience when playing the piece. The older the computer, the better the chaos added to the result due to the CPU load. Apparently that's the reason Steve Reich composes pieces such as this. Without further ado, please give a warm welcome to the Bash minimalist player on synthesized two-threaded pianos. Please turn off your cellphones.


    1
    phase() { while :; do for n in E4 F#4 B4 C#5 D5 F#4 E4 C#5 B4 F#4 D5 C#5; do /usr/bin/play -qn synth $1 pluck $n; done; echo -n "[$1]"; done; }; phase 0.13 & phase 0.131 &
    rodolfoap · 2017-06-14 20:29:26 21
  • This function will encrypt a bash script and will only execute it after providing the passphrase. Requires mcrypt to be installed on the system. Show Sample Output


    1
    scrypt(){ [ -n "$1" ]&&{ echo '. <(echo "$(tail -n+2 $0|base64 -d|mcrypt -dq)"); exit;'>$1.scrypt;cat $1|mcrypt|base64 >>$1.scrypt;chmod +x $1.scrypt;};}
    rodolfoap · 2017-06-14 16:27:20 20
  • ‹ First  < 37 38 39 40 41 >  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

Rename files in batch

Display 16 largest installed RPMs in size order, largest first
Interesting to see which packages are larger than the kernel package. Useful to understand which RPMs might be candidates to remove if drive space is restricted.

Purge configuration files of removed packages on debian based systems
also search with aptitude search '~c'

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"

lists files and folders in a folder
lists files and folders in a folder with summary.

Filter the output of a file continously using tail and grep

Check if filesystem hangs
When a fs hangs and you've just one console, even # ls could be a dangerous command. Simply put a trailing "&" and play safe

most used unix commands

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

Log your internet download speed
This will log your internet download speed. You can run $gnuplot -persist


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: