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:
rpm, sometimes, is not wildcard friendly. To search files installed from package this could be useful.
change PACKAGENAME to any package do you want to search
This command gives a model information of a computer. Also useful in determining the host is a VM machine or actual physical machine.
Useful in scripts while you just need an IP address in a variable.
I've had this as mute.sh in my ~/bin/ for some time.
greps for search word in directory and below (defaults to cd).
-i case insensitive
-n shows line number
-H shows file name
kills all pids matching the search term of "PROCESS". Be careful what you wish for :)
Note that the file at the given path will have the contents of the (still) deleted file, but it is a new file with a new node number; in other words, this restores the data, but it does not actually "undelete" the old file.
I posted a function declaration encapsulating this functionality to http://www.reddit.com/r/programming/comments/7yx6f/how_to_undelete_any_open_deleted_file_in_linux/c07sqwe (please excuse the crap formatting).
If the 'lm' flag is present, then the CPU is 64-bit.
If no output, then CPU is 32-bit.
From 'man netstat'
"netstat -i | -I interface [-abdnt] [-f address_family] [-M core] [-N system]
Show the state of all network interfaces or a single interface
which have been auto-configured (interfaces statically configured
into a system, but not located at boot time are not shown). An
asterisk (``*'') after an interface name indicates that the
interface is ``down''. If -a is also present, multicast
addresses currently in use are shown for each Ethernet interface
and for each IP interface address. Multicast addresses are shown
on separate lines following the interface address with which they
are associated. If -b is also present, show the number of bytes
in and out. If -d is also present, show the number of dropped
packets. If -t is also present, show the contents of watchdog
This is a nice way to kill processes.. the example here is for firefox!!! substitute firefox for whatever the process name is...
To save the result, redirect the output to another file.
grep -v "^$" file1 > file2
Useful to check DDoS attacks on servers.
Yet another ps grep function, but this one includes the column headings.
My variant on this common function. Some highlights:
Allows you to override the default ps args of "aux"
Uses bracket trick to omit the grep process itself without having to use a second grep
Always prints the correct header row of ps output
Limitations: Ugly ps error output if you forget to quote your multi word grep argument