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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
Yeah, there are many ways to do that.
Doing with sed by using a for loop is my favourite, because these are two basic things in all *nix environments. Sed by default does not allow to save the output in the same files so we'll use mv to do that in batch along with the sed.
A ping flood is a simple DoS attack where the attacker overwhelms the victim with ICMP Echo Request (ping) packets. It only succeeds if the attacker has more bandwidth than the victim (for instance an attacker with a DSL line and the victim on a dial-up modem).
In this command replace 192.168.1.100 with victim IP address.
Courtesy of LifeHacker.com (http://lifehacker.com/5625725/open-the-gnome-applications-menu-with-the-windows-key)
grep 'HOME.*' data.txt | awk '{print $2}' | awk '{FS="/"}{print $NF}'
OR
awk '/HOME/ {print $2}' data.txt | awk -F'/' '{print $NF}'
In this example, we are having a text file that is having several entries like:
---
c1 c2 c3 c4
this is some data
HOME /dir1/dir2/.../dirN/somefile1.xml
HOME /dir1/dir2/somefile2.xml
some more data
---
for lines starting with HOME, we are extracting the second field that is a 'file path with file name', and from that we need to get the filename only and ignore the slash delimited path.
The output would be:
somefile1.xml
somefile2.xml
(In case you give a -ive - pls give the reasons as well and enlighten the souls :-) )
During this operation :
# mv Joomla_1.5.10-Stable-Full_Package.zip /var/www/joomla/
I invoke /var/www/joomla/ as last command argument. To change in this directory I can use
# cd !$
So I go to
hob:/var/www/joomla#
Should do exactly the same - compress every file in the current directory. You can even use it recursively:
gzip -r .
Linux : these script enable you to edit multiple files and remove exact phrase from multiple files
grep -sq "" filename && command
grep can be used in combination with && to run a command if a file exists.
* ps -ef # list running processes
* grep string
* pull the process names from 8th field
* cut and delimiter '/'
* print 4th field
* get rid of trailing grep
* for loop killall -9 $i which is the process name
bvi is your vi for binary editing. If your system does not have it, you can get it from
Its very useful when you do not have control over name servers and need to check DNS configuration directly, right after change. You will not need to wait for DNS propagation to verify if all records were configured properly by vendors of name servers.
It suspends to RAM: you always need your batteries for the RAM but it saves time as there is no need to slowly archive everything on your hard disk.
It works fine with me but if anyone has a nicer way, please contribute.
-s
Make a signature.
-e
Encrypt data.
-r
Encrypt for user id name.
That's useful when you're doing some web scraping http://en.wikipedia.org/wiki/Web_scraping and you're trying to test your possibly fake user-agent.