few more Linux commands and Git Commands
Table of contents
As DevOps engineers, proficiency in Linux and Git-GitHub is essential for managing and deploying code efficiently. With the vast array of commands and functionalities these tools offer, having a well-organized cheat-sheet can be a game-changer. Today, I’m sharing a comprehensive cheat-sheet covering essential Linux commands, Git commands, and GitHub tips that every DevOps professional should have in their toolkit.
Linux Commands Cheat-Sheet File
Directory Management
- ls List directory contents.
ls
- cd [directory] Change the current directory.
cd /path/to/directory
- pwd Print the current working directory.
pwd
- mkdir [directory] Create a new directory.
mkdir new-directory
- rmdir [directory] Remove an empty directory.
rmdir old-directory
- rm [file] Remove a file.
rm file-to-remove.txt
- cp [source] [destination] Copy files or directories.
cp source-file.txt destination-file.txt
- mv [source] [destination] Move or rename files or directories.
mv old-name.txt new-name.txt
- touch [file] Create an empty file or update the timestamp of an existing file.
touch new-file.txt
File Viewing & Editing
- cat [file] Concatenate and display file content.
cat file-to-view.txt
- less [file] View file content page by page.
less file-to-view.txt
- head [file] Display the first 10 lines of a file.
head file-to-view.txt
- tail [file] Display the last 10 lines of a file.
tail file-to-view.txt
- nano [file] Edit a file using the Nano text editor.
nano file-to-edit.txt
- vim [file] Edit a file using the Vim text editor.
vim file-to-edit.txt
Permissions & Ownership
- chmod [permissions] [file] Change file permissions.
chmod 755 file-to-change-permissions.txt
- chown [owner]:[group] [file] Change file owner and group.
chown user:group file-to-change-owner.txt
- ls -l List files with detailed information including permissions and ownership.
ls -l
System Monitoring & Management
- top Display active processes.
top
- ps aux List all running processes.
ps aux
- df -h Display disk space usage.
df -h
- du -sh [directory] Display disk usage of a directory.
du -sh /path/to/directory
- free -h Display memory usage.
free -h
- uptime Show system uptime and load averages.
uptime
Git Commands Cheat-Sheet Basic Commands
- git init Initialize a new Git repository.
git init
- git clone [url] Clone a repository from a URL.
git clone https://github.com/user/repo.git
- git add [file] Add a file to the staging area.
git add file-to-add.txt
- git commit -m "[message]" Commit changes with a message.
git commit -m "Commit message"
- git status Show the status of changes.
git status
- git log Display commit history.
git log
Branching & Merging
- git branch List all branches.
git branch
- git branch [branch_name] Create a new branch.
git branch new-branch
- git checkout [branch_name] Switch to a branch.
git checkout new-branch
- git merge [branch_name] Merge a branch into the current branch.
git merge new-branch
- git rebase [branch_name] Rebase the current branch onto another branch.
git rebase new-branch
Stashing
- git stash Temporarily save changes without committing.
git stash
- git stash pop Apply stashed changes and remove them from the stash.
git stash pop
- git stash list List all stashed changes.
git stash list
- git stash drop Remove a specific stash.
git stash drop stash@{0}
- git stash clear Remove all stashes.
git stash clear
Cherry-Picking
- git cherry-pick [commit_hash] Apply a specific commit from another branch.
git cherry-pick 123abc456def
Conflict Resolution
- git status Show files with conflicts.
git status
- git diff Show differences between conflicting versions.
git diff
- git add [file] Stage resolved files for commit.
git add resolved-file.txt
GitHub Tips Cheat-Sheet Repository Management
Create a Repository Click "New" on GitHub and follow the prompts.
Fork a Repository Click "Fork" on the top-right of the repository page.
Clone a Repository Use git clone [url] to copy a repository locally.
git clone https://github.com/user/repo.git
Collaboration
Pull Requests Create a pull request to propose changes. Review and discuss before merging.
Issues Use GitHub Issues to track bugs, tasks, and feature requests.
Wiki Utilize the GitHub Wiki for project documentation. Branch Protection
Enable Branch Protection Prevent force-pushes and require pull request reviews before merging.
GitHub Actions
- Set Up CI/CD Create workflows using .github/workflows to automate build, test, and deployment processes.
Subscribe to my newsletter
Read articles from telagorla saiyadav directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
telagorla saiyadav
telagorla saiyadav
AWS DevOps Engineer with 3+ years of experience in cloud infrastructure, automation, and CI/CD pipelines. Passionate about optimizing systems and building scalable, secure solutions with tools like Terraform, Docker, and Kubernetes. AWS Certified Solutions Architect.