⚔Day 12 - Linux , Git and Github Commands Cheat-Sheet

⚔Day 12 - Linux , Git and Github Commands Cheat-Sheet

This cheat sheet provides quick access to essential Linux commands organized into categories like navigation, file management, search, permissions, system management, and Git/GitHub workflows. With clear descriptions, modes, and examples, users can efficiently perform tasks such as navigating directories, managing files, searching text, handling permissions, monitoring processes, and version controlling with Git. Ideal for both beginners and experienced users, this resource enhances productivity and proficiency in Linux command line operations and version control practices.

Linux Commands Cheat Sheet** 🐧

Navigation: 🗺️

cd

  1. Usage : To change Directories

  2. Modes :

    📍 ~ : Home directory.

    📍 .. : Previous directory.

Example:

  • " cd ~ " : Change to the Home Directory

  • " cd .. " : Change to the previous Directory


File Management: 📁

ls

  1. Usage : List Directory Contents.

Modes :

📍 -a : Show hidden files

📍 -l: Use a long listing format

Example:

  • " ls -a " : Lists all files, including hidden ones.

  • " ls -l " : Displays detailed information about files.

mkdir

  1. Usage : Make Directory

  2. Modes :

    📍-p: Create parent directories if they do not exist.

Example:

  • " mkdir new_folder": Creates a new directory named "new_folder".

  • " mkdir -p parent_folder/sub_folder ": Creates nested directories.

rm

  1. Usage : Remove files or directories.

  2. Modes :

    📍 -r : Recursively remove directory.

    📍 -f : Force removal without confirmation.

Example:

  • " rm file.txt " : Deletes a file named "file.txt".

  • " rm -rf directory " : Removes a directory and its contents forcefully.

cp

  1. Usage : Copy files or directories.

  2. Modes :

    📍 -r: Copy directories recursively.

    📍-u: Update - copy only when source is newer than destination.

    Example:

    • " cp file.txt destination/ " : Copies "file.txt" to the "destination" directory.

    • " cp -ru source/ destination/ ": Copies newer files from source to destination.

mv

  1. Usage : Move or rename files or directories.

Example:

  • " mv file.txt new_location/ " : Moves "file.txt" to "new_location".

  • " mv old_name.txt new_name.txt " : Renames "old_name.txt" to "new_name.txt".

cat

  1. Usage : Display file content.

  2. Modes :

    📍-n : Number all output lines.

Example:

  • " cat file.txt " : Displays content of "file.txt".

  • " cat -n file.txt " : Displays content with line numbers.


Search and Filter: 🔍

grep

  1. Usage : Search Text.

  2. Modes:

    📍-i: Ignore case distinctions.

    📍-v: Invert match.

Example:

  • " grep "keyword" file.txt " : Searches for "keyword" in "file.txt".

  • " grep -i "word" file.txt " : Searches ignoring case.


Permissions and Security: 🔒

chmod

  1. Usage : Change file permissions.

  2. Modes :

    📍u/g/o : User/group/others

    📍+/- : Add/remove Permission

Example:

  • " chmod u+x script.sh " : Adds execute permission to the owner.

  • " chmod go-w file.txt " : Removes write permission from group and others.


System Management: ⚙️

sudo

  1. Usage : Execute a command with superuser privileges.

Example:

sudo apt-get update

top

  1. Usage : Display and manage running processes.

  2. Modes :

    📍-u : Display processes for a specific user.

Example:

  • " top " : Displays processes in real-time.

  • " top -u username " : Shows processes for a specific user.

df

  1. Usage : Report file system disk space usage.

  2. Modes :

    📍-h : Human-readable format.

Example:

  • " df -h " : Displays disk space usage in a human-readable format.

  • " df -hT " : Shows disk space usage with filesystem type.


Downloading and Archiving: 📦

wget

  1. Usage : Download files from the internet.

Example:

tar

  1. Usage : To zip or compress file handle tar archieves.

  2. Modes :

    📍-x : Extract files from an archieve.

    📍-z : Filter the archive through gzip.

Example:

  • " tar -xvf archive.tar.gz " : Extracts files from a tarball.

" tar -czf archive.tar.gz directory/ " : Creates a gzip-compressed tarball of a directory.


Git and GitHub Commands Cheat Sheet 🚀

Version Control: 🔄

  1. git init

    • Usage: Initialize a new Git repository.

    • Example: git init

  2. git clone

    • Usage: Clone a repository into a new directory.

    • Example: git clone <repository_url>

  3. git add

    • Usage: Add file contents to the index.

    • Example: git add file.txt

  4. git commit

    • Usage: Record changes to the repository.

    • Modes:

      • -m: Specify commit message.
    • Example: git commit -m "Commit message"

  5. git push

    • Usage: Update remote refs along with associated objects.

    • Example: git push origin main

  6. git pull

    • Usage: Fetch from and integrate with another repository or a local branch.

    • Example: git pull origin main

  7. git branch

    • Usage: List, create, or delete branches.

    • Example: git branch feature

  8. git checkout

    • Usage: Switch branches or restore working tree files.

    • Example: git checkout feature

  9. git merge

    • Usage: Join two or more development histories together.

    • Example: git merge feature

  10. git log

    • Usage: Show commit logs.

    • Example: git log

  11. git status

    • Usage: Show the working tree status.

    • Example: git status

  12. git remote

    • Usage: Manage set of tracked repositories.

    • Modes:

      • -v: List remote URLs.
    • Example: git remote -v

This cheat sheet covers commands for Linux, Git and GitHub. providing a quick reference for revision , share and spread the knowledge! 🌟

Happy Learning 😊:)

Did you find this article valuable?

Support Vivek's Blog by becoming a sponsor. Any amount is appreciated!