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:
The example command deletes all aliases for network interface 'em0' assuming that the aliases have netmask of 255.255.255.255 and the master IP has some other netmask (such as 255.255.255.0). See here -> http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/ for more on the rationale of this command.
works on Linux and Solaris. I think it will work on nearly all *nix-es
The curl command retrieve the HTML text containing the IP address. The grep command picks out the IP address from that HTML text.
The socket.gethostname() call returns the host name of the computer. The socket.gethostbyname_ex() call returns a list of three items: The host name, the list of aliases for this host, and a list of IP addresses. Recall that Python?s array starts with index 0, the socket.gethostbyname_ex(?) expression refers to the list of IP addresses. Finally, the print statement prints out the IP addresses, one per line.
Basically an improvement on an earlier ethtool command line.
The report mode of mtr produces a text formated result of the mtr run using the number of ping cycles stated by the command. This text file could then be attached to an email with ease.
I use this also without the ">" portion when writing email from within mutt using VI from the command mode with ":r !mtr --report --report-cycles 10
Replace "en1" with your network interface (on OS X, usually en0, en1, eth0, etc..)
Waiting for your server to finish rebooting? Issue the command above and you will hear a beep when it comes online. The -i 60 flag tells ping to wait for 60 seconds between ping, putting less strain on your system. Vary it to your need. The -a flag tells ping to include an audible bell in the output when a package is received (that is, when your server comes online).
On Linux and Mac systems (I have not tested with other Unix systems), the ping command will keep on pinging until the user interrupts it with Ctrl+C. On Windows system, ping will execute for a number of times then quit. The -c flag on Linux and Mac will make this happen
To connect to the shell run:
nc server.example.org 2000
Redirect the local port 2000 to the remote port 3000. The same but UDP:
nc -u -l -p 2000 -c "nc -u example.org 3000"
It may be used to "convert" TCP client to UDP server (or viceversa):
nc -l -p 2000 -c "nc -u example.org 3000"
Where < target > may be a single IP, a hostname or a subnet
-sS TCP SYN scanning (also known as half-open, or stealth scanning)
-P0 option allows you to switch off ICMP pings.
-sV option enables version detection
-O flag attempt to identify the remote operating system
-A option enables both OS fingerprinting and version detection
-v use -v twice for more verbosity.
nmap -sS -P0 -A -v < target >
-nohttpd don't run mini-httpd if VNC java applet is found
-name change the name of the desktop, it's passed to xstartup script via $VNCDESKTOP, run different set of apps acording the name.
-depth pixel depth in bits of the desktop, default is 16
-geometry size of the desktop, default is 1024x768