๐Ÿง(Day 07) Task : Linux Commands & Git Commands Cheat Sheet.

Aditya SharmaAditya Sharma
3 min read

๐Ÿง Linux Commands Cheat Sheet :-

File & Directory Operations :-

  • ls โ€“ List files in current directory.

  • ls -l โ€“ Long listing format.

  • ls -a โ€“ Show hidden files.

  • cd <dir> โ€“ Change directory.

  • pwd โ€“ Print current directory path.

  • mkdir <dir> โ€“ Create new directory.

  • rmdir <dir> โ€“ Remove empty directory.

  • rm <file> โ€“ Remove file.

  • rm -r <dir> โ€“ Remove directory with contents.

  • cp <src> <dest> โ€“ Copy file/directory.

  • mv <src> <dest> โ€“ Move/rename file/directory.

File Viewing & Editing :-

  • cat <file> โ€“ View file contents.

  • less <file> โ€“ View file with scroll.

  • head <file> โ€“ First 10 lines of file.

  • tail <file> โ€“ Last 10 lines of file.

  • nano <file> โ€“ Edit file using nano.

  • vim <file> โ€“ Edit file using vim.

File Searching :-

  • find <dir> -name <filename> โ€“ Find file by name.

  • grep "<text>" <file> โ€“ Search text in file.

  • grep -r "<text>" <dir> โ€“ Recursively search in directory.

File Permissions :-

  • chmod +x <file> โ€“ Make file executable.

  • chmod 755 <file> โ€“ Set read/write/execute for owner, read/execute for others.

  • chown user:group <file> โ€“ Change file ownership.

System Info :-

  • uname -a โ€“ Kernel version.

  • top โ€“ Real-time system processes.

  • df -h โ€“ Disk usage.

  • free -h โ€“ RAM usage.

  • uptime โ€“ System uptime.

  • whoami โ€“ Current user.

Package Management :-

  • sudo apt update โ€“ Update package list.

  • sudo apt upgrade โ€“ Upgrade packages.

  • sudo apt install <package> โ€“ Install package.

  • sudo apt remove <package> โ€“ Remove package.

๐Ÿ™ Git Commands Cheat Sheet :-

Configuration :-

  • git config --global user.name "Your Name" โ€“ Set Git username.

  • git config --global user.email "you@example.com" โ€“ Set Git email.

  • git config --list โ€“ List config.

Repository Management :-

  • git init โ€“ Initialize new Git repo.

  • git clone <url> โ€“ Clone remote repo.

  • git status โ€“ Show repo status.

  • git log โ€“ Show commit history.

  • git diff โ€“ Show changes.

Staging & Committing :-

  • git add <file> โ€“ Stage file.

  • git add . โ€“ Stage all changes.

  • git commit -m "message" โ€“ Commit with message.

  • git commit -am "message" โ€“ Add & commit tracked files.

Branching :-

  • git branch โ€“ List branches.

  • git branch <name> โ€“ Create branch.

  • git checkout <name> โ€“ Switch branch.

  • git checkout -b <name> โ€“ Create and switch to new branch.

  • git merge <branch> โ€“ Merge branch into current.

Remote Repositories :-

  • git remote -v โ€“ Show remote URLs.

  • git push origin <branch> โ€“ Push changes.

  • git pull โ€“ Pull latest changes.

  • git fetch โ€“ Download changes.

Undoing Changes :-

  • git reset <file> โ€“ Unstage file.

  • git checkout -- <file> โ€“ Discard file changes.

  • git revert <commit> โ€“ Revert a commit.

  • git reset --hard <commit> โ€“ Reset to commit.

0
Subscribe to my newsletter

Read articles from Aditya Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aditya Sharma
Aditya Sharma

DevOps Enthusiast | Python | Chef | Docker | GitHub | Linux | Shell Scripting | CI/CD & Cloud Learner | AWS