Day 14 Task: Create a Linux & Git-GitHub Cheat Sheet

Faizan ShaikhFaizan Shaikh
3 min read

🐧 Linux Cheat Sheet 🐧

CommandDescriptionExample
lsList files and directories.ls -l
cd [directory]Change current directory.cd /home/user/
mkdir [directory]Create a new directory.mkdir project
touch [file]Create an empty file.touch file.txt
rm [file]Remove a file.rm file.txt
rmdir [directory]Remove an empty directory.rmdir folder
cp [source] [destination]Copy file to a destination.cp file.txt folder/
mv [source] [destination]Move or rename a file.mv oldname.txt newname.txt
chmod [permissions] [file]Change file permissions.chmod 755 script.sh
chown [user] [file]Change the owner of a file.chown user file.txt
psList running processes.ps aux
kill [PID]Terminate a process using PID.kill 12345
topDisplay real-time process statistics.top
df -hShow disk space usage.df -h
du -sh [directory]Show disk usage of a directory.du -sh /folder
uname -aDisplay system information.uname -a
uptimeShow how long the system has been running.uptime
free -hDisplay memory usage.free -h

🐙 Git & GitHub Cheat Sheet 🐙

CommandDescriptionExample
git initInitialize a new Git repository.git init
git clone [URL]Clone a repository from GitHub.git clone https://github.com/user/repo
git statusShow the current status of your Git repository.git status
git add [file]Stage a file for commit.git add file.txt
git commit -m "[message]"Commit changes with a message.git commit -m "Added new feature"
git branchList all branches.git branch
git checkout -b [branch]Create and switch to a new branch.git checkout -b dev
git merge [branch]Merge a branch into the current branch.git merge dev
git rebase [branch]Reapply commits on top of another branch.git rebase master
git push origin [branch]Push your branch to GitHub.git push origin dev
git pullFetch and merge changes from GitHub.git pull
git remote -vDisplay the remote repository URL.git remote -v
git reset --hard [commit]Reset repository to a previous commit, discarding changes.git reset --hard HEAD~1
git revert [commit]Undo a commit by creating a new commit.git revert [commit]
git tag [tagname]Create a tag for a specific commit.git tag v1.0
git push origin [tagname]Push a tag to GitHub.git push origin v1.0

💡 Pro Tips 💡

TipDescription
Use branchesAlways create branches for new features to keep the code clean.
Rebase for clean historyUse git rebase for a linear, cleaner commit history.
Write meaningful commit messagesClearly describe what changes you've made in your commits.
Check file permissionsRun ls -l in Linux to inspect file permissions and avoid errors.

Make sure to use all command and be practical guys

#HappyLearning😇

0
Subscribe to my newsletter

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

Written by

Faizan Shaikh
Faizan Shaikh