Mastering Linux and Git-GitHub commands is essential for any DevOps engineer. This cheat sheet provides a comprehensive yet easy-to-understand overview of the most crucial commands. Let's dive in! 🌊
Linux Commands 🐧
File and Directory Management 📂
ls: List directory contents (See everything!)
ls -l: Detailed listing
ls -a: Show all files, including hidden ones
cd: Change directory
cd /path/to/directory: Navigate to a specific location.
cd ..: Move up one level (⬆️)
cd ../..: Move up two level (⬆️)
mkdir: Create a new directory ()
- mkdir new_directory: Make a new directory named 'new_directory'
rm: Remove files or directories
rm filename: Delete a file.
- rm -r directory: Remove a directory and its contents (Be careful!).
pwd: Print your current working directory (Where am I? )
vi <file_name>: for editing content in a file
File Permissions and Ownership 🔒
chmod: Change file permissions
chmod 755 filename: Set permissions for owner, group, and others.
chown: Change file ownership
- chown user:group filename: Change owner and group of the file.
Process Management 🖥️
ps: Display running processes
ps aux: Detailed view of all processes
top: Monitor processes in real-time
kill: Terminate a process
kill -9 PID: Forcefully terminate a process by its ID
Text Manipulation (🪄)
awk: Powerful text processing tool from space separated files
grep: Search for patterns in text
find: Locate files based on criteria
comm: Compare two sorted files (⚖️)
sort: Sort lines of text
Input/Output 📤📥
echo: Print text to the console
read: Read input from the user
- read -p "Prompt: " : Read with a prompt (⌨️)
User and group Management 👥
user add -m <new_user>: adding new user accounts, (-m) this flag tells useradd to create a home directory for the new user.
passwd <new_user> : to set password for new user
sudo usermod -aG <group_name> <user> : to add a user into a group with sudo command
sudo gpasswd -M <user_1> <user_2> <user_3> <group_name> : to add multiple user into a group
Git Commands
Repository Management 📁
git init: Initialise a new Git repository
git clone: Clone an existing repository from github to local
- git clone https://github.com/user/repo.git: Clone from GitHub
Branching and Merging 🌿
git branch: List, create, or delete branches
- git branch new-branch: Create a new branch named 'new-branch'
git checkout: Switch branches or restore files
git checkout new-branch: Switch to 'new-branch'
git checkout -b new-branch: Create and switch to 'new-branch'
git merge: Combine branches
git checkout main (Switch to main branch)
git merge new-branch: Merge 'new-branch' into 'main'
Committing Changes 💾
git add: Add files to the staging area
git add .: Add all changes in the current directory.
git add filename: Add a specific file.
git commit: Record changes with a message
- git commit -m "Commit message": Commit with a descriptive message.
Viewing Changes 👀
git status: See the current state of your working directory
git log --oneline: Show a history of commits
git diff: View changes between commits
Collaboration 🤝
git pull: Download changes from a remote repository
git push: Upload your changes to a remote repository
git remote add origin url: Add a remote repository
Advanced Git (✨)
git config --global user.name: Set your Git username
git config --global user.email: Set your Git email
git stash: Temporarily store uncommitted changes (⏱️)
git squash: Combine multiple commits into one (♻️)
git cherry-pick: Select and apply specific commits from
Conclusion
This cheat sheet is your go-to guide for mastering Linux and Git-GitHub commands. Whether you're managing files, editing permissions, or collaborating on code, these commands will streamline your workflow and boost your productivity.
Feel free to share your thoughts or ask questions in the comments below. If you found this guide helpful, consider sharing it with your peers!
Happy Learning!✨
#90DaysOfDevops #TrainWithShubham #Linux #Devops #Automation #git #github