Skip to main content

Command Palette

Search for a command to run...

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

Published
โ€ข3 min readโ€ขView as Markdown

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

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.

๐Ÿš€ Master these commands and boost your DevOps productivity! ๐Ÿ’ป๐Ÿ”ฅ

More from this blog

DEVOPS challenge

21 posts