Day 12 of 90 Days of DevOps Challenge: A Comprehensive Linux and Git Cheat-Sheet for DevOps Engineers

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

  1. ls List directory contents.
ls
  1. cd [directory] Change the current directory.
cd /path/to/directory
  1. pwd Print the current working directory.
pwd
  1. mkdir [directory] Create a new directory.
mkdir new-directory
  1. rmdir [directory] Remove an empty directory.
rmdir old-directory
  1. rm [file] Remove a file.
rm file-to-remove.txt
  1. cp [source] [destination] Copy files or directories.
cp source-file.txt destination-file.txt
  1. mv [source] [destination] Move or rename files or directories.
mv old-name.txt new-name.txt
  1. touch [file] Create an empty file or update the timestamp of an existing file.
touch new-file.txt

File Viewing & Editing

  1. cat [file] Concatenate and display file content.
cat file-to-view.txt
  1. less [file] View file content page by page.
less file-to-view.txt
  1. head [file] Display the first 10 lines of a file.
head file-to-view.txt
  1. tail [file] Display the last 10 lines of a file.
tail file-to-view.txt
  1. nano [file] Edit a file using the Nano text editor.
nano file-to-edit.txt
  1. vim [file] Edit a file using the Vim text editor.
vim file-to-edit.txt

Permissions & Ownership

  1. chmod [permissions] [file] Change file permissions.
chmod 755 file-to-change-permissions.txt
  1. chown [owner]:[group] [file] Change file owner and group.
chown user:group file-to-change-owner.txt
  1. ls -l List files with detailed information including permissions and ownership.
ls -l

System Monitoring & Management

  1. top Display active processes.
top
  1. ps aux List all running processes.
ps aux
  1. df -h Display disk space usage.
df -h
  1. du -sh [directory] Display disk usage of a directory.
du -sh /path/to/directory
  1. free -h Display memory usage.
free -h
  1. uptime Show system uptime and load averages.
uptime

Git Commands Cheat-Sheet Basic Commands

  1. git init Initialize a new Git repository.
git init
  1. git clone [url] Clone a repository from a URL.
git clone https://github.com/user/repo.git
  1. git add [file] Add a file to the staging area.
git add file-to-add.txt
  1. git commit -m "[message]" Commit changes with a message.
git commit -m "Commit message"
  1. git status Show the status of changes.
git status
  1. git log Display commit history.
git log

Branching & Merging

  1. git branch List all branches.
git branch
  1. git branch [branch_name] Create a new branch.
git branch new-branch
  1. git checkout [branch_name] Switch to a branch.
git checkout new-branch
  1. git merge [branch_name] Merge a branch into the current branch.
git merge new-branch
  1. git rebase [branch_name] Rebase the current branch onto another branch.
git rebase new-branch

Stashing

  1. git stash Temporarily save changes without committing.
git stash
  1. git stash pop Apply stashed changes and remove them from the stash.
git stash pop
  1. git stash list List all stashed changes.
git stash list
  1. git stash drop Remove a specific stash.
git stash drop stash@{0}
  1. git stash clear Remove all stashes.
git stash clear

Cherry-Picking

  1. git cherry-pick [commit_hash] Apply a specific commit from another branch.
git cherry-pick 123abc456def

Conflict Resolution

  1. git status Show files with conflicts.
git status
  1. git diff Show differences between conflicting versions.
git diff
  1. git add [file] Stage resolved files for commit.
git add resolved-file.txt

GitHub Tips Cheat-Sheet Repository Management

  1. Create a Repository Click "New" on GitHub and follow the prompts.

  2. Fork a Repository Click "Fork" on the top-right of the repository page.

  3. Clone a Repository Use git clone [url] to copy a repository locally.

git clone https://github.com/user/repo.git

Collaboration

  1. Pull Requests Create a pull request to propose changes. Review and discuss before merging.

  2. Issues Use GitHub Issues to track bugs, tasks, and feature requests.

  3. Wiki Utilize the GitHub Wiki for project documentation. Branch Protection

  4. Enable Branch Protection Prevent force-pushes and require pull request reviews before merging.

GitHub Actions

  1. Set Up CI/CD Create workflows using .github/workflows to automate build, test, and deployment processes.