Cheat sheet for Linux, Git-GitHub

Cheat sheet for Linux, Git-GitHub

#90daysofdevops Day12

Linux commands.

  1. cd - Change directory. Use this command to navigate to different directories in the file system. For example, cd Documents will take you to the "Documents" directory.

  2. cd ..

    Move one level up

    cd

    To change to a particular directory

    cd /

    Move to the root directory

  3. ls - List files and directories. This command shows the contents of the current directory. Adding options like -l (long format) or -a (including hidden files) provides more detailed information.

  4. ls -R

    Lists files in sub-directories as well

    ls -a

    Lists hidden files as well

    ls -al

    Lists files and directories with detailed information like permissions,size, owner, etc.

  5. pwd - Print working directory. It displays the path of the current directory you are in.

  6. mkdir - Make directory. Use this command to create a new directory. For example, mkdir Pictures will create a directory named "Pictures" in the current location.

  7. rm - Remove files or directories. This command deletes files or directories permanently. To remove a file, use rm filename. To remove a directory and its contents, use rm -r directoryname.

  8. cp - Copy files and directories. Use this command to make copies of files or directories. For example, cp file.txt /path/to/destination will copy "file.txt" to the specified destination.

  9. mv - Move or rename files and directories. This command is used to move files or directories to a different location or rename them. For example, mv file.txt /path/to/destination will move "file.txt" to the specified destination.

  10. cat - Concatenate and display file content. This command shows the contents of a file on the terminal. For example, cat file.txt will display the content of "file.txt".

  11. grep - Search for text within files. Use this command to search for specific text within files. For example, grep "keyword" file.txt will search for the keyword in "file.txt".

  12. chmod - Change file permissions. This command is used to change the permissions of a file or directory. For example, chmod +x script.sh makes "script.sh" executable.

  13. sudo - Execute a command with superuser privileges. Use this command to run a command as the superuser (administrator). It is often used for system administration tasks. For example, sudo apt-get update updates the package lists with administrator privileges.

  14. apt-get - Package manager command. This command is used to install, update, or remove software packages in Debian-based distributions. For example, sudo apt-get install package-name installs a package.

  15. man - Access manual pages. This command provides documentation for other commands. For example, man ls displays the manual page for the "ls" command.

  16. wget - Download files from the web. Use this command to download files from the internet. For example, wget https://example.com/file.txt will download "file.txt" from the specified URL.

  17. ping - Check network connectivity. This command is used to check if a network host is reachable. For example, ping google.com will send a network request to Google's servers and show the response time.

  18. adduser USERNAME: Adds a new user to the system.

  19. passwd -l USERNAME: Changes the password of a user.

  20. userdel -r USERNAME: Removes a user from the system, including their home.

  21. userdel -r USERNAME: Removes a user from the system, including their home directory.

  22. usermod -a -G GROUPNAME USERNAME: Adds a user to a specific group.

  23. deluser USERNAME GROUPNAME: Removes a user from a specific group.

    Git commands.

  1. git init - Initialize a new Git repository. Use this command to start tracking changes in a new project.

  2. git clone [repository URL] - Clone a remote repository. This command creates a copy of a remote repository on your local machine.

  3. git add [file(s)] - Add file changes to the staging area. Use this command to prepare changes for the next commit. For example, git add file.txt adds "file.txt" to the staging area.

  4. git commit -m "[commit message]" - Commit changes. This command saves the staged changes to the repository with a descriptive commit message. For example, git commit -m "Added new feature" commits the changes with the message "Added new feature".

  5. git status - Check the status of the repository. This command displays the current status of your files and any pending changes.

  6. git push - Push changes to a remote repository. Use this command to upload your local commits to a remote repository. For example, git push origin master pushes the commits to the "master" branch of the remote repository named "origin".

  7. git pull - Fetch and merge changes from a remote repository. This command retrieves the latest changes from the remote repository and merges them with your local branch.

  8. git branch - List branches. Use this command to see a list of branches in your repository. The current branch is highlighted with an asterisk.

  9. git checkout [branch name] - Switch branches. This command allows you to switch to a different branch. For example, git checkout feature-branch switches to the branch named "feature-branch".

  10. git merge [branch name] - Merge branches. Use this command to merge changes from one branch into the current branch. For example, git merge feature-branch merges the changes from "feature-branch" into the current branch.

  11. git log - View commit history. This command displays a log of all commits in the repository, including commit messages, authors, and timestamps.

  12. git remote add [remote name] [repository URL] - Add a remote repository. This command sets up a connection to a remote repository with a given name and URL. For example, git remote add origin https://github.com/user/repo.git adds a remote repository named "origin" with the specified URL.

  13. git remote -v - List remote repositories. Use this command to see a list of remote repositories associated with your local repository.

  14. git stash - Stash changes. This command temporarily saves your changes and reverts the working directory to the last commit, allowing you to switch branches or apply the changes later.

  15. git reset [commit] - Reset the repository to a previous commit. This command undoes commits, discarding changes after the specified commit. Exercise caution with this command, as it modifies the commit history.

*********************************************************************************

I'm glad you found the Linux and Git reference guide helpful! Hope this guide simplifies your experience with Linux and Git. Happy coding and version controlling!

Thank you!