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 /<directory_path> |
Change Directory to Previous | cd .. |
Create Directory | mkdir <directory_name> |
Create Directory with Parent | mkdir -p <parent_directory_name>/<directory_name> |
Remove Directory | rm -r <directory_name> |
Remove Directory without prompt | rm -rf <directory_name> |
Remove empty Directory | rmdir <directory_name> |
Copy Directory | cp -r <directory_name> <destination_path> |
Move Directory | mv <directory_name> <destination_path> |
Name | Command |
---|---|
Search files in a directory | find <directory_name> -name <file_name_pattern> |
Search files in a directory with case-insensitive | find <directory_name> -iname <file_name_pattern> |
Search files in a directory and execute command on it | find <directory_name> -name <file_name_pattern> -exec <command> |
Search text in file | grep <text> <file_name> |
Search text in file with line numbers | grep -n <text> <file_name> |
Search text in file with case-insensitive | grep -i <text> <file_name> |
Search text in file for all patterns given | grep -e <text> <file_name> |
Search multiple text with case-insensitive and all pattern given | grep -ie <text1> <file_name> -ie <text2> <file_name> -ie <text3> <file_name> -ie <textn> <file_name> |
Search file for any lines that don't include the content | grep -v '<content_pattern>' <file_name> |
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 <file_name> |
Create a file with content | cat <<EOF > <file_name>#!/bin/bash <content> EOF |
Create an empty file | touch <file_name> |
Remove file | rm <file_name> |
Remove file without prompt | rm -f <file_name> |
Copy file | cp <file_name> <destination_path> |
Move file | mv <file_name> <destination_path> |
Show first n lines of file | head -n <file_name> |
Show last n lines of file | tail -n <file_name> |
Keep showing last 10 lines of file | tail -f <file_name> |
Show total line in a file | cat <file_name> | 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 <file_name> | less |
Create symbolic link to source file in current directory | ln -s <file_name> |
Create symbolic link to source file in directory | ln -s <file_name> |
Extract .tar.gz file | tar -zxvf <file_name> |
See the differences between files | diff <file_a> <file_b> |
Name | Command |
---|---|
Change file permission with permission number | chmod 755 <file_name> |
Change directory permission with permission number | chmod -R 755 <directory_name> |
Change directory permission with letters | chmod -R u+rw,g+r,o+x <directory_name> |
Change file owner | chown <file_name> |
Change file owner with user's login group | chown : <file_name> |
Change directory and its content owner recursively | chown -R <directory_name> |
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 <process_id> ... |
Lists signal | kill -l |
Kill all processes with specifies name | pkill <process_name> |
Kill all processes with case-insensitive | pkill -i <process_name> |
Kill specific running command | pkill -f <running_command_pattern> |
Kill all processes with specific signal | pkill --signal <signal> <process_name> |
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 |
---|---|
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 | <command1> || <command2> |
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