commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
nc localhost 9876
That's the easiest way to do it. -I (or capital i) display all network addresses of a host
It's useful mostly for your custom scripts, which running on specific host and tired on ssh'ing every time when you need one simple command (i use it for update remote apt repository, when new package have to be downloaded from another host).
Don't forget to set up authorization by keys, for maximum comfort.
Now put more interesting stuff on the script in replacement of hostname, even entire functions, etc, and stuff.
hosta> cat myScript.sh
[ $1 == "client" ] && hostname || cat $0 | ssh $1 /bin/sh -s client
hosta> myScript.sh hostb
Only useful for really flakey connections (but im stuck with one for now). Though if youre in this situation ive found this to be a good way to run autossh and it does a pretty good job of detecting when the session is down and restarting. Combined with the -t and screen commands this pops you back into your working session lickety split w/ as few headaches as possible.
And if autossh is a bit slow at detecting the downed ssh connection, just run this in another tab/terminal window to notify autossh that it should drop it and start over. Basically for when polling is too slow.
kill -SIGUSR1 `pgrep autossh`
this string of commands will release your dhcp address, change your mac address, generate a new random hostname and then get a new dhcp lease.
Quick shortcut if you know the hostname and want to save yourself one step for looking up the IP address separately.
I've seen some versions of hostname that don't have the -i option, so this may not work everywhere. When available, it's a better alternative than using ifconfig and wasting eyeball muscle to search for the address, and it's definitely simpler than using awk/sed.
I used this to confirm an upgrade to an SSH daemon was successful
changes the PS1 to something better than default.
[username.hostname.last-2-digits-of-ip] (current directory)
Just run the command, type your password, and that's the last time you need to enter your password for that server.
This assumes that the server supports publickey authentication. Also, the permissions on your home dir are 755, and the permissions on your .ssh dir are 700 (local and remote).