๐Ÿš€๐Ÿ“… Day 12 DevOps Challenge - Master Linux, Git & GitHub: Your Ultimate Cheat Sheet ๐Ÿง๐Ÿ™๐Ÿš€

๐Ÿš€๐Ÿ“… Day 12 DevOps Challenge - Master Linux, Git & GitHub: Your Ultimate Cheat Sheet ๐Ÿง๐Ÿ™๐Ÿš€

ยท

4 min read

Linux Commands Cheat Sheet ๐Ÿง

Everyday Linux Commands: Boost Your Productivity ๐Ÿง๐Ÿ’ผ

Navigation:

  • cd [directory]: Change directory. ๐Ÿš€

  • pwd: Print working directory. ๐Ÿ“‚

  • ls [options] [path]: List files and directories. ๐Ÿ—‚๏ธ

  • mkdir [directory]: Create a new directory. ๐Ÿ“

  • rmdir [directory]: Remove an empty directory. ๐Ÿ—‘๏ธ

File Operations:

  • touch [filename]: Create an empty file. โœจ

  • cp [source] [destination]: Copy files/directories. ๐Ÿ“

  • mv [source] [destination]: Move/Rename files/directories. ๐Ÿ”„

  • rm [options] [file/directory]: Remove files/directories. โŒ

File Permissions:

  • chmod [permissions] [file]: Change file permissions. ๐Ÿ”’

  • chown [user:group] [file]: Change file ownership. ๐Ÿ‘ฅ

Text Manipulation:

  • cat [file]: Display file contents. ๐Ÿฑ

  • less [file]: View file content interactively. ๐Ÿ“–

  • head [file]: Display the beginning of a file. ๐Ÿ“„

  • tail [file]: Display the end of a file. ๐Ÿ“‘

  • grep [pattern] [file]: Search for patterns in a file. ๐Ÿ”

  • wc [file]: Count lines, words, and characters. ๐Ÿงฎ

Process Management:

  • ps: Display running processes. ๐Ÿ”„

  • kill [PID]: Terminate process by PID. โ˜ ๏ธ

  • killall [process_name]: Terminate processes by name. โ˜ ๏ธ

  • top: Monitor system processes. ๐Ÿ“ˆ

System Information:

  • uname -a: Display kernel info. ๐Ÿง

  • df -h: Show disk space usage. ๐Ÿ’ฝ

  • free -h: Display RAM usage. ๐Ÿง 

  • ifconfig: View network config. ๐ŸŒ

User Management:

  • whoami: Display current username. ๐Ÿ‘ค

  • id: Show user/group info. ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ

  • users: List logged-in users. ๐Ÿง‘โ€๐Ÿ’ป

  • passwd: Change user password. ๐Ÿ”‘

File Searching:

  • find [path] [expression]: Search for files/dirs. ๐Ÿ”

  • locate [filename]: Find files using the database. ๐Ÿ”

Archive & Compression:

  • tar [options] [archive_name.tar] [files/dirs]: Create/extract tar archives. ๐Ÿ—ƒ๏ธ

  • gzip [file]: Compress using gzip. ๐Ÿ—œ๏ธ

  • gunzip [file]: Decompress with gzip. ๐Ÿ—œ๏ธ

  • zip [archive_name.zip] [files/dirs]: Create a zip archive. ๐Ÿ“ฆ

  • unzip [archive_name.zip]: Extract from zip. ๐Ÿ“ฆ

Networking:

  • ping [host]: Send ICMP echo requests. ๐Ÿ“

  • ssh [user@]host: Securely connect with SSH. ๐Ÿ”’

  • scp [source] [destination]: Copy over SSH. ๐Ÿ“ค๐Ÿ“ฅ

  • wget [url]: Download from the web. ๐ŸŒ๐Ÿ”ฝ

  • curl [url]: Transfer with URLs. ๐ŸŒ๐Ÿ”—

Disk & Filesystem:

  • df -h: Show disk space usage. ๐Ÿ’พ

  • du -h [directory]: Estimate file space usage. ๐Ÿ“Š

  • mount: Show mounted filesystems. ๐Ÿ”๏ธ

  • umount [mount_point]: Unmount filesystem. ๐Ÿ—ป

Package Management:

