Commands by SamuelWN (1)

  • The function had to be cut down to meet the maximum command length requirements. The full version of the function is: extract() { if [ -f $1 ]; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xvf $1 ;; *.tbz2) tar xvjf $1 ;; *.tgz) tar xvzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via >extract<" ;; esac else echo "'$1' is not a valid file!" fi } Note: This is not my original code. I came across it in a forum somewhere a while ago, and it's been such a useful addition to my .bashrc file, that I thought it worth sharing. Show Sample Output

    extract() {if [ -f $1 ];then case $1 in *.tar.bz2) tar xvjf $1;;*.tar.gz) tar xvzf $1;;*.bz2) bunzip2 $1;;*.rar) unrar x $1;;*.gz) gunzip $1;;*.tar) tar xvf $1;;*.tbz2) tar xvjf $1;;*.tgz) tar xvzf $1;;*.zip) unzip $1;;*.7z) 7z x $1;;esac fi}
    SamuelWN · 2016-02-08 14:52:05 0

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

Bypass 1000 Entry limit of Active Directory with ldapsearch
That command bypass the entry limit specifing page results size, when the search arrive to the limit ldapsearch magically reiterate it from the last entry.

Make a file not writable / immutable by root

create disk copy over the net without temp files
I wanted to create a copy of my whole laptop disk on an lvm disk of the same size. First I created the logical volume: lvcreate -L120G -nlaptop mylvms SOURCE: dd if=/dev/sda bs=16065b | netcat ip-target 1234 TARGET: nc -l -p 1234 | dd of=/dev/mapper/mylvms-laptop bs=16065b to follow its process you issue the following command in a different terminal STATS: on target in a different terminal: watch -n60 -- kill -USR1 $(pgrep dd) (see

Change host name
With sed you can replace strings on the fly.

history autocompletion with arrow keys
This will enable the possibility to navigate in the history of the command you type with the arrow keys, example "na" and the arrow will give all command starting by na in the history.You can add these lines to your .bashrc (without &&) to use that in your default terminal.

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"

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

Transform a portrait pdf in a landscape one with 2 pages per page
This is an example of the usage of pdfnup (you can find it in the 'pdfjam' package). With this command you can save ink/toner and paper (and thus trees!) when you print a pdf. This tools are very configurable, and you can make also 2x2, 3x2, 2x3 layouts, and more (the limit is your fantasy and the resolution of the printer :-) You must have installed pdfjam, pdflatex, and the LaTeX pdfpages package in your box.

Limit the transfer rate of a pipe with pv
-L RATE, --rate-limit RATE Limit the transfer to a maximum of RATE bytes per second. A suffix of "k", "m", "g", or "t" can be added to denote kilobytes (*1024), megabytes, and so on. It must be an integer.

make 100 directories with leading zero, 001...100, using bash3.X

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: