Commands by leftyfb (2)

  • Requires: curl xsel access to the internet( This is an alias utilizing the service to make sharing files easier from the command line. I have modified the alias provided by to use xsel to copy the resulting URL to the clipboard. The full modified alias is as follows since commandlinefu only allows 255 characters: transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/\ncat /tmp/ | transfer"; return 1; fi if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "$basefile" |xsel --clipboard; else curl --progress-bar --upload-file "-" "$1" |xsel --clipboard ; fi; xsel --clipboard; } Show Sample Output

    transfer() { basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');curl --progress-bar --upload-file "$1" "$basefile"|xsel --clipboard;xsel --clipboard ; }
    leftyfb · 2016-03-20 19:38:48 12
  • I save this to bin/iptrace and run "iptrace ipaddress" to get the Country, City and State of an ip address using the service. I add the following to my script to get a tinyurl of the map as well: URL=`lynx -dump$1|grep details|awk '{print $2}'` lynx -dump$URL|grep tinyurl|grep "19. http"|awk '{print $2}'

    lynx -dump$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\'
    leftyfb · 2009-02-25 17:16:56 27

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

Run a command after the process you choose finishes
Run a command as soon as another long-running command finishes. E.g. suspend the machine after performing apt upgrade. The process is selected interactively via fzf.

Delete all but latest file in a directory
Useful for deleting old unused log files.

Reverse SSH
this command from the source server and this follow in the destination server: ssh user@localhost -p 8888

Unite pdf files
pdfunite is a part of the poppler-utils. poppler-utils package is only 150KB. The alternative - pdftk package is 14MB! Install poppler-utils if you need simple pdf operation commands like unite, separate, info, text/html conversions

List files older than one year, exluding those in the .snapshot directory
Useful when you want to cron a daily deletion task in order to keep files not older than one year. The command excludes .snapshot directory to prevent backup deletion. One can append -delete to this command to delete the files : $ find /path/to/directory -not \( -name .snapshot -prune \) -type f -mtime +365 -delete

Automatically download Ubuntu 10.04 when available
Tested with 9.10 release. Choose whatever torrent client you prefer.

Find Duplicate Files (based on MD5 hash)
Calculates md5 sum of files. sort (required for uniq to work). uniq based on only the hash. use cut ro remove the hash from the result.

Quickly analyse an Apache error log
This searches the Apache error_log for each of the 5 most significant Apache error levels, if any are found the date is then cut from the output in order to sort then print the most common occurrence of each error.

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested

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.

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: