Skip to main content

Command Palette

Search for a command to run...

πŸš€ Day 14: Ultimate Linux & Git-GitHub Cheat Sheet for DevOps Engineers πŸš€

Published
β€’7 min read
C

πŸ‘¨β€πŸ’» Chintamani Tare | DevOps Enthusiast & Linux Advocate 🌐 I'm a passionate DevOps engineer with a solid foundation in Linux system administration. With a deep interest in automation, cloud technologies, and CI/CD pipelines, I love simplifying complex tasks and building scalable infrastructure. Whether it's scripting in Bash, managing servers with Ansible, or deploying applications with Docker and Kubernetes, I'm always eager to explore the latest tools and practices in the DevOps space.

Congratulations on reaching Day 14 of your DevOps journey! πŸŽ‰ You've been learning Linux and Git-GitHub, two critical skills for any DevOps engineer. Now, it's time to consolidate all that knowledge into an awesome cheat sheet that you can reference anytime.

Let’s create a well-organized, easy-to-follow, and comprehensive cheat sheet with all the important commands you’ve learned so far. This will not only help you in the future, but will also be a great resource for the DevOps community! Let’s dive in. πŸ˜‰


🌟 Linux Cheat Sheet 🌟

Linux is the backbone of most cloud and DevOps environments. Mastering basic and advanced Linux commands is essential for system administration, scripting, and automation. Below is your go-to cheat sheet with all the Linux commands from basic to advanced.

🐧 Basic Linux Commands for Beginners

CommandDescription
pwdPrints the current directory path you're working in.
lsLists files and directories in the current directory. Add -l for a detailed view.
cd [directory]Changes the current directory to the one specified.
mkdir [folder_name]Creates a new directory.
rmdir [folder_name]Removes an empty directory.
rm [file_name]Removes a file. Use rm -r [folder_name] to remove directories recursively.
touch [file_name]Creates a new, empty file.
cat [file_name]Displays the content of a file.
echo "[text]"Prints text to the terminal or writes it to a file (e.g., echo "Hello" > file.txt).
cp [source] [destination]Copies a file or directory from source to destination.
mv [source] [destination]Moves or renames a file or directory.
man [command]Opens the manual for a command. Use this to learn about any command's options.
clearClears the terminal screen.

πŸ” File Permissions & Users

File permissions are crucial when working on shared systems or production servers. Understanding user roles and how to control access is key.

CommandDescription
chmod [permissions] [file_name]Changes file permissions (e.g., chmod 755 file.txt gives read/write/execute access to the owner and read/execute access to others).
chown [user]:[group] [file_name]Changes the owner and/or group of a file.
sudo [command]Executes a command as a superuser. Use with caution!
useradd [username]Adds a new user to the system.
passwd [username]Sets or changes the password for a user.
whoamiDisplays the current logged-in user.
su [username]Switches to another user.

βš™οΈ System Management Commands

These commands will help you monitor and manage your system resources, processes, and services.

CommandDescription
psDisplays the currently running processes.
topDisplays real-time system resource usage (like CPU and memory).
htopAn improved version of top, providing a cleaner interface for process management.
df -hShows disk space usage in a human-readable format.
du -sh [directory]Shows the size of a directory or file.
free -hDisplays memory (RAM) usage in a human-readable format.
uptimeShows how long the system has been running.
rebootReboots the system.
shutdown nowShuts down the system immediately.
kill [PID]Terminates a process by its Process ID (PID).

πŸ–§ Networking in Linux

As a DevOps engineer, networking is a critical skill. Here are commands that help you configure and troubleshoot network issues.

CommandDescription
ping [host]Sends ICMP echo requests to check the connectivity with another machine or server.
ifconfigDisplays network interface configurations.
ip aAnother way to view IP address information, commonly used in newer Linux distributions.
netstat -tulnLists all active network connections.
curl [URL]Transfers data from or to a server (used to interact with APIs, download files, etc.).
wget [URL]Downloads files from the web.
nslookup [domain]Queries the DNS to get information about a domain or IP address.

🌟 Git & GitHub Cheat Sheet 🌟

Git and GitHub are essential for version control and collaboration in any DevOps environment. Here’s your cheat sheet for basic to advanced Git commands.

πŸš€ Basic Git Commands

CommandDescription
git initInitializes a new Git repository.
git clone [URL]Clones a repository from GitHub or another location to your local machine.
git add [file_name]Adds changes in the working directory to the staging area.
git commit -m "[message]"Commits changes with a message describing the update.
git statusShows the current status of your repository, including staged and unstaged changes.
git logDisplays the commit history. Use git log --oneline for a simpler view.
git diffShows differences between your working directory and the last commit.

🌿 Branching & Merging

Branches allow you to isolate your work. Here’s how to create, switch, and merge branches.

CommandDescription
git branchLists all branches in your repository.
git branch [branch_name]Creates a new branch.
git checkout [branch_name]Switches to the specified branch.
git merge [branch_name]Merges the specified branch into the current branch.
git branch -d [branch_name]Deletes the specified branch.
git branch -m [old_name] [new_name]Renames a branch.

πŸ›  Undoing Changes in Git

Sometimes mistakes happen. Here’s how to undo changes safely.

CommandDescription
git reset --soft HEAD~1Moves the current branch pointer back by one commit, keeping the changes in your working directory.
git reset --hard HEAD~1Moves the current branch pointer back by one commit, and discards all changes.
git revert [commit_hash]Reverts the changes made by a specific commit (use this when you want to undo changes in a shared repository).
git stashTemporarily saves your uncommitted changes.
git stash applyRe-applies your stashed changes.

🌍 Working with Remote Repositories (GitHub)

To collaborate with others, you’ll need to interact with remote repositories like those on GitHub.

CommandDescription
git remote add origin [URL]Adds a remote repository (usually GitHub).
git push [remote] [branch]Pushes your local changes to the specified remote branch.
git pull [remote] [branch]Fetches and merges changes from the remote repository.
git fetchFetches changes from the remote repository without merging.

✨ Advanced Git Commands

For advanced users, here are some powerful commands to keep your repository clean and your history organized.

CommandDescription
git rebase [branch_name]Re-applies your commits on top of another branch’s history. Useful for keeping your branch up-to-date without creating a merge commit.
git cherry-pick [commit_hash]Applies the changes introduced by an existing commit to your current branch.
git reflogShows a history of all your Git operations, including branch switches, merges, and resets.
git bisectFinds which commit introduced a bug by performing a binary search.

πŸ“ Conclusion

Mastering Linux and Git-GitHub commands is fundamental for any DevOps engineer. Whether you’re building pipelines, deploying applications, or collaborating on open-source projects, having these commands at your fingertips will make your workflow smoother and more efficient.

By using this cheat sheet, you can:

  • Automate system administration tasks using Linux.

  • Manage source code efficiently with Git.

  • Collaborate and deploy code to GitHub with ease.

Happy learning and coding! πŸš€

#LinuxCheatSheet #GitCheatSheet #DevOps #DevOpsTools #LinuxCommands #GitHubTips #GitCommands #SystemAdministration #CloudComputing #90DaysOfDevOps

A

informative

More from this blog

C

chintamani's blogs

18 posts