This is Day to Day Work Linux Cheatsheet for Software Engineers.
This is Day to Day Work Linux Cheatsheet for Software Engineers.
Facebook: Link
Youtube: Link
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Name | Command |
---|---|
Change Directory | cd / |
Change Directory to Previous | cd .. |
Create Directory | mkdir |
Create Directory with Parent | mkdir -p |
Remove Directory | rm -r |
Remove Directory without prompt | rm -rf |
Remove empty Directory | rmdir |
Copy Directory | cp -r |
Move Directory | mv |
Name | Command |
---|---|
Search files in a directory | find |
Search files in a directory with case-insensitive | find |
Search files in a directory and execute command on it | find <command> |
Search text in file | grep <text> |
Search text in file with line numbers | grep -n <text> |
Search text in file with case-insensitive | grep -i <text> |
Search text in file for all patterns given | grep -e <text> |
Search multiple text with case-insensitive and all pattern given | grep -ie <text1> <text2> <text3> <textn> |
Search file for any lines that don’t include the content | grep -v ‘ |
Name | Command | |
---|---|---|
Send stdout of cmd1 to cmd2 | cmd1 `\ | ` cmd2 |
Send stderr of cmd1 to cmd2 | cmd1 `\ | &` cmd2 |
Name | Command | |
---|---|---|
Show content of the file | cat |
|
Create a file with content | cat <<EOF > #!/bin/bash <content> EOF |
|
Create an empty file | touch |
|
Remove file | rm |
|
Remove file without prompt | rm -f |
|
Copy file | cp |
|
Move file | mv |
|
Show first n lines of file | head -n |
|
Show last n lines of file | tail -n |
|
Keep showing last 10 lines of file | tail -f |
|
Show total line in a file | cat |
wc -l |
List files in current directory | ls | |
List files, hidden files in current directory | ls -a | |
List files in current directory with their permissions and sizes | ls -l | |
List files in current directory with their permissions, sizes, units | ls -lh | |
Paginate the content of file | cat |
` less |
Create symbolic link to source file in current directory | ln -s |
|
Create symbolic link to source file in directory | ln -s |
|
Extract .tar.gz file | tar -zxvf |
|
See the differences between files | diff |
Name | Command |
---|---|
Change file permission with permission number | chmod 755 |
Change directory permission with permission number | chmod -R 755 |
Change directory permission with letters | chmod -R u+rw,g+r,o+x |
Change file owner | chown |
Change file owner with user’s login group | chown |
Change directory and its content owner recursively | chown -R |
Name | Command |
---|---|
4 | read (r) |
2 | write (w) |
1 | execute (x) |
Name | Command |
---|---|
Shows processes for the current shell | ps |
View all the running processes | ps -A or ps -e |
View all processes associated with the terminal | ps -a |
View all processes associated with the terminal and show user | ps -aux |
Kill specific process id | kill -SIGTERM |
Lists signal | kill -l |
Kill all processes with specifies name | pkill |
Kill all processes with case-insensitive | pkill -i |
Kill specific running command | pkill -f |
Kill all processes with specific signal | pkill —signal <signal> |
Show dynamic real-time processes list of specific user | top -u <user> |
To understand Vim well, we need to understand Vim editing modes. Vim has 6 basic modes which are:
Name | Description | Help page |
---|---|---|
normal | For navigation and manipulation of text. This is the default mode. | :help Normal-mode |
insert | For inserting new text. | :help Insert-mode |
visual | For manipulation of text selection. | :help Visual-mode |
select | Similar to a visual mode, but with a more MS Windows-like behavior. | :help Select-mode |
command-line | For entering editor commands - like the help commands (:help), quit (:q) | :help Command-line-mode |
Ex-mode | Similar to a command-line mode but optimized for batch processing. | :help Ex-mode |
Name | Command | Example |
---|---|---|
Edit a file | vi |
![]() |
Enter an insert mode to insert new text | i | ![]() |
Insert a blank line under the current line and switch to an insert mode | o | ![]() |
Switch to an insert mode and move a cursor to the end of line (Append) | A | ![]() |
Copy the current line | yy | ![]() |
Paste copied text after the current cursor position | p | ![]() |
Delete the current line and switch to an insert mode (Change a line) | cc | ![]() |
Delete the current line and stay in an normal mode | dd | ![]() |
Delete from the current cursor position to the end of a word | dw | ![]() |
Delete before the current cursor position to the beginning of a word | db | ![]() |
Delete a character at the current cursor position and stay in a normal mode | x | ![]() |
Delete and switch to an insert mode from the current cursor postion to the end of line | C | ![]() |
Delete a character and switch to an insert mode (Substitute a character) | s | ![]() |
Move the cursor left | h | ![]() |
Move the cursor down | j | ![]() |
Move the cursor up | k | ![]() |
Move the cursor right | l | ![]() |
Go to the begining of the first line | gg | ![]() |
Go to the begining of the last line | G | ![]() |
Go to a line number | <row_number> + gg |
![]() |
Go to a column number | <column_number> + \ |
![]() |
Search keyword | / <keyword> |
![]() |
Search keyword with case-insensitive | /<keyword> \c |
![]() |
Move to the next found keyword after searching | n | ![]() |
Move to the previous found keyword after searching (invert of n) | N | ![]() |
Visual selection a character at the current cursor position | v | ![]() |
Visual selection the current line | V | ![]() |
Tab right | shift + . | ![]() |
Tab left | shift + , | ![]() |
Repeat a last change | . | ![]() |
Undo change | u | ![]() |
Redo change | ctrl + r | ![]() |
Save and quit | :wq | ![]() |
Quit (The most important Vi/Vim command) | :q | ![]() |
Name | Command |
---|---|
Show System | uname -a |
Show Mounted File System | mount |
Show System Date | date |
Show Uptime | uptime |
Show username | whoami |
Show Manual Command | man <command> |
Show History Command | history |
Name | Command |
---|---|
Stop Current Command | CTRL + c |
Sleep Program | CTRL + z |
Search History | CTRL + r |
Repeat Last Command | !! |
Run the most recent command that matches with starting character(s) of string | !<string> |
Name | Command |
---|---|
Show Environment Variables | env |
Show Value of Variable | echo \$<VariableName> |
Set Value of Variable | export \$<VariableName> = <value> |
Show Executable Search Path | \$PATH |
Show Home Directory | \$HOME |
Show Current Shell | \$SHELL |
Name | Command | ||
---|---|---|---|
Run command1 then command2 | <command1> ; <command2> |
||
Run command2 if command1 is successful | <command1> && <command2> |
||
Run command2 if command1 is not successful | ` |
\ |
Name | Command |
---|---|
Display all network interfaces and IP addresses | ifconfig -a |
Send echo requests to the target host to verify connectivity | ping <host> |
Get who is information for domain | whois <domain> |
Get DNS information for domain | dig <domain> |
Reverse lookup host | dig -x <host> |
Display name of server | hostname |
Download file | wget <file> |
Listing all listening connections ports | netstat -a |
An A-Z Index of Linux command line: Link