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:
This command will give you the same list of files as "find /etc/ -name '*killall' | xargs ls -l".
In a simpler format just do 'ls /etc/**/file'.
It uses shell globbing, so it will also work with other commands, like "cp /etc/**/sshd sshd_backup".
Using the sed -i (inline), you can replace the beginning of the first line of a file without redirecting the output to a temporary location.
Description is moved to "Sample output" because the html sanitizer for commandlinefu breaks the examples..
SSH can be controlled trough an ~ escape sequence. Example, to terminate the current ssh connection, type a newline, then the ~ character, and last a . character.
This is useful eg when an ssh connection hangs after you reboot a machine and the connection hangs.
I submitted a command like this without $0 if $BASH_SOURCE is unset. Therefor, it did only work when using ./script, not using 'sh script'. This version handles both, and will set $mydir in a script to the current working directory. It also works on linux, osx and probably bsd.
I think this is the cleanest way of getting the current working directory of a script. It also works on osx, Linux, and probably bsd as well..
Makes bash-4.x like zsh. Automatic cd into a directory if a command with that name doesnt exists. Ready for your ~/.bashrc file
~ is the ssh control character. If you type it after a newline, you can example force close the ssh session.
, ~, then .
If you want more info, type ~? when you are connecting using ssh.
Very useful to kill of any hanging ssh sessions when nothing else works.
This little function will smarten 'cd'. If you try to cd into a file (which I guess we all have done), it cd's into the directory of that file instead.
I had to use nesten if's, to get cd to still work with 'cd' (to get to $HOME), 'cd -' (to get to last directory), and 'cd foo\ bar'.
Check if you have 64bit by looking for "lm" in cpuinfo. lm stands for "long mem". This can also be used without being root.
Not really an easier solution. But an example using && for (if last command returned 0). You can use || for (if last command returned other than 0)..
You are stuck with testing a tcp port using telnet, and must kill the telnet session from another terminal... Or, press ctrl+5 and write close/quit to force the current connection to close..
For those of us that still uses lynx :)
Using our beloved wget
Mostly for Norwegians, but easily adoptable to others. Very handy if you are brainstorming for a new domainname.
Will only display the available ones..
You can usually do this better with dig, but if you dont have dig, or the TLD only have an online service to check with, this will be usefull..