Cheat Sheet for DevOps Engineers on Linux & Git Commands | #Day12 #90daysof devops

ยท

5 min read

Cheat Sheet for DevOps Engineers on Linux & Git Commands | #Day12 #90daysof devops

Linux Command Line Cheat Sheet

Navigation ๐Ÿš€

  • pwd: Print current working directory

  • ls: List files and directories

    • ls -l: Detailed list view

    • ls -a: Show hidden files

  • cd: Change directory

    • cd ~: Home directory

    • cd ..: Parent directory

  • mkdir: Create a directory

  • rmdir: Remove an empty directory

  • grep: Search for a pattern in files

    • grep pattern file: Search in a file

    • grep -r pattern dir: Recursively search in a directory

  • find: Search for files and directories

    • find dir -name file: Search for a file in a directory

File System ๐Ÿ“

  • df: Display disk space usage

  • du: Display file/directory space usage

    • du -h: Human-readable format
  • mount: Mount a file system

  • umount: Unmount a file system

  • ln: Create symbolic/hard links

    • ln -s source link: Create a symbolic link

File Permission ๐Ÿ”

  • chmod: Change file permissions

    • chmod ugo +/- rwx file: Modify permissions
  • chown: Change file ownership

    • chown user:group file: Change ownership

Network ๐ŸŒ

  • ifconfig or ip addr: Display network interfaces

  • ping: Test network connectivity

  • netstat or ss: Network statistics

  • ssh: Securely connect to a remote server

    • ssh user@host: Connect to a remote host

File Management ๐Ÿ“‚

  • cp: Copy files/directories

    • cp source destination: Copy files

    • cp -r source_dir destination_dir: Copy directories

  • mv: Move/Rename files/directories

    • mv old new: Rename file/directory
  • rm: Remove files/directories

    • rm file: Remove a file

    • rm -r dir: Remove a directory

File Compression ๐Ÿ“ฆ

  • tar: Create/Extract tar archives

    • tar -cvf archive.tar files: Create an archive

    • tar -xvf archive.tar: Extract an archive

  • gzip/gunzip: Compress/Decompress files

    • gzip file: Compress a file

    • gunzip file.gz: Decompress a file

File Editors โœ๏ธ

  • nano: Simple terminal text editor

  • vim/vi: Powerful terminal text editor

    • Press i to insert, Esc to exit insert mode, :wq to save and exit

Directory Utilities ๐Ÿ“™

  • tree: Display directory structure

    • tree 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 information

  • ps: Display running processes

    • ps aux: Detailed process list
  • kill: Terminate a process

    • kill PID: Terminate a process by PID

Disk Utilities ๐Ÿ’ฝ

  • fdisk: Disk partitioning utility

  • mkfs: Create a file system on a partition

    • mkfs.ext4 /dev/sdX: Create ext4 file system
  • dd: Copy data from one source to another

    • dd if=source of=destination bs=block_size

๐Ÿš€ Ultimate Git & GitHub Cheat Sheet for DevOps Engineers ๐Ÿš€

Git Basics ๐Ÿ“œ

  1. git init ๐ŸŽ‰ - Initialize a new Git repository in the current directory.

  2. git clone <repository-url> ๐Ÿ“ฅ - Clone a remote repository to your local machine.

  3. git add <file> โž• - Stage changes for commit.

  4. git commit -m "commit message" ๐Ÿ’ฌ - Commit staged changes with a descriptive message.

  5. git status ๐Ÿ“Š - View the status of your working directory.

  6. git log ๐Ÿ“ - Display commit history.

  7. git diff ๐Ÿ” - Show differences between your working directory and the last commit.

  8. git branch ๐ŸŒฟ - List all branches in the repository.

  9. git checkout <branch> ๐Ÿ”„ - Switch to a different branch.

  10. git merge <branch> ๐Ÿค - Merge changes from one branch into the current branch.

  11. git pull ๐Ÿ”„ - Fetch remote changes and integrate them into the current branch.

  12. git push ๐Ÿš€ - Push local changes to a remote repository.

GitHub Collaboration ๐Ÿค

  1. git remote add origin <repository-url> ๐Ÿ“Œ - Link your local repository to a remote on GitHub.

  2. git remote -v ๐Ÿ“ก - View remote repositories associated with your local repo.

  3. git pull origin <branch> ๐Ÿ”„ - Pull and integrate remote changes into your local branch.

  4. git push origin <branch> ๐Ÿš€ - Push local commits to a remote branch on GitHub.

  5. git branch -d <branch> ๐Ÿ—‘๏ธ - Delete a local branch.

  6. git push origin --delete <branch> ๐Ÿ—‘๏ธ - Delete a remote branch on GitHub.

  7. git fork ๐Ÿด - Create a copy of a repository under your GitHub account.

  8. git pull-request ๐Ÿ”„ - Initiate a pull request to merge your changes into the main repository.

  9. git merge <pull-request-branch> ๐Ÿ”„ - Merge a pull request into the main branch.

Git Advanced ๐Ÿš€

  1. git rebase <branch> ๐Ÿ”„ - Combine commits from one branch onto another.

  2. git cherry-pick <commit> ๐Ÿ’ - Apply a specific commit to your current branch.

  3. git stash ๐Ÿ“ฆ - Temporarily save changes that you don't want to commit immediately.

  4. git reset <file> ๐Ÿ”™ - Unstage changes in a file.

  5. git reset --hard <commit> ๐Ÿ”™๐Ÿ”™ - Reset your branch and working directory to a previous commit.

  6. git blame <file> ๐Ÿ” - Find out who made changes to a specific file and when.

  7. 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

ย