Cheat Sheet for DevOps Engineers on Linux & Git Commands | #Day12 #90daysof devops
Linux Command Line Cheat Sheet
Navigation ๐
pwd
: Print current working directoryls
: List files and directoriesls -l
: Detailed list viewls -a
: Show hidden files
cd
: Change directorycd ~
: Home directorycd ..
: Parent directory
mkdir
: Create a directoryrmdir
: Remove an empty directory
Search ๐
grep
: Search for a pattern in filesgrep pattern file
: Search in a filegrep -r pattern dir
: Recursively search in a directory
find
: Search for files and directoriesfind dir -name file
: Search for a file in a directory
File System ๐
df
: Display disk space usagedu
: Display file/directory space usagedu -h
: Human-readable format
mount
: Mount a file systemumount
: Unmount a file systemln
: Create symbolic/hard linksln -s source link
: Create a symbolic link
File Permission ๐
chmod
: Change file permissionschmod ugo +/- rwx file
: Modify permissions
chown
: Change file ownershipchown user:group file
: Change ownership
Network ๐
ifconfig
orip addr
: Display network interfacesping
: Test network connectivityping
google.com
: Ping a host
netstat
orss
: Network statisticsssh
: Securely connect to a remote serverssh user@host
: Connect to a remote host
File Management ๐
cp
: Copy files/directoriescp source destination
: Copy filescp -r source_dir destination_dir
: Copy directories
mv
: Move/Rename files/directoriesmv old new
: Rename file/directory
rm
: Remove files/directoriesrm file
: Remove a filerm -r dir
: Remove a directory
File Compression ๐ฆ
tar
: Create/Extract tar archivestar -cvf archive.tar files
: Create an archivetar -xvf archive.tar
: Extract an archive
gzip
/gunzip
: Compress/Decompress filesgzip file
: Compress a filegunzip file.gz
: Decompress a file
File Editors โ๏ธ
nano
: Simple terminal text editorvim
/vi
: Powerful terminal text editor- Press
i
to insert,Esc
to exit insert mode,:wq
to save and exit
- Press
Directory Utilities ๐
tree
: Display directory structuretree dir
: Show structure of a directory
Scripting ๐
Shebang:
#!/bin/bash
(at the beginning of script)Variables:
variable_name=value
Conditions:
if
,else
,elif
Loops:
for
,while
Functions:
function_name() { ... }
Memory and Process ๐ง
top
: Display real-time system informationps
: Display running processesps aux
: Detailed process list
kill
: Terminate a processkill PID
: Terminate a process by PID
Disk Utilities ๐ฝ
fdisk
: Disk partitioning utilitymkfs
: Create a file system on a partitionmkfs.ext4 /dev/sdX
: Create ext4 file system
dd
: Copy data from one source to anotherdd if=source of=destination bs=block_size
๐ Ultimate Git & GitHub Cheat Sheet for DevOps Engineers ๐
Git Basics ๐
git init
๐ - Initialize a new Git repository in the current directory.git clone <repository-url>
๐ฅ - Clone a remote repository to your local machine.git add <file>
โ - Stage changes for commit.git commit -m "commit message"
๐ฌ - Commit staged changes with a descriptive message.git status
๐ - View the status of your working directory.git log
๐ - Display commit history.git diff
๐ - Show differences between your working directory and the last commit.git branch
๐ฟ - List all branches in the repository.git checkout <branch>
๐ - Switch to a different branch.git merge <branch>
๐ค - Merge changes from one branch into the current branch.git pull
๐ - Fetch remote changes and integrate them into the current branch.git push
๐ - Push local changes to a remote repository.
GitHub Collaboration ๐ค
git remote add origin <repository-url>
๐ - Link your local repository to a remote on GitHub.git remote -v
๐ก - View remote repositories associated with your local repo.git pull origin <branch>
๐ - Pull and integrate remote changes into your local branch.git push origin <branch>
๐ - Push local commits to a remote branch on GitHub.git branch -d <branch>
๐๏ธ - Delete a local branch.git push origin --delete <branch>
๐๏ธ - Delete a remote branch on GitHub.git fork
๐ด - Create a copy of a repository under your GitHub account.git pull-request
๐ - Initiate a pull request to merge your changes into the main repository.git merge <pull-request-branch>
๐ - Merge a pull request into the main branch.
Git Advanced ๐
git rebase <branch>
๐ - Combine commits from one branch onto another.git cherry-pick <commit>
๐ - Apply a specific commit to your current branch.git stash
๐ฆ - Temporarily save changes that you don't want to commit immediately.git reset <file>
๐ - Unstage changes in a file.git reset --hard <commit>
๐๐ - Reset your branch and working directory to a previous commit.git blame <file>
๐ - Find out who made changes to a specific file and when.git tag <tag-name>
๐ท๏ธ - Create a tag for a specific commit (e.g., for releases).
Remember, this cheat sheet provides only a brief overview. For in-depth usage and options, consult the respective command's manual pages (man
command).
Feel free to customize and expand upon this cheat sheet as needed. Happy learning! ๐
That's all for today, stay tuned for more updates!
#trainwithshubham #Devops #devopslearning #devopscommunity #90daysofdevops #git #github