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:
Btrfs reports the inode numbers of files with failed checksums. Use `find` to lookup the file names of those inodes.
In a multiple PostgreSQL server environment knowing the servers version can be important. Note that psql --version returns just the local psql apps version which may not be what you want. This command dumps the PostgreSQL servers version out to one line. You may need to add more command line options to the psql command for your connection environment.
This command will use the fdisk utility to find all block devices on your system, and overwrite them with data from the /dev/urandom non-blocking random number generator.
CAUTION: This will irrevocably erase EVERY SINGLE physical block storage device visible to the fdisk utility, including plugged USB devices, RAID sets, LVM, etc.
Using "wmic get * /value" within any Cygwin shell will return lots of Win/Dos newline junk ie "^M$" at the end of found value line, two lines ("$" Unix newline) above, and three below. This makes storing and or evaluating wmic queries as variables a pain. The method i suggest strips the mentioned junk, only returns the value after "OSArchitecture=", and includes only one Unix style newline. Other methods using sed|awk|cut can only handle the output of wmic cleanly when piped or using multiple sed statements.
wmic OS get OSArchitecture /value | sed 's/\r//g;s/^M$//;/^$/d;s/.*=//'
wmic OS get OSArchitecture /value | grep -Eo '[^=]*$'
a much cleaner and slightly less costly alternative.
List the busiest scripts/files running on a cPanel server with domain showing (column $12).
IP addresses and number of connections connected to port 80.
Easiest way to obtain the busiest website list (sorted by number of process running).
Be careful, first run:
lsof | grep -i deleted | grep REG | grep -v txt
Then, give it the boot!
Actually grep can do recursive search based on file extensions.
Sort netflow packet capture by unique connections excluding source port.
for redhat systems works sometimes :S tested on dell poweredge r7+ systems
on some distro's you have to replace "BogoMIPS" with "bogomips".
Another way to view some code by keyword and basic regular expression
It find out the mic recording level at the moment of run the command and if a noise level is higher it starts to record an mp3 file. The resulting file will have only the sounds not the silences.
Connects to the last adb connection in history.
Displays memory usage for individual instances of an application that spawns multiple instances of itself. This command also works on single process applications.
This command will traverse all of the folders and subfolders under current working directory. For every file inside it, it will do a search inside the content of the file for a specific term 'what'. Then it will print a list of the lines that contain that term (and match that pattern). Each matching line will be preceded with the path and name to the file and then the line number iside taht file wehre the pattern was found. Then the actual content of the matching lien will be printed.
The output will be piped throug less, so that the user can scroll through it if it goes beyond the limits of the current display window.
Edit YYYY and MM at the beginning of the command with the year and month you want.
Note that `DD=$(printf "%02d" $d)` will pad single digit integers with a leading zero.
Substitute `echo $YYYY$MM$DD` at the end of the line with the command you want to launch, for instance
script.pl --yyyymmdd $YYYY$MM$DD
lsblk | grep mountpoint