12 Day: Linux & Git-GitHub Cheat Sheet

Here s a cheat sheet for commonly used Linux and Git/GitHub commands:

Linux Cheat Sheet:

  1. File and Directory Operations:

    • ls: List files and directories.

    • pwd: Print the working directory.

    • cd: Change directory.

    • mkdir: Create a new directory.

    • touch: Create an empty file.

    • rm: Remove files or directories.

    • cp: Copy files or directories.

    • mv: Move or rename files or directories.

  2. File Manipulation:

    • cat: Display the contents of a file.

    • more or less: View file content page by page.

    • head: Display the beginning of a file.

    • tail: Display the end of a file.

    • nano or vim or emacs: Text editors to edit files.

  3. File Permissions:

    • chmod: Change file permissions.

    • chown: Change file ownership.

  4. Process Management:

    • ps: List running processes.

    • kill: Terminate processes.

    • top or htop: Monitor system resources and processes.

  5. Package Management:

    • apt (Debian/Ubuntu) or yum (Fedora/CentOS): Install and manage software packages.
  6. Networking:

    • ifconfig or ip: Network configuration.

    • ping: Test network connectivity.

    • ssh: Secure shell for remote access.

    • scp: Securely copy files over SSH.

  7. User Management:

    • useradd: Create a new user.

    • passwd: Change user password.

    • su or sudo: Switch users or run commands with superuser privileges.

  8. File Compression and Archiving:

    • tar: Archive files.

    • gzip or bzip2: Compress files.

    • zip or unzip: Create or extract ZIP archives.

Git & GitHub Cheat Sheet:

  1. Git Basics:

    • git init: Initialize a new Git repository.

    • git clone: Clone a remote repository.

    • git add: Stage changes for commit.

    • git commit: Commit changes.

    • git status: Check the status of the repository.

    • git log: View commit history.

    • git branch: List branches.

    • git checkout: Switch branches or commit versions.

    • git merge: Merge branches.

    • git pull: Fetch and merge changes from a remote repository.

    • git push: Push local changes to a remote repository.

  2. GitHub Commands:

    • git remote add origin <repository_url>: Link your local repository to a GitHub repository.

    • git push -u origin <branch_name>: Push your branch to GitHub.

    • Pull requests, issues, and other GitHub-specific actions are typically performed through the GitHub web interface.

  3. Git Branching and Merging:

    • git branch <branch_name>: Create a new branch.

    • git checkout -b <branch_name>: Create and switch to a new branch.

    • git merge <branch_name>: Merge a branch into the current branch.

    • git rebase <branch_name>: Rebase the current branch onto another branch.

  4. Git Collaboration:

    • git fetch: Retrieve remote changes without merging.

    • git pull: Fetch and merge remote changes.

    • git fetch --all and git pull --all: Fetch and merge from all remote repositories.

    • git clone --recursive: Clone a repository and its submodules.

Remember to replace placeholders like <repository_url> and <branch_name> with the actual values you're working with. This cheat sheet should help you get started with common Linux and Git/GitHub commands.