Commands by unixmonkey1696 (2)

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

List only executables installed by a debian package
I wanted to view only executables installed by a package. This seemed to work. There's got to be easier way, please share. Note: (1) Replace iptables with the package name of your interest (2) The command will trash any existing environment variable named 'lst' (3) Instead if you are interested in viewing just .ko or .so files installed by this package, then that would be easy: $ dpkg -L iptables | grep "\.[sk]o$"

Find the package that installed a command

rsync directory tree including only files that match a certain find result.
'-mtime -10' syncs only files newer 10 days (-mtime is just one example, use whatever find expressions you need) printf %P: File's name with the name of the command line argument under which it was found removed. this way, you can use any src directory, no need to cd into your src directory first. using \\0 in printf and a corresponding --from0 in rsync ensures that even filenames with newline characters work (thanks syssyphus for #3808). both, #1481 and #3808 just work if you either copy the current directory (.) , or the filesystem root (/), otherwise the output from find and the source dir from rsync just don't match. #7685 works with an arbitrary source directory.

Create a backdoor on a machine to allow remote connection to bash
This will launch a listener on the machine that will wait for a connection on port 1234. When you connect from a remote machine with something like : nc 1234 You will have console access to the machine through bash.

Rename all .jpeg and .JPG files to .jpg

Unzip multi-part zip archive
Assuming you have a multi-part archive like " archive.z01 archive.z02 ...", unzip will not handle these correctly. If you "fix" the parts into one big file with zip -F before, it works.

Find how much of your life you've wasted coding in the current directory
Finds all C++, Python, SWIG files in your present directory (uses "*" rather than "." to exclude invisibles) and counts how many lines are in them. Returns only the last line (the total).

Counting the source code's line numbers C/C++ Java
Count your source and header file's line numbers. This ignores blank lines, C++ style comments, single line C style comments. This will not ignore blank lines with tabs or multiline C style comments.

Inverted cowsay
It's quite fun to invert text using "" (ref: ). Slightly more challenging is to flip a whole "cowsay". :-)

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"

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: