Skip to main content

Command Palette

Search for a command to run...

#90DaysOfDevops | Day 14

Day -> Linux & Git-GitHub Cheat Sheet

Published
4 min readView as Markdown
#90DaysOfDevops | Day 14

Git Basics:

  • git init: Initialize a new Git repository.

  • git clone <repository-url>: Clone a repository into a new directory.

  • git status: Check the status of your working directory and staging area.

  • git add <file>: Add a file to the staging area.

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

  • git push origin <branch>: Push changes to a remote repository.

  • git pull origin <branch>: Pull changes from a remote repository.

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

  • git merge <branch>: Merge changes from a different branch into the current branch.

  • git branch: List all branches in the repository.

  • git log: View commit history.

  • git diff <file>: Show changes between commits, commit and working tree, etc.

Branching and Merging:

  • git branch <branch-name>: Create a new branch.

  • git checkout -b <branch-name>: Create and switch to a new branch.

  • git merge <branch-name>: Merge a branch into the current branch.

  • git branch -d <branch-name>: Delete a branch.

Undoing Changes:

  • git reset HEAD <file>: Unstage changes from the staging area.

  • git checkout -- <file>: Discard changes in the working directory.

  • git revert <commit>: Revert a specific commit.

Remote Repositories:

  • git remote add <name> <url>: Add a new remote repository.

  • git remote -v: List all remote repositories.

  • git fetch <remote>: Fetch changes from a remote repository.

  • git remote show <remote>: Show information about a remote repository.

  • git push <remote> --delete <branch>: Delete a branch on a remote repository.

  • git pull --rebase origin master: Pull changes from the remote repository and rebase local commits on top.

Git Configuration:

  • git config --global user.name "Your Name": Set your username globally.

  • git config --global user.email "youremail@example.com": Set your email globally.

  • git config --list: List all Git configurations.

This cheat sheet covers the basic Git commands and concepts.

Linux Important Commands:

File System Navigation:

  • pwd: Print the current working directory.

  • ls: List files and directories.

    • ls -l: Detailed list view.

    • ls -a: List including hidden files.

  • cd <directory>: Change directory.

  • cd ..: Move up one directory.

  • cd ~: Move to the home directory.

File Operations:

  • touch <filename>: Create an empty file.

  • mkdir <directory>: Create a new directory.

  • cp <source> <destination>: Copy files or directories.

  • mv <source> <destination>: Move or rename files or directories.

  • rm <file>: Remove files (use with caution).

    • rm -r <directory>: Remove directories recursively.
  • cat <file>: Display the contents of a file.

  • less <file>: View file contents page by page.

  • head <file>: Display the beginning of a file.

  • tail <file>: Display the end of a file.

File Permissions:

  • chmod <permissions> <file>: Change file permissions.

  • chown <user>:<group> <file>: Change file ownership.

  • chgrp <group> <file>: Change file group ownership.

  • umask: Set default permissions for new files.

Process Management:

  • ps: List processes.

    • ps aux: Detailed process list.
  • top: Display real-time system resource usage.

  • kill <PID>: Terminate a process by process ID.

  • killall <process_name>: Terminate a process by name.

  • pkill <pattern>: Send signal to processes based on name.

  • pgrep <pattern>: List processes based on name.

System Information:

  • uname -a: Display kernel information.

  • lsb_release -a: Display Linux distribution information.

  • df -h: Show disk space usage.

  • du -h <directory>: Show directory space usage.

  • free -h: Display memory usage.

  • uptime: Show system uptime and load averages.

Package Management (Debian/Ubuntu):

  • apt update: Update package lists.

  • apt upgrade: Upgrade all installed packages.

  • apt install <package>: Install a package.

  • apt remove <package>: Remove a package.

  • apt search <keyword>: Search for a package.

Text Processing:

  • grep <pattern> <file>: Search for a pattern in a file.

  • sed 's/find/replace/' <file>: Stream editor for filtering and transforming text.

  • awk '{print $<column>}' <file>: Pattern scanning and processing language.

  • sort <file>: Sort lines of text files.

  • uniq <file>: Report or omit repeated lines.

Miscellaneous:

  • date: Display current date and time.

  • cal: Display a calendar.

  • history: Display command history.

  • tar: Archive files.

  • zip: Compress files.

  • unzip: Extract files from a zip archive.

  • man <command>: Display manual page for a command.

Happy Learning 🚀