DevOps Linux & Git Commands Cheat Sheet ππ§π» | Day 12 of 90 Days of DevOps
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!