Day11-Linux and Git Commands for DevOps Engineers

Day11-Linux and Git Commands for DevOps Engineers

Now we have completed the Linux & Git-GitHub hands-on, let's make a cheat sheet of all the commands we have learned so far.

Linux Commands -

  • pwd: Print the current working directory.
  • man: To display the user manual of any command that we can run on the terminal
  • history: To display the history of the commands executed by the user.
  • clear: To clear the terminal screen.
  • date: Display the system date and time.
  • echo: Display string of characters.
  • whoami: Displays the login of the current user.
  • tree: recursive directory listing program that produces a depth-indented listing of files
  • uname: Displays the information about the system


1. Navigating the File System:


  • ls: List files and directories.
  • cd: Change the current directory.
  • mkdir: Create a new directory.
  • rm: Remove files or directories.
  • cp: Copy files or directories.
  • mv: Move or rename files or directories.


2. Viewing and Editing Files:


  • cat: Display the contents of a file.
  • less: View file contents interactively.
  • nano or vim: Text editors for editing files.
  • head: Display the beginning of a file.
  • tail: Display the end of a file.


3. File Permissions:


  • chmod: Change file permissions.
  • chown: Change file ownership.
  • chgrp: Change the group of directory/file


4. Processes and System Management:


  • ps: Display information about processes.
  • top : Monitor system processes interactively.
  • kill: Terminate processes.
  • shutdown or reboot: Shutdown or restart the system.


5. Networking:


  • ifconfig or ip: Display or configure network interfaces.
  • ping: Send ICMP echo requests to a host.
  • ssh: Securely access remote systems over SSH.
  • netstat : Display network statistics.
  • hostname: allows us to set and view the hostname of the system.
  • curl: used to transfer data to or from a server.
  • wget: To download files and interact with REST APIs


6. Package Management:


  • apt (Debian/Ubuntu) or yum (Red Hat/Fedora): Package management tools for installing, updating, and removing software packages.
  • dpkg (Debian/Ubuntu) or rpm (Red Hat/Fedora): Direct package management tools.


7. File Compression and Archiving:


  • tar: Create, extract, and manipulate archive files.
  • gzip or gunzip: Compress or decompress files.
  • zip or unzip: Compress or extract files in ZIP format.


8. User Management:


  • useradd: Add a new user.
  • passwd: Change user password.
  • usermod: Modify user properties.
  • userdel: Delete a user.


9. Disk and Storage Management:


  • df: Display disk space usage.
  • du: Display file and directory space usage.
  • mount and umount: Mount and unmount filesystems.


10. Searching for files and directories:


  • find: Search for files and directories in a specified directory
  • grep: Search for specified patterns or text in files
  • locate: Quickly find files using a database (requires updating the database)
  • which: Displays the full path of a specified command.

Git-GitHub commands -

? Setting up Git:



? Creating Repositories:


  • git init: Initialize a new Git repository in the current directory.
  • git clone <repository_url>: Clone a remote repository to your local machine.


? Managing Changes:


  • git add <file>: Add a file to the staging area.
  • git commit -m "Commit message": Commit staged changes with a message.
  • git status: Check the status
  • git rm <file name> : To remove the file/folder
  • git diff: Show the changes between working directory and staging area.
  • git diff --staged: Show the changes between staging area and last commit.
  • git reset <file>: Unstaged changes for a file, removing them from the staging area.
  • git revert <commit>: Create a new commit that undoes the changes from a specific commit.


? Branching and Merging:


  • git branch: List all branches in the repository.
  • git branch -a: List all branches
  • git branch <branch_name>: Create a new branch.
  • git checkout <branch_name>: Switch to a different branch.
  • git merge <branch_name>: Merge changes from one branch into another.
  • git checkout -b <branch_name>: Create a new branch and switch to it.
  • git branch --delete <branch_name> : To delete the branch


? Updating and Publishing:


  • git pull: Fetch and merge changes from a remote repository.
  • git push origin <branch_name>: Push local changes to a remote repository.
  • git push -u origin <branch_name>: Push changes to remote repository (and remember the branch)
  • git remote add origin ssh://[email protected]/[username]/[repository-name].git : Add a remote repository


? Viewing History:


  • git log: Display commit history.
  • git log --oneline: Display a single commit history.
  • git-show: To see log messages


? Stashing Changes:


  • git stash: Temporarily save changes that are not ready to be committed.
  • git stash apply: Apply the most recent stash.
  • git stash save: Changes can be stashed with a message
  • git stash list: List out all the stashes stored in the stash stack
  • git stash clear or drop: To delete all the stashes from the stash stack
  • git stash branch <branch name>: Create a new branch from your latest stash
  • git cherry-pick <commit>: Apply changes from a specific commit to the current branch.
  • git remote -v: View a list of remote repositories and their URLs.
  • git pull upstream <branch>: Pull changes from the original repository after forking (upstream).




Thank you for reading this blog! ?? Hope you have gained some knowledge.

Hope you find it helpful, please give it a like ??, share it with your friends, share your thoughts, and give me some valuable feedback.??

要查看或添加评论,请登录

Pankaj Bawliya的更多文章

社区洞察

其他会员也浏览了