Commands by carlesso (2)

  • This is useful for example if you are on ssh in a server and the server goes down without letting you out. This is part of a larget sets of escape sequences provided by ssh. You can find them with ~? Here's the list: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~R - request rekey ~V/v - decrease/increase verbosity (LogLevel) ~^Z - suspend ssh ~# - list forwarded connections ~& - background ssh (when waiting for connections to terminate) ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.) Show Sample Output


    11
    <Return>~.
    carlesso · 2013-06-26 13:34:58 12
  • Useful if you have a list of images called 1 2 3 4 and so on, you can adapt it to rewrite it as 4 (in this example) 0-padded number. Show Sample Output


    5
    for i in ???.jpg; do mv $i $(printf %04d $(basename $i .jpg) ).jpg ; done
    carlesso · 2010-11-18 23:48:41 3

What's this?

commandlinefu.com 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 all established tcp connections on os x

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"

Clone perms and owner group from one file to another
Copy both perms and owner group from one file to another.

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.

Compress a file or directory keeping the owner and permissions

list files recursively by size

command line fu roulette
retrieves the html from a random command line fu page, then finds commands on the page and prints them alternatively, pipe to bash (add "| bash" to the end) to execute the command (very risky) edit: had to adjust to properly display the portion that replaces HTML characters (e.g. &quot; -> ")

List of reverse DNS records for a subnet
This command uses nmap to perform reverse DNS lookups on a subnet. It produces a list of IP addresses with the corresponding PTR record for a given subnet. You can enter the subnet in CDIR notation (i.e. /24 for a Class C)). You could add "--dns-servers x.x.x.x" after the "-sL" if you need the lookups to be performed on a specific DNS server. On some installations nmap needs sudo I believe. Also I hope awk is standard on most distros.

Launch a command from a manpage
Launch a command from within a manpage, vim style. This is rather trivial, but can be very useful to try out the functions described in a manpage without actually quitting it (or switching to another console/screen/...).

pass the output of some command to a new email in the default email client
This depends on 'stripansi' and 'urlencode' commands, which exist on my system as these aliases: $ alias stripansi='perl -ple "s/\033\[(?:\d*(?:;\d+)*)*m//g;"' $ alias urlencode='perl -MURI::Escape -ne "\$/=\"\"; print uri_escape \$_"' The `open` command handles URLs on a Mac. Substitute the equivalent for your system (perhaps gnome-open). I don't use system `mail`, so I have this aliased as `mail` and use it this way: $ git show head | mail


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: