DevOps Linux & Git Commands Cheat Sheet πŸš€πŸ§πŸ’» | Day 12 of 90 Days of DevOps

Ajit Fawade
3 min readJul 30, 2023

--

Photo by Kelly Sikkema on Unsplash

Hi everyone, welcome to my #90DaysOfDevOps challenge! In this blog post, I will share with you a comprehensive cheat sheet of all the Linux commands and Git commands that I have learned and used from day 1 to day 11 of my online training on DevOps. This cheat sheet will help you master the basics of Linux, Git, and GitHub

Let’s get started! 🌟

Linux Commands:

  • πŸ“‚ pwd: Prints the current working directory.
pwd

This command displays the current directory you are in.

  • πŸ“„ ls: Lists files and directories.
ls -l

This command lists all files and directories in a long format.

  • πŸ“ mkdir: Creates a new directory.
mkdir new_directory

This command creates a new directory with the specified name.

  • ⬆️ cd: Changes directory.
cd /path/to/directory

This command changes your current directory to the specified path.

  • ✏️ touch: Creates a new file.
touch new_file.txt

This command creates a new empty file with the given name.

  • πŸ“¦ cp: Copies files and directories.
cp file.txt /path/to/destination

This command copies the file or directory to the specified destination.

  • πŸ”„ mv: Moves or renames files/directories.
mv old_name.txt new_name.txt

This command renames the file or moves it to a new location.

  • πŸ—‘οΈ rm: Removes files/directories.
rm file.txt

This command deletes the specified file or directory.

  • πŸ”Ž grep: Searches for patterns in files.
grep "keyword" file.txt

This command searches for the specified keyword in the file.

  • πŸ”’ chmod: Changes file permissions.
chmod +x script.sh

This command changes the permissions of the file to allow execution.

  • ✏️ nano: Text editor for editing files.
nano file.txt

This command opens the file in the Nano text editor for editing.

  • πŸ‘€ useradd: Adds a new user to the system.
useradd john

This command creates a new user with the given username.

  • πŸ‘€ userdel: Deletes a user from the system.
userdel john

This command deletes the user with the specified username.

  • πŸ‘₯ groupadd: Adds a new group to the system.
groupadd developers

This command creates a new group with the given name.

  • πŸ‘₯ groupdel: Deletes a group from the system.
groupdel developers

This command deletes the group with the specified name.

Git Commands:

  • 🏁 git init: Initializes a new Git repository.
git init

This command creates a new Git repository in the current directory.

  • πŸ” git status: Shows the status of the working tree and the staging area.
git status

This command shows which files are modified, staged, untracked, etc.

  • βž• git add: Adds files to the staging area.
git add file.txt

This command adds the specified file to the staging area for the next commit.

  • πŸ’Ύ git commit: Commits changes to the repository.
git commit -m "Added new feature"

This command commits the staged changes with the given commit message.

  • πŸ”„ git checkout: Switches branches or restores files from a branch.
git checkout feature_branch

This command switches to the specified branch.

  • πŸ—‚οΈ git branch: Lists, creates, or deletes branches.
git branch -d feature_branch

This command deletes the specified branch.

  • πŸš€ git push: Pushes local changes to a remote repository.
git push origin master

This command pushes the local changes to the β€œmaster” branch of the remote repository.

  • πŸ”€ git merge: Merges branches.
git merge feature_branch

This command merges the specified branch into the current branch.

GitHub Commands:

  • 🌐 git clone: Clones a remote repository to your local machine.
git clone https://github.com/username/repo.git

This command clones the repository to your local machine.

  • βž• git remote add: Adds a new remote repository.
git remote add origin https://github.com/username/repo.git

This command adds the remote repository with the specified name and URL.

  • ➑️ git pull: Pulls changes from a remote repository.
git pull origin master

This command pulls the latest changes from the β€œmaster” branch of the remote repository.

And that’s it!

You now have a handy cheatsheet of all the essential Linux, Git, and GitHub commands that will support you in your DevOps journey. From managing files and directories to handling user accounts and mastering version control, these commands are fundamental for every DevOps engineer.

I hope you find this cheat sheet helpful and an excellent reference guide in your daily work.

If you have any questions, comments, or suggestions, feel free to leave them below or contact me on my πŸ‘” LinkedIn or πŸ™ GitHub profiles.

Thank you for joining me in my #90DaysOfDevOps challenge, and stay tuned for more exciting updates!

--

--

Ajit Fawade
Ajit Fawade

No responses yet