Linux & Git-GitHub Cheat Sheet

ยท

4 min read

Linux & Git-GitHub Cheat Sheet

Linux Commands:

  1. ls: List all the directories and files.

  2. mkdir: Makes a new directory.

  3. rmdir: Remove a directory (only if it's empty).

  4. cd: Change directory.

  5. cd.. : Go back to the previous directory.

  6. pwd: Print the current working directory.

  7. ls -l: List files with more details.

  8. cat: Show the content of a file.

  9. echo: Shows the desired string and value.

  10. man: Tells about all commands.

  11. touch: Create a file.

  12. cp: Copy files.

  13. mv: Move files.

  14. rm: Remove the file permanently.

  15. sudo: Administrative commands (password).

  16. head: Display the first 10 lines.

  17. tail: Display the last 10 lines.

  18. zip: Zip files in Linux

  19. unzip: Unzip files in Linux

  20. ssh: Secure Shell command in Linux

  21. service: Linux command to start and stop services

  22. ps: Display active processes

  23. wget: download files from the internet

  24. whoami: Create or update passwords for existing users

  25. grep: Search for a string within an output

  26. sort: sort the file content

  27. cal: View Calendar in terminal

  28. whereis: View the exact location of any command types after this command

  29. kill and killall: Kill active processes by process ID or name

  30. chmod: Change file permissions.

  31. chown: Change file ownership.

  32. history: Shows history of command usage.

  33. useradd and usermod: Add a new user or change existing users data

  34. passwd: Create or update passwords for existing users

Git-GitHub Commands:

  1. git init: Initialize a new Git repository in the current directory.

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

  3. git status: Show the current status of the repository (modified files, staged changes, etc.).

  4. git add <file>: Add a file to the staging area to be included in the next commit.

  5. git commit -m "commit message": Create a new commit with the staged changes and a descriptive message.

  6. git diff: View the differences between the working directory and the staging area.

  7. git log: Display the commit history of the repository.

  8. git branch: List all branches in the repository.

  9. git checkout <branch>: Switch to a different branch.

  10. git merge <branch>: Merge changes from the specified branch into the current branch.

  11. git pull: Fetch and merge changes from a remote repository into the current branch.

  12. git push: Push local commits to a remote repository.

  13. git remote add origin <repository-url>: Add a remote repository as the origin (usually the main remote).

  14. git remote -v: View a list of remote repositories and their URLs.

  15. git reset <file>: Unstage changes for a file, removing them from the staging area.

  16. git rm <file>: Remove a file from the repository and staging area.

  17. git stash: Temporarily store changes not ready for a commit.

  18. git cherry-pick <commit>: Apply changes from a specific commit to the current branch.

  19. git fetch: Download objects and refs from another repository without merging.

  20. git revert <commit>: Create a new commit that undoes the changes from a specific commit.

  21. git remote -v: View a list of remote repositories and their URLs, including GitHub remotes.

  22. git push origin <branch>: Push local commits to a remote branch on GitHub.

  23. git pull origin <branch>: Fetch and merge changes from a remote branch on GitHub into the current branch.

  24. git clone <repository-url>: Clone a GitHub repository to your local machine.

  25. git fork: Create a copy of a repository on your GitHub account (forking).

  26. git pull-request: Create a pull request to propose changes from your fork to the original repository.

  27. git pull upstream <branch>: Pull changes from the original repository after forking (upstream).

  28. git remote add upstream <original-repo-url>: Add the original repository as the upstream remote for your fork.

  29. git branch -d <branch>: Delete a local branch after it's merged and no longer needed.

  30. git push origin --delete <branch>: Delete a remote branch on GitHub.

I hope you like my blog..!!

Stay Connected with me for more interesting articles on DevOps, if you like my blog follow me on Hashnode and Linkedin (https://www.linkedin.com/in/som-shanker-pandey/)

Did you find this article valuable?

Support Som Pandey's blog by becoming a sponsor. Any amount is appreciated!

ย