Day - 12 : Cheat-sheet for Linux & Git-GitHub Commands.

Day - 12 : Cheat-sheet for Linux & Git-GitHub Commands.

Linux Commands :

Certainly, here's a Linux command cheat sheet with some commonly used commands and their brief descriptions. Remember that Linux offers a vast array of commands, so this list is not exhaustive, but it should give you a good starting point.

Basic Commands:

  • ls: List files and directories.

  • cd: Change directory.

  • pwd: Print working directory.

  • cp: Copy files/directories.

  • mv: Move (rename) files/directories.

  • rm: Remove files/directories.

  • mkdir: Create a directory.

  • rmdir: Remove a directory (if empty).

  • cat: Concatenate and display file content.

  • echo: Print text to the terminal.

  • man: Display the manual for a command.

  • help: Get help for shell builtins.

File Operations:

  • touch: Create an empty file.

  • nano or vim: Text editors for file editing.

  • head: Display the beginning of a file.

  • tail: Display the end of a file.

  • grep: Search for text in files.

  • find: Search for files and directories.

  • wc: Count lines, words, and characters in a file.

  • chmod: Change file permissions.

  • chown: Change file ownership.

System Information:

  • uname: Display system information.

  • df: Display disk space usage.

  • free: Display memory usage.

  • top: Display real-time system processes.

  • ps: Display information about processes.

  • uptime: Display system uptime.

  • who: Display logged-in users.

Package Management:

  • Package managers can vary based on the Linux distribution. Here are a few examples:

    • apt (Debian/Ubuntu)

    • dnf (Fedora)

    • pacman (Arch Linux)

    • zypper (openSUSE)

    • Commands:

    • sudo apt update: Update package list (Debian/Ubuntu).

    • sudo apt install package_name: Install a package (Debian/Ubuntu).

    • sudo apt remove package_name: Remove a package (Debian/Ubuntu).

    • sudo dnf install package_name: Install a package (Fedora).

    • sudo dnf remove package_name: Remove a package (Fedora).

    • sudo pacman -S package_name: Install a package (Arch Linux).

    • sudo pacman -R package_name: Remove a package (Arch Linux).

Networking:

  • ifconfig or ip: Display network interfaces and configuration.

  • ping: Send ICMP echo requests to a host.

  • netstat: Display network statistics.

  • ss: Display socket statistics.

  • ssh: Securely connect to a remote server.

  • scp: Securely copy files between hosts.

Remember to use the man command for more detailed information about each command. The commands and package management examples may vary slightly depending on the Linux distribution you're using.

Git - Github commands :

Git Commands:

  1. git init: Initialize a new Git repository.

  2. git clone <repository_url>: Clone a remote repository to your local machine.

  3. git status: Check the status of your repository.

  4. git add <file(s)>: Add changes to the staging area.

  5. git commit -m "Commit message": Commit the changes in the staging area with a message.

  6. git commit -am "Commit message": Stage and commit changes in one step.

  7. git log: View commit history.

  8. git diff: View commit differences.

  9. git diff --staged: View changes in the staging area.

  10. git checkout -- <file(s)>: Discard changes in the working directory.

  11. git reset HEAD <file(s)>: Unstage changes from the staging area.

  12. git revert <commit_hash>: Revert a commit.

  13. git reset --hard <commit_hash>: Reset to a specific commit.

  14. git branch: List, create, or delete branches.

  15. git checkout <branch_name>: Switch to the specified branch.

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

  17. git merge <branch_name>: Merge the specified branch into your current branch.

  18. git branch -d <branch_name>: Delete a branch.

  19. git tag <tag_name>: Create a lightweight tag.

  20. git tag -a <tag_name> -m "Tag message": Create an annotated tag.

  21. git stash: Temporarily save changes to a stack for later use.

  22. git stash apply: Apply the last stashed changes.

  23. git stash pop: Apply and remove the last stashed changes.

  24. git stash list: List stashed changes.

  25. git stash drop: Discard the last stashed changes.

  26. git remote add <remote_name> <repository_url>: Add a remote repository.

  27. git remote -v: List remote repositories and their URLs.

  28. git push <remote_name> <branch_name>: Push your local commits to a remote branch.

  29. git fetch <remote_name>: Fetch changes from a remote repository.

  30. git pull <remote_name> <branch_name>: Pull changes from a remote branch into your local branch.

GitHub Commands:

  1. git pull-request: Create a pull request for code review and merging on GitHub.

  2. git merge <pull_request_branch>: Merge a pull request into the main branch on GitHub.

  3. git push --tags: Push tags to the remote repository on GitHub.

  4. git remote set-url origin <new_repository_url>: Update the URL of the remote repository (e.g., when switching from HTTPS to SSH).

  5. git remote remove <remote_name>: Remove a remote repository from your local configuration.

  6. git reflog: View the history of references (useful for recovering lost commits).

  7. git clean -n: List untracked files that will be removed with git clean -f.

  8. git log --graph --oneline --all: Visualize the commit graph in a concise way.

  9. git cherry-pick <commit_hash>: Apply a specific commit from one branch to another.

  10. git rebase <branch_name>: Reapply commits on top of another base branch.

Remember to refer to official documentation or use git --help for more information on each command. Regular usage and practice with these commands will improve your efficiency and proficiency in version control and collaboration with Git and GitHub.

Did you find this article valuable?

Support Sahil Kamble's blog by becoming a sponsor. Any amount is appreciated!