Commands by pdurbin (1)

  • "Vice versa xorriso is able to copy file objects out of ISO 9660 filesystems." -- Show Sample Output

    xorriso -osirrox on -indev /tmp/pmagic-6.7.iso -report_about NOTE -extract / /tmp/extractedfiles
    pdurbin · 2012-05-26 10:48:59 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

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"

Display the number of connections to a MySQL Database
Count the number of active connections to a MySQL database. The MySQL command "show processlist" gives a list of all the active clients. However, by using the processlist table, in the information_schema database, we can sort and count the results within MySQL.

Delete all non-printing characters from a file
tr has some predefined sets of characters that are more convenient to use than characters codes

share internet connection with only one network interface
the below command create a alias for share your internet connection with another. $ifconfig eth0:1 Its obviously necessary too activate the iptables post-routing and ip forwarding, as root: $modprobe iptable_nat $iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE $echo 1 > /proc/sys/net/ipv4/ip_forward Be sure that the alias is not your active real ip range

Recursively grep for string and format output for vi(m)
This is a big time saver for me. I often grep source code and need to edit the findings. A single highlight of the mouse and middle mouse click (in gnome terminal) and I'm editing the exact line I just found. The color highlighting helps interpret the data.

Find the package that installed a command

Search recursively to find a word or phrase in certain file types, such as C code
I have a bash alias for this command line and find it useful for searching C code for error messages. The -H tells grep to print the filename. you can omit the -i to match the case exactly or keep the -i for case-insensitive matching. This find command find all .c and .h files

add the result of a command into vi
':r!ls -l' results in listing the files in the current directory and paste it into vi

escape any command aliases
e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash: rm [file] # WILL prompt for confirmation per the alias \rm [file] # will NOT prompt for confirmation per the default behavior of the command

Display or use a random file from current directory via a small bash one-liner
An other way to run it ( playing a random file ending with avi, flv or mpeg ) from a specified dir and a specified type of extension : making MOVIE array with a glob : $ MOVIE=( /PATH/TO/MY/FAVORITE/MOVIES/*.{avi,flv,mpeg} ) playing the random file from a random key from the array $ mplayer ${MOVIE[ RANDOM % ( ${#i[@]} + 1 ) ]]} I use only globs and a bash array. I use GNU bash, version 3.2.48

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: