Day 12 : Linux and Git-GitHub Cheat Sheet

Radheya Zunjur
4 min readJun 30, 2023

--

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.

Let’s dive in and unlock the full potential of these indispensable tools together!

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

--

--

Radheya Zunjur
Radheya Zunjur

Written by Radheya Zunjur

Database Engineer At Harbinger | DevOps | Cloud Ops | Technical Writer

No responses yet