Commands by DJVG (1)

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

show how many regex you use in your vim today
i want to count how many regex code i have used in vim in a long time so i make a directory in svn host and post record to this directory of course i dont want to post manually so i worte a script to do that and this is the core thing to do

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.

In (any) vi, add a keystroke to format the current paragraph.
That goes into your $HOME/.exrc file. " Nice macro to reformat lines: map ^A !}fmt Note that the ^A has to be input by typing ^V^A.

Find out my Linux distribution name and version

list only directories in reverse order
list only directories in reverse order

Show which programs are listening on TCP and UDP ports
-p Tell me the name of the program and it's PID -l that is listening -u on a UDP port. -n Give me numeric IP addresses (don't resolve them) -t oh, also TCP ports

Script executes itself on another host with one ssh command
Now put more interesting stuff on the script in replacement of hostname, even entire functions, etc, and stuff. hosta> cat #!/bin/sh [ $1 == "client" ] && hostname || cat $0 | ssh $1 /bin/sh -s client hosta> hostb hostb hosta>

Check if it's OK to spawn tmux. Bool's Rools.
The command cechks if we are connected to a X11 console, if the $TERM var noct yet contains a "screen" derivat, and only then attachs to tmux. You could add a test for interactive shell [[ $- == *i* ]] but your .bashrc has that already, I bet.

Rename files in batch

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: