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:
This is how I typically grep. -R recurse into subdirectories, -n show line numbers of matches, -i ignore case, -s suppress "doesn't exist" and "can't read" messages, -I ignore binary files (technically, process them as having no matches, important for showing inverted results with -v)
I have grep aliased to "grep --color=auto" as well, but that's a matter of formatting not function.
After executing this, click on a window you want to track X Window events in.
Explaination: "xev will track events in the window with the following -id, which we get by greping window information obtained by xwininfo"
for one line per process:
ss -p | cat
for established sockets only:
ss -p | grep STA
for just process names:
ss -p | cut -f2 -sd\"
ss -p | grep STA | cut -f2 -d\"
show only the name of the apps that are using internet
Show apps that use internet connection at the moment.
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details, though it will not work showing only unique processes.
This version will work with other languages such as Spanish and Portuguese, if the word for "ESTABLISHED" still contain the fragment "STAB"(e.g. "ESTABELECIDO")
This corrects duplicate output from the previous command.
Can be used to discover what programms create internet traffic. Skip the part after awk to get more details.
Has anyone an idea why the uniq doesn't work propperly here (see sample output)?
Handles everything except octets with 255. Ran through ip generator with variable octet lengths.
This obey that you don't match any broadcast or network addresses and stay between 188.8.131.52 - 254.254.254.254
regex to match an ip
Make sure that find does not touch anything other than regular files, and handles non-standard characters in filenames while passing to xargs.
needs no GNU tools, as far as I see it
saves one command. Needs GNU grep though :-(
The grep switches eliminate the need for awk and sed. Modifying vim with -p will show all files in separate tabs, -o in separate vim windows. Just wish it didn't hose my terminal once I exit vim!!
This will drop you into vim to edit all files that contain your grep string.
This will allow you to watch as matches occur in real-time. To filter out only ACCEPT, DROP, LOG..etc, then run the following command: watch 'iptables -nvL | grep -v "0 0" && grep "ACCEPT"' The -v is used to do an inverted filter. ie. NOT "0 0"
Check which files are opened by Firefox then sort by largest size (in MB). You can see all files opened by just replacing grep to "/". Useful if you'd like to debug and check which extensions or files are taking too much memory resources in Firefox.
Best to put it in a file somewhere in your path. (I call the file spath)
IFS=:; find $PATH | grep $1
Usage: $ spath php
-exec works better and faster then using a pipe
doesn't do case-insensitive filenames like iname but otherwise likely to be faster
to omit "grep -v", put some brackets around a single character