Day 12 - Mastering Linux and Git-GitHub: Your Ultimate Cheat-Sheet

Rahul GuptaRahul Gupta
4 min read

Introduction

Welcome to your ultimate cheat-sheet for Linux and Git-GitHub! This guide is designed to be a quick reference for essential commands, providing brief explanations and usage examples to enhance your productivity and efficiency. Whether you're a beginner or an experienced developer, this cheat-sheet will serve as a valuable resource for both everyday tasks and advanced operations. Let's dive into the world of Linux and Git-GitHub!

Linux Commands

Basic Commands

  1. ls

    • Usage: Lists the files and directories in the current directory.

    • Example:

        ls
        ls -la  # Includes hidden files and detailed information
      
  2. cd

    • Usage: Changes the current directory.

    • Example:

        cd /path/to/directory
        cd ..  # Moves up one directory
      
  3. pwd

    • Usage: Prints the working directory.

    • Example:

        pwd
      
  4. mkdir

    • Usage: Creates a new directory.

    • Example:

        mkdir new_directory
      
  5. rm

    • Usage: Removes files or directories.

    • Example:

        rm file.txt
        rm -r directory  # Recursively removes a directory
      
  6. cp

    • Usage: Copies files or directories.

    • Example:

        cp source.txt destination.txt
        cp -r source_directory destination_directory
      
  7. mv

    • Usage: Moves or renames files or directories.

    • Example:

        mv old_name.txt new_name.txt
        mv /path/to/file /new/path/
      
  8. touch

    • Usage: Creates an empty file or updates the timestamp of an existing file.

    • Example:

        touch newfile.txt
      

File Permissions

  1. chmod

    • Usage: Changes the permissions of a file or directory.

    • Example:

        chmod 755 script.sh  # Sets read, write, execute for owner and read, execute for group and others
      
  2. chown

    • Usage: Changes the owner of a file or directory.

    • Example:

        chown user:group file.txt
      

Networking

  1. ifconfig / ip

    • Usage: Displays or configures network interfaces.

    • Example:

        ifconfig
        ip addr show
      
  2. ping

    • Usage: Checks connectivity to a host.

    • Example:

        ping example.com
      

System Monitoring

  1. top

    • Usage: Displays active processes and system resource usage.

    • Example:

        top
      
  2. df

    • Usage: Reports file system disk space usage.

    • Example:

        df -h
      
  3. du

    • Usage: Estimates file space usage.

    • Example:

        du -sh *
      

Package Management

  1. apt-get (Debian/Ubuntu)

    • Usage: Installs, updates, and removes packages.

    • Example:

        sudo apt-get update
        sudo apt-get install package_name
        sudo apt-get remove package_name
      
  2. yum (CentOS/RHEL)

    • Usage: Installs, updates, and removes packages.

    • Example:

        sudo yum update
        sudo yum install package_name
        sudo yum remove package_name
      

Git-GitHub Commands

Git Basics

  1. git init

    • Usage: Initializes a new Git repository.

    • Example:

        git init
      
  2. git clone

    • Usage: Clones a repository into a new directory.

    • Example:

        git clone https://github.com/user/repository.git
      
  3. git add

    • Usage: Adds files to the staging area.

    • Example:

        git add file.txt
        git add .
      
  4. git commit

    • Usage: Records changes to the repository.

    • Example:

        git commit -m "Commit message"
      
  5. git status

    • Usage: Displays the state of the working directory and the staging area.

    • Example:

        git status
      
  6. git log

    • Usage: Shows the commit history.

    • Example:

        git log
      

Branching and Merging

  1. git branch

    • Usage: Lists, creates, or deletes branches.

    • Example:

        git branch  # Lists branches
        git branch new-branch  # Creates a new branch
        git branch -d old-branch  # Deletes a branch
      
  2. git checkout

    • Usage: Switches branches or restores files.

    • Example:

        git checkout branch-name
        git checkout -b new-branch  # Creates and switches to a new branch
      
  3. git merge

    • Usage: Merges changes from one branch into another.

    • Example:

        git checkout main
        git merge feature-branch
      

Remote Repositories

  1. git remote

    • Usage: Manages remote repository connections.

    • Example:

        git remote add origin https://github.com/user/repository.git
        git remote -v  # Lists remote connections
      
  2. git push

    • Usage: Uploads local repository content to a remote repository.

    • Example:

        git push origin main
      
  3. git pull

    • Usage: Fetches and integrates changes from a remote repository.

    • Example:

        git pull origin main
      
  4. git fetch

    • Usage: Downloads objects and refs from another repository.

    • Example:

        git fetch origin
      

Conclusion

This cheat-sheet covers essential commands for Linux and Git-GitHub, providing a handy reference for daily use and advanced operations. By mastering these commands, you'll enhance your productivity and become more proficient in managing your development environment. Remember, practice is key to becoming comfortable with these tools, so don't hesitate to experiment and explore further.

Happy coding and contributing to the DevOps community! ๐Ÿ˜Ž๐Ÿ™Œ

Thank you for reading our DevOps blog post. We hope you found it informative and helpful. If you have any questions or feedback, please don't hesitate to contact us.

I hope this helps!

Happy Learningโœจ

0
Subscribe to my newsletter

Read articles from Rahul Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rahul Gupta
Rahul Gupta

Hey there! ๐Ÿ‘‹ I'm Rahul Gupta, a DevOps Engineer passionate about all things AWS DevOps Technology. Currently, on a learning adventure, I'm here to share my journey and Blogs in the world of cloud and DevOps. ๐Ÿ› ๏ธ My focus? Making sense of AWS services, improving CI/CD, and diving into infrastructure as code. Whether you're fellow interns or curious enthusiasts, let's grow together in the vibrant DevOps space. ๐ŸŒ Connect with me for friendly chats, shared experiences, and learning moments. Here's to embracing the learning curve and thriving in the exciting world of AWS DevOps Technology!