Commands by VictorBjelkholm (3)

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

Open (in vim) all modified files in a git repository
The option --porcelain makes the output of git easier to parse. This one-liner may not work if there is a space in the modified file name.

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.

stderr in color
in case you run some command in CLI and would like to take read strerr little bit better, you can use the following command. It's also possible to grep it if necessary....

Rename files in batch

Alternative way to generate an XKCD #936 style 4 word password usig sed
This is what I came up to generate XKCD #936 style four-word password. Since first letter of every word is capitalized it looks a bit more readable to my eyes. Also strips single quotes. And yes - regex is a bit of a kludge, but that's the bes i could think of.

search ubuntu packages to find which package contains the executable program programname
search ubuntu's remote package source repositories for a specific program to see which package contains it

Download and install the newest dropbox beta

a find and replace within text-based files, to locate and rewrite text en mass.
syntax follows regular command line expression. example: let's say you have a directory (with subdirs) that has say 4000 .php files. All of these files were made via script, but uh-oh, there was a typo! if the typo is "let's go jome!" but you meant it to say "let's go home!" find . -name "*.php" | xargs perl -pi -e "s/let\'s\ go\ jome\!/let\'s\ go\ home\!/g" all better :) multiline: find . -name "*.php" | xargs perl -p0777i -e 's/knownline1\nknownline2/replaced/m' indescriminate line replace: find ./ -name '*.php' | xargs perl -pi -e 's/\".*$\"/\new\ line\ content/g'

cpu and memory usage top 10 under Linux
The original version gives an error, here is the correct output

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

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: