Day 12 : Linux and Git-GitHub Cheat Sheet

Day 12 : Linux and Git-GitHub Cheat Sheet

#90daysofdevops

Introduction🎉

This article aims to present a comprehensive cheat sheet encompassing essential Linux and Git-GitHub commands, along with explanations of their usage. Whether you are looking to navigate through directories, perform file operations, manage system resources, or collaborate on projects using Git-GitHub, this cheatsheet will serve as your go-to reference.

So, whether you’re a developer, a system administrator, or a DevOps enthusiast, keep this cheatsheet close at hand. It’s your gateway to mastering the essential Linux and Git-GitHub commands that will empower you to navigate the world of technology with confidence.


🔹Linux Cheat Sheet: File Operations:

  • ls: List files and directories in the current directory.

  • cd: Change directory.

  • pwd: Print the current working directory.

  • mkdir: Create a new directory.

  • cp: Copy files and directories.

  • mv: Move or rename files and directories.

  • rm: Remove files and directories.

  • cat: Concatenate and display the contents of files.

  • touch: Create an empty file or update the timestamp of an existing file.

  • chmod: Change the permissions of files and directories.

  • chown: Change the owner of files and directories.

  • find: Search for files and directories.

  • grep: Search for a specific pattern in files.

  • tar: Archive files together into a tarball or extract files from a tarball.

🔹System Operations:

  • sudo: Execute a command as the superuser or another user.

  • apt-get: Package management command for Debian-based systems.

  • yum: Package management command for RPM-based systems.

  • systemctl: Control system services (start, stop, restart, enable, disable).

  • ps: Display information about active processes.

  • top: Monitor system resources and running processes.

  • df: Display disk space usage.

  • free: Display memory usage.

  • ifconfig: Display or configure network interfaces.

  • ssh: Connect to a remote server using Secure Shell (SSH).

  • ping: Send ICMP Echo Request packets to a network host.

  • shutdown: Shut down or restart the system.

🔹Text Processing:

  • grep: Search for a specific pattern in files.

  • sed: Stream editor for text manipulation.

  • awk: Text processing tool for pattern scanning and processing.

  • cut: Select portions of lines from files.

  • sort: Sort lines of text files.

  • uniq: Remove duplicate lines from a sorted file.

  • wc: Count the number of lines, words, and characters in files.

  • head: Display the beginning of a file.

  • tail: Display the end of a file.

🔸Git-GitHub Cheat Sheet: Repository Operations:

🔹Repository Initialization:

  • git init: Initialize a new Git repository.

🔹Cloning and Creating Repositories:

  • git clone [repository URL]: Clone a remote repository onto your local machine.

  • git remote add [name] [repository URL]: Add a remote repository.

  • git remote remove [name]: Remove a remote repository.

  • git remote -v: List remote repositories.

🔹Branches:

  • git branch: List branches.

  • git branch [branch name]: Create a new branch.

  • git branch -d [branch name]: Delete a branch.

  • git checkout [branch name]: Switch to a different branch.

  • git checkout -b [branch name]: Create a new branch and switch to it.

  • git merge [branch name]: Merge changes from a different branch.

  • git rebase [branch name]: Reapply commits on top of another branch.

🔹Staging and Committing Changes:

  • git status: Show the current status of the repository.

  • git add [file(s)]: Add file(s) to the staging area.

  • git add .: Add all changes to the staging area.

  • git commit -m "[commit message]": Commit staged changes.

  • git commit --amend: Amend the last commit.

🔹Pushing and Pulling:

  • git push [remote] [branch]: Push commits to a remote repository.

  • git push -u [remote] [branch]: Push commits to a remote repository and set upstream.

  • git pull [remote] [branch]: Fetch changes from a remote repository and merge them into the current branch.

  • git fetch [remote]: Fetch changes from a remote repository without merging.

  • git branch -r: List remote branches.

  • git branch -a: List all local and remote branches.

🔹Collaborating and Remote Operations:

  • git clone [repository URL]: Clone a remote repository onto your local machine.

  • git fork: Create a copy of a remote repository under your GitHub account.

  • git pull-request: Create a pull request to propose changes to a repository.

  • git fetch origin: Fetch changes from the origin remote repository.

  • git push origin [branch name]: Push commits to the origin remote repository.

🔹Viewing History and Diffs:

  • git log: Display commit history.

  • git diff: Show changes between commits, branches, or files.

  • git show [commit]: Show details of a specific commit.

  • git blame [file]: Display who last modified each line of a file.

🔹Undoing Changes:

  • git checkout [file]: Discard changes in a file and restore it to the last committed version.

  • git reset [commit]: Discard commits, moving the branch pointer to a previous commit.

  • git revert [commit]: Create a new commit that undoes the changes introduced by a specific commit.

  • git stash: Temporarily save changes that are not ready to be committed.

🔹Remote Repository Management:

  • git remote show [remote]: Display information about a remote repository.

  • git remote prune [remote]: Remove remote branches that no longer exist on the

🔹Basic Git Command:

  • git init :Initialize a new local Git repository

  • git clone : Clone a remote repository to your local machine

  • git add : Add a file to the staging area

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

  • git status : Check the status of your local repository

  • git log : View the commit history

  • git diff : View the differences between the working directory and the last commit

  • git branch : View the branches in the repository

  • git branch : Create a new branch

  • git checkout : Switch to a different branch

  • git merge : Merge a branch into the current branch

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

  • git push : Push local changes to a remote repository

🔹Advanced Git Commands:

  • git stash: Temporarily save changes that haven't been committed Temporarily saves changes that haven't been committed, allowing you to switch branches or work on something else without committing your current changes.

  • git stash apply: Apply the most recent stash

  • git stash drop: Discard the most recent stash

  • git stash list: List all stashes

  • git stash pop: Apply and remove the most recent stash

  • git rebase: Rebase the current branch onto another branch Allows you to reapply commits on top of another base tip. This can be useful for maintaining a linear history, or for resolving conflicts in a feature branch before merging it back into the main branch.

  • git cherry-pick: Apply the changes from a specific commit to the current branch Allows you to apply the changes from a specific commit to the current branch. This can be useful for picking specific changes from one branch and applying them to another.

  • git reset: Unstage a file Allows you to undo commits and move the branch pointer to a previous commit. This can be useful for removing commits from a branch, or for rolling back to a previous state.

  • git reset: Reset the current branch to a specific commit

  • git revert: Create a new commit that undoes the changes made in a specific commit Creates a new commit that undoes the changes made in a specific commit. This can be useful for undoing changes that were accidentally committed or pushed to a remote repository.

🔹Linux Commands:

  • ls - Lists all files and directories in the current directory.

  • cd - Changes the current directory.

  • pwd - Shows the current directory path.

  • mkdir - Creates a new directory.

  • touch - Creates a new file.

  • cp - Copies a file or directory.

  • mv - Moves a file or directory.

  • rm - Removes a file or directory.

  • cat - Shows the contents of a file.

  • less - Shows the contents of a file one page at a time.

  • grep - Searches for a specific text pattern in a file or a group of files.

  • find - Searches for files and directories in a specified location.

  • chmod - Changes the permissions of a file or directory.

  • chown - Changes the ownership of a file or directory.

  • su - Allows you to switch to a different user account.

  • sudo - Allows you to execute a command as the root user.

  • top - Shows the processes running on your system and their resource usage.

  • ps - Shows the processes running on your system.

  • kill - Ends a running process.

  • reboot - Restarts the system.

  • tar - Archiving and extracting files.

  • gzip and gunzip - Compressing and decompressing files.

  • find - Advanced file search and manipulation.

  • awk and sed - Text processing and manipulation.

  • grep - Advanced search in files and text streams.

  • sort and uniq - Sorting and unique data manipulation.

  • cut and paste - Text and columns manipulation.

  • tr - Translation of characters.

  • ssh - Secure remote connection.

  • scp - Secure file copying over a network.

  • rsync - Synchronizing files and directories over a network.

  • netstat - Showing network connections and statistics.

  • iptables - Firewall management.

  • crontab - Scheduling tasks to run automatically.

  • df and du - Showing disk usage.

  • free - Showing memory usage.

  • top, htop, and glances - Advanced system monitoring.

  • lsof - Listing open files and network connections.

    I hope you found this information helpful. For more information click on the given link 👇

    Github


Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

Linkedln

Twitter