Cheatography
https://cheatography.com
A list of useful bash/zsh shell commands
Useful Commands
|
Run the given command as the root user |
|
List the contents of a directory |
|
Change directory |
|
Concatenate files together and print them to screen ( stdout
), if only one file is given just print the file to the screen |
|
Create a file |
|
Print what other users are running |
|
Manual page viewer |
|
Manual page searcher |
|
Print the command history to the terminal |
|
Print to the terminal |
|
Print the current environment variables |
|
Display the user running the commands |
|
Shows the last time any user on the system has logged in |
|
Shows the size of all the filesystems |
Bang (!) commands
|
Run the previous command. sudo !!
is very helpful |
|
The first word of the last command |
|
The last word of the previous command. Example, mkdir /tmp/foo
, then run cd !$
to change directory to the one you've just created |
|
Run the previous command starting with foo |
|
Print the previous command starting with foo |
|
Substitute foo with bar within the previous command |
|
Same as above, runs the previous command replacing foo with bar |
|
This will search for commands starting with comm, replace foo with bar and execute the command. Can be appended with :p
to print out the command before running |
|
Will run command n in the history, replace with whatever number you want from the output of the history command. !1
will run the first command. !-1
will run the previous command, same as !!
|
|
Variable for the last argument in the previous command. |
|
Will run whatever is in the ()
as a subshell and return the result before running the rest of the command |
Hint in some shells you can hit space after the bang command and the command in full will populate
Remote Network Connections
|
Use the Secure Shell application to log into a given remote host |
|
Use the File Transfer Protocol to download/upload a file to a given host |
|
Interact with network sockets |
Web Builtins
|
Interact with files / webpages / API endpoints |
|
Download files over the network |
Processes
|
Output top running processes |
|
Send signals to the given process or stop a process |
|
|
Keyboard Shortcuts
|
Move up in the command history |
|
Move down in the command history |
|
Move the cursor left |
|
Move the cursor right |
|
Autocompletion |
|
In some shells will not save the command to the history file |
|
Move the cursor to the front of a command |
|
Move to the cursor to the end of the command |
|
Reverse search history |
|
Terminate the current running command or clear the terminal of the command about to run |
|
Copy the selected text out of the terminal window |
|
Paste into the terminal window |
|
Send the current command to the queue for one command before it re-populates the terminal |
|
Clear the terminal |
Shell Redirection Operators
|
Send the output of the command to a file |
|
Append the output of the command to a file |
|
Send Standard Error ( stderr
) to a file |
|
Send stderr
to null. In essence throw away all outputted errors |
|
Send the output of cmd1
to cmd2
|
|
|
|
Run cmd2
if cmd1
is successful |
|
Run cmd2
if cmd1
is not successful |
Networking
|
Lists the current networking interfaces and information about them like the assigned IP addresses |
|
Like ifconfig, lists the current interfaces and associated IP addresses |
|
Lists active networking sockets |
|
Opens a network socket |
Text
|
Text count |
|
Text searcher |
|
Text editor |
|
Text editor |
|
Text editor |
|
Text viewer |
|
Text viewer |
|
Text manipulator |
|
Text manipulator |
|
Text reader |
|
Text reader |
Jobs
|
Run the command in the background as a job |
|
List all running jobs |
|
Send the current running process to the background and suspend it |
|
Background job ID n |
|
Foreground job ID n |
|
Kill job ID n |
|
Send a given SIGNAL to job ID n |
|
Disown the job ID n so it will run even if the terminal exits |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets