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:
Often times you run a command in the terminal and you don't realize it's going to take forever. You can open a new terminal, but you lose the local history of the suspended one. You can stop the running command using , but that may produce undesirable side-effects. suspends the job, and (assuming you have no other jobs running in the background) %1 resumes it. Appending & tells it to run in the background.
You now have a job running concurrently with your terminal. Note this will still print any output to the same terminal you're working on.
Tested on zsh and bash.
Cleans all files in /tmp that have been accessed at least 2 days ago.
Unpack and build a WebLogic 9 or 10 domain
extension to tali713's random fact generator. It takes the output & sends it to notify-osd. Display time is proportional to the lengh of the fact.
Though without infinite time and knowledge of how the site will be designed in the future this may stop working, it still will serve as a simple straight forward starting point.
This uses the observation that the only item marked as strong on the page is the single logical line that includes the italicized fact.
If future revisions of the page show failure, or intermittent failure, one may simply alter the above to read.
wget randomfunfacts.com -O - 2>/dev/null | tee lastfact | grep \<strong\> | sed "s;^.*<i>\(.*\)</i>.*$;\1;"
The file lastfact, can then be examined whenever the command fails.
Connect-back shell using Bash built-ins. Useful in a web app penetration test, if it's the case of a locked down environment, without the need for file uploads or a writable directory.
/dev/tcp and /dev/udb redirects must be enabled at compile time in Bash.
Most Linux distros enable this feature by default but at least Debian is known to disable it.
Thanks to comment if that works or not...
If you have already typed that snippet or you know you already have IO::Interface::Simple perl module, you can type only the last command :
perl -e 'use IO::Interface::Simple; my $ip=IO::Interface::Simple->new($ARGV); print $ip->address,$/;' <INTERFACE>
( The first perl command will install the module if it's not there already... )
Exit with error if script is not run in a terminal
If your script needs to be run in a terminal, this line at the top will stop it running if you absent-mindedly double-click the icon, perhaps intending to edit it. (Of course this won't help with scripts that run in the background.)
I often need to cd where no man wants to go (i.e. long path). by enabling the shell option cdable_vars, I can tell cd to assume the destination is the name of a variable.
Initialized empty Git repository in /home/user/path/to/dir/.git/
Useful in while and if statements
if not grep string filename; then echo string not found; exit 1; fi
Remove everything in current directory except files starting with "ca".
Works in all shells. Does not require a test. Handles like an assertion.
Also searches for aliases and shell builtins
Searches in order of the directories of $PATH. Stops after finding the entry; looks for only that fileName. Works in Bourne, Korn, Bash and Z shells.
Manages everything through one sed script instead of pipes of greps and awks. Quoting of shell variables is generally easier within a sed script.
rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits. rkhunter is a shell script which carries out various checks on the local system to try and detect known rootkits and malware. It also performs checks to see if commands have been modified, if the system startup files have been modified, and various checks on the network interfaces, including checks for listening applications.
chkrootkit is a tool to locally check for signs of a rootkit,Get it from the website http://www.chkrootkit.org
To get information at your fingertips about Apache compilation.
Like many other thing in Linux ,you can see the same thing in different way.
This is a handy way to find which modules are loaded with Apache web server.