Day 14 Task: Create a Linux & Git-GitHub Cheat Sheet
Linux & Git-GitHub Cheat Sheet
๐ Linux Commands
๐น Basic Commands
pwdโ Print working directory.lsโ List files in a directory.cd <directory>โ Change directory.mkdir <directory>โ Create a new directory.rmdir <directory>โ Remove an empty directory.rm <file>โ Remove a file.rm -r <directory>โ Remove a directory with files.
๐น File Operations
touch <file>โ Create an empty file.cp <source> <destination>โ Copy a file/directory.mv <source> <destination>โ Move or rename a file/directory.cat <file>โ View file contents.nano <file>โ Edit a file using Nano editor.vim <file>โ Edit a file using Vim editor.
๐น File Permissions
chmod <permissions> <file>โ Change file permissions.chown <user>:<group> <file>โ Change file ownership.ls -lโ Show file permissions.
๐น Process Management
psโ Show running processes.topโ Display real-time system processes.kill <PID>โ Kill a process by its PID.htopโ Interactive process monitoring (if installed).
๐น System Information
uname -aโ Show system info.df -hโ Show disk usage.free -mโ Show memory usage.uptimeโ Show system uptime.whoamiโ Show current user.
๐น Networking
ifconfig/ip aโ Show network interfaces.ping <host>โ Check network connectivity.curl <URL>โ Fetch data from a URL.wget <URL>โ Download a file from a URL.
๐น Package Management
sudo apt update && sudo apt upgrade -yโ Update and upgrade system packages (Debian-based).sudo yum update -yโ Update system packages (RHEL-based).apt install <package>โ Install a package.apt remove <package>โ Remove a package.
๐ Git & GitHub Commands
๐น Git Basics
git initโ Initialize a Git repository.git clone <repo_url>โ Clone a repository.git statusโ Check status of the working directory.git add <file>โ Stage changes.git commit -m "message"โ Commit staged changes.git push origin <branch>โ Push commits to remote.git pull origin <branch>โ Pull latest changes.git log --onelineโ Show commit history in short form.
๐น Branching
git branchโ List all branches.git branch <branch_name>โ Create a new branch.git checkout <branch_name>โ Switch to a branch.git merge <branch_name>โ Merge a branch.git branch -d <branch_name>โ Delete a branch.
๐น Undo Changes
git reset --soft HEAD~1โ Undo last commit (keep changes).git reset --hard HEAD~1โ Undo last commit (discard changes).git revert <commit_hash>โ Revert a commit safely.
๐น GitHub Collaboration
git remote add origin <repo_url>โ Connect to a remote repository.git push -u origin <branch>โ Push branch to GitHub.git pull origin <branch>โ Pull latest changes from GitHub.git fetchโ Fetch latest updates from remote.git clone <repo_url>โ Clone a repository from GitHub.
Tips
| Tip | Description |
| Use branches | Always create branches for new features to keep the code clean. |
| Rebase for clean history | Use git rebase for a linear, cleaner commit history. |
| Write meaningful commit messages | Clearly describe what changes you've made in your commits. |
| Check file permissions | Run ls -l in Linux to inspect file permissions and avoid errors. |
๐ Master these commands and boost your DevOps productivity! ๐ป๐ฅ