commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
-R, -r, --recursive
Read all files under each directory, recursively; this is equivalent to the -d recurse option.
I must monitorize a couple of ftp servers every morning WITHOUT a port-scanner
Instead of ftp'ing on 100 ftp servers manually to test their status I use this loop.
It might be adaptable to other services, however it may require a 'logout' string instead of 'quit'.
The file ftps.txt contains the full list of ftp servers to monitorize.
Recursive grep through directory for file.
no loop, only one call of grep, scrollable ("less is more", more or less...)
This command toggles the touchpad on and off, when it's on, the right side scroll strip (annoying) and the tap-clicking are disabled, you can change this by changing occurances of 2 in the command to 0. this whole command can then be given a keyboard shortcut so that the touchpad is disableable without using a special fn key (which linux doesn't recognize on some computers) or a seperate button.
Somewhat shorter version.
Might be able to do it in less steps with xmlstarlet, although whether that would end up being shorter overall I don't know - xmlstarlet syntax confuses the heck out of me.
Prompts for your password, or if you're a bit mental you can add your password into the command itself in the format "-u user:password".
if firefox is running the database is locked, so you need to copy the places.sqlite file temporarily somewhere to be able to query it...
Will find all files containing "sample" in the current directory and in the directories below.
This is very similar to the first example except that it employs the 'exec' argument of the find command rather than piping the result to xargs. The second example is nice and tidy but different *NIXs may not have as capable a grep command.
This command will find all files recursively containing the phrase entered, represented here by "searchphrase". This particular command searches in all php files, but you could change that to just be html files or just log files etc.
The '[r]' is to avoid grep from grepping itself. (interchange 'r' by the appropriate letter)
Here is an example that I use a lot (as root or halt will not work):
while (ps -ef | grep [w]get); do sleep 10; done; sleep 60; halt
I add the 'sleep 60' command just in case something went wrong; so that I have time to cancel.
Very useful if you are going to bed while downloading something and do not want your computer running all night.
Whenever you compile a new kernel, there are always new modules. The best way to make sure you have the correct modules loaded when you boot is to add all your modules in the modules.autoload file (they will be commented) and uncomment all those modules you need.
Also a good way to keep track of the available modules in your system.
For other distros you may have to change the name of the file to /etc/modprobe.conf
Adapted using your usefull comments !
A way not so simple but functional for print the command for the process that's listening a specific port.
I got the pid from lsof because I think it's more portable but can be used netstat
My old Solaris server does not have lsof, so I have to use pfiles.
Shows how many Windows and Linux devices are on your network.
May add support for others, but that's all that are on my network right now.
If you don't have nl on your system, this achieves a similar effect, the default behavior in nl is to not number blank lines, but this does.
Can use lsof, but since it's not part of the base OS, it's not always available.
Get the line containing "inet addr:" and the line before that, get down to only the first line, and then get the first word on that line, which should be the interface.
Usage: flight_status airline_code flight_number (optional)_offset_of_departure_date_from_today
So for instance, to track a flight which departed yesterday, the optional 3rd parameter should have a value of -1.
flight_status ua 3655 -1
Departure: San Francisco, CA (SFO)
Scheduled: 6:30 AM, Jan 3
Takeoff: 7:18 AM, Jan 3
Term-Gate: Term 1 - 32A
Arrival: Newark, NJ (EWR)
Scheduled: 2:55 PM, Jan 3
At Gate: 3:42 PM, Jan 3
Term-Gate: Term C - C131
html2text needs to be installed for this command. only tested on ubuntu 9.10