Created
November 20, 2011 08:54
-
-
Save huyttq/1380019 to your computer and use it in GitHub Desktop.
Useful bash commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
History: Ctrl + r | |
Find: find /home/user -name abc.txt | |
Pipeline: vi `find /home/user -name abc.txt` | |
Ctrl-x, Ctrl-e will bring up an $EDITOR containing whatever is currently entered into the prompt. (opposed to editing last command actually entered) | |
Managing remote systems and trying to figure out what hardware you're on and whether it's healthy or not: dmidecode | |
Repeat last command with "sudo" prepended: sudo !! | |
Execute <command> with the argument to your previous command: <command> !$ / !* for get all args. | |
Show all connections with -i: lsof -i (:port_number) | |
Only TCP: lsof -iTCP | |
For a specific host: lsof [email protected] | |
Pointing to a file shows what's interacting with that file: lsof /var/log/messages | |
The -p switch lets you see what a given process ID has open, which is good for learning more about unknown processes: lsof -p 10075. | |
Using -a allows you to combine search terms | |
You can also use the -t with -u to kill everything a user has open: kill -9 `lsof -t -u moviemasher` | |
Pushd pushes a directory onto a stack and switches to it. Popd removes the current directory from the stack and changes to the previous one: pushd/popd | |
Use it all the time to watch for incoming connections on a certain port: watch -d -n 1 "netstat -an | grep :8080" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment