This cheat sheet provides quick access to essential Linux commands organized into categories like navigation, file management, search, permissions, system management, and Git/GitHub workflows. With clear descriptions, modes, and examples, users can efficiently perform tasks such as navigating directories, managing files, searching text, handling permissions, monitoring processes, and version controlling with Git. Ideal for both beginners and experienced users, this resource enhances productivity and proficiency in Linux command line operations and version control practices.
Linux Commands Cheat Sheet** 🐧
Navigation: 🗺️
cd
Usage : To change Directories
Modes :
📍
~
: Home directory.📍
..
: Previous directory.
Example:
" cd ~ " : Change to the Home Directory
" cd .. " : Change to the previous Directory
File Management: 📁
ls
- Usage : List Directory Contents.
Modes :
📍 -a
: Show hidden files
📍 -l
: Use a long listing format
Example:
" ls -a " : Lists all files, including hidden ones.
" ls -l " : Displays detailed information about files.
mkdir
Usage : Make Directory
Modes :
📍
-p
: Create parent directories if they do not exist.
Example:
" mkdir
new_folder
": Creates a new directory named "new_folder"." mkdir -p parent_folder/sub_folder ": Creates nested directories.
rm
Usage : Remove files or directories.
Modes :
📍
-r
: Recursively remove directory.📍
-f
: Force removal without confirmation.
Example:
" rm file.txt " : Deletes a file named "file.txt".
" rm -rf directory " : Removes a directory and its contents forcefully.
cp
Usage : Copy files or directories.
Modes :
📍
-r
: Copy directories recursively.📍
-u
: Update - copy only when source is newer than destination.Example:
" cp file.txt destination/ " : Copies "file.txt" to the "destination" directory.
" cp -ru source/ destination/ ": Copies newer files from source to destination.
mv
- Usage : Move or rename files or directories.
Example:
" mv file.txt new_location/ " : Moves "file.txt" to "new_location".
" mv old_name.txt new_name.txt " : Renames "old_name.txt" to "new_name.txt".
cat
Usage : Display file content.
Modes :
📍
-n
: Number all output lines.
Example:
" cat file.txt " : Displays content of "file.txt".
" cat -n file.txt " : Displays content with line numbers.
Search and Filter: 🔍
grep
Usage : Search Text.
Modes:
📍
-i
: Ignore case distinctions.📍
-v
: Invert match.
Example:
" grep "keyword" file.txt " : Searches for "keyword" in "file.txt".
" grep -i "word" file.txt " : Searches ignoring case.
Permissions and Security: 🔒
chmod
Usage : Change file permissions.
Modes :
📍
u/g/o
: User/group/others📍
+/-
: Add/remove Permission
Example:
" chmod u+x script.sh " : Adds execute permission to the owner.
" chmod go-w file.txt " : Removes write permission from group and others.
System Management: ⚙️
sudo
- Usage : Execute a command with superuser privileges.
Example:
sudo apt-get update
top
Usage : Display and manage running processes.
Modes :
📍
-u
: Display processes for a specific user.
Example:
" top " : Displays processes in real-time.
" top -u username " : Shows processes for a specific user.
df
Usage : Report file system disk space usage.
Modes :
📍
-h
: Human-readable format.
Example:
" df -h " : Displays disk space usage in a human-readable format.
" df -hT " : Shows disk space usage with filesystem type.
Downloading and Archiving: 📦
wget
- Usage : Download files from the internet.
Example:
" wget http://example.com/file.txt " : Downloads "file.txt" from the web.
" wget -O filename http://example.com/file.txt " : Saves downloaded file with a specific name.
tar
Usage : To zip or compress file handle tar archieves.
Modes :
📍
-x
: Extract files from an archieve.📍
-z
: Filter the archive through gzip.
Example:
- " tar -xvf archive.tar.gz " : Extracts files from a tarball.
" tar -czf archive.tar.gz directory/ " : Creates a gzip-compressed tarball of a directory.
Git and GitHub Commands Cheat Sheet 🚀
Version Control: 🔄
git init
Usage: Initialize a new Git repository.
Example:
git init
git clone
Usage: Clone a repository into a new directory.
Example:
git clone <repository_url>
git add
Usage: Add file contents to the index.
Example:
git add file.txt
git commit
Usage: Record changes to the repository.
Modes:
-m
: Specify commit message.
Example:
git commit -m "Commit message"
git push
Usage: Update remote refs along with associated objects.
Example:
git push origin main
git pull
Usage: Fetch from and integrate with another repository or a local branch.
Example:
git pull origin main
git branch
Usage: List, create, or delete branches.
Example:
git branch feature
git checkout
Usage: Switch branches or restore working tree files.
Example:
git checkout feature
git merge
Usage: Join two or more development histories together.
Example:
git merge feature
git log
Usage: Show commit logs.
Example:
git log
git status
Usage: Show the working tree status.
Example:
git status
git remote
Usage: Manage set of tracked repositories.
Modes:
-v
: List remote URLs.
Example:
git remote -v
This cheat sheet covers commands for Linux, Git and GitHub. providing a quick reference for revision , share and spread the knowledge! 🌟
Happy Learning 😊:)