Debian/Ubuntu:

  • apt-get: Package Tool. ๐Ÿ“ฆ๐Ÿ”ง

  • dpkg: Package manager for .deb. ๐Ÿ“ฆ๐Ÿ“ฆ

Red Hat/CentOS/Fedora:

  • yum: Package manager. ๐Ÿ“ฆ๐Ÿ”ง

  • rpm: Package manager for .rpm. ๐Ÿ“ฆ๐Ÿ“ฆ

Process Monitoring:

  • ps: Display running processes. ๐Ÿ”„

  • top: Monitor processes. ๐Ÿ“ˆ

System Shutdown/Reboot:

  • shutdown [options] [time]: Shut down or reboot. ๐Ÿšซ๐Ÿ”„

  • reboot: Reboot immediately. ๐Ÿ”„

Help:

  • man [command]: Display manual. โ„น๏ธ

  • --help or -h: Get help. โ„น๏ธ

Git & GitHub Commands Cheat Sheet ๐Ÿ™

Basic Git Commands ๐Ÿš€

  • git init: Initialize Git repo.

  • git clone <repository_url>: Clone remote repo.

  • git status: Check repo status.

  • git add <file(s)>: Add changes to staging. ๐Ÿ“

  • git commit -m "Commit message": Commit with the message. ๐Ÿ’ฌ

  • git log: View commit history. ๐Ÿ“œ

  • git diff: View commit differences. ๐Ÿ“Š

  • git checkout -- <file(s)>: Discard changes. ๐Ÿ”„

  • git reset HEAD <file(s)>: Unstage changes. ๐Ÿ™…โ€โ™‚๏ธ

  • git revert <commit_hash>: Revert a commit. โช

  • git reset --hard <commit_hash>: Reset to commit. ๐Ÿ”™

  • git clean -n: List untracked files to be removed. ๐Ÿ—‘๏ธ

  • git cherry-pick <commit_hash>: Apply a specific commit. ๐Ÿ’

  • git rebase <branch_name>: Reapply commits on another base. ๐Ÿ”„

Branch & Tag Operations ๐ŸŒฟ๐Ÿท๏ธ

  • git branch: List/create/delete branches. ๐ŸŒ

  • git checkout <branch_name>: Switch branch. ๐Ÿ”„

  • git checkout -b <branch_name>: Create & switch. ๐ŸŒฑ

  • git merge <branch_name>: Merge branch. ๐Ÿค

  • git branch -d <branch_name>: Delete branch. โŒ

  • git tag <tag_name>: Create a lightweight tag. ๐Ÿท๏ธ

  • git tag -a <tag_name> -m "Tag message": Create annotated tag. ๐Ÿท๏ธ

Stashing & Remote ๐Ÿ“ฆ๐ŸŒ

  • git stash: Temporarily save changes. ๐Ÿ“ฆ

  • git stash apply: Apply last stash. ๐Ÿ“ฆ

  • git stash pop: Apply & remove last stash. ๐Ÿ“ฆ

  • git stash list: List stashed changes. ๐Ÿ“ฆ

  • git stash drop: Discard last stash. ๐Ÿ“ฆ

  • git remote add <remote_name> <repository_url>: Add remote repo. ๐ŸŒ

  • git remote -v: List remotes & URLs. ๐ŸŒ

  • git push <remote_name> <branch_name>: Push commits. โ˜๏ธ

  • git fetch <remote_name>: Fetch changes. ๐Ÿ”„

  • git pull <remote_name> <branch_name>: Pull changes. ๐Ÿ”„

Advanced Git Actions ๐Ÿš€

  • git reflog: View the history of references. ๐Ÿ“œ

  • git log --graph --oneline --all: Visualize the commit-graph concisely. ๐Ÿ“ˆ

  • git rebase <branch_name>: Reapply commits on another base. ๐Ÿ”„

Note: ๐Ÿš€

This cheat sheet contains all the commands used and mentioned in the past 11 blogs. It's a comprehensive and helpful resource that combines essential Linux commands for efficient file management and system control with powerful Git and GitHub commands for version control and collaborative coding. ๐Ÿง๐Ÿ™ Elevate your skills, streamline your workflow, and navigate the coding universe with confidence. ๐Ÿ’ป Embrace these tools to become a coder ๐ŸŒŸ!

Did you find this article valuable?

Support Adarsh Jha by becoming a sponsor. Any amount is appreciated!

ย