Skip to main content

Command Palette

Search for a command to run...

Day 14: Create a Linux & Git-GitHub Cheat Sheet

Published
4 min read
S

"Passionate about simplifying the complexities of DevOps, I bring 5 years of hands-on experience in supporting development and operations teams to achieve faster, more reliable software delivery. I thrive on optimizing CI/CD pipelines, automating workflows, and troubleshooting challenges across diverse cloud environments. My expertise spans across infrastructure management, continuous integration, and performance monitoring—ensuring stability and efficiency at every stage of the software lifecycle. Always eager to learn, collaborate, and innovate, I’m committed to driving impactful change in the DevOps space."

Key Uses of Linux:

  1. Server Management:

    • Linux is extensively used to run servers due to its stability, security, and flexibility. Many web servers, database servers, and cloud systems rely on Linux.
  2. Software Development:

    • Programmers and developers prefer Linux for its versatility and compatibility with various programming languages and tools. It also allows customization, automation with shell scripting, and has strong support for development environments.
  3. Networking and Security:

    • Linux provides strong networking capabilities, making it popular among network administrators. Many cybersecurity professionals also use Linux for its access to various security tools and configurations.
  4. Embedded Systems and IoT:

    • Due to its efficiency and low resource requirements, Linux is common in embedded systems and IoT devices, like smart thermostats, automotive infotainment systems, and industrial control systems.
  5. Education and Research:

    • Linux is often used in research and academia, where high-performance computing, data science, and simulations require a flexible, open platform.
  6. Personal Use:

    • Many users choose Linux for personal computing because it is open-source, meaning it’s free, and is highly customizable, allowing users to tailor it to their needs.

Advantages of Linux:

  • Security: Linux is generally more secure than many other operating systems due to its user permissions and open-source nature.

  • Stability and Performance: Linux systems are known for running efficiently for long periods without crashing.

  • Open Source and Free: Being open source, Linux can be modified, and it’s typically free, saving costs.

  • Customization: Users can modify Linux to fit their specific needs, from the desktop environment to the kernel itself.

  • Community Support: Linux has a large community that supports development, troubleshooting, and innovation.

  • Install a package:
    sudo apt install <package-name>

  • Remove a package:
    sudo apt remove <package-name>

  • Install nginx:
    sudo apt install nginx

  • Check nginx version:
    nginx -v

File and Directory Management

  • List files in a directory:
    ls

  • List files with detailed information:
    ls -lh

  • Change directory:
    cd <directory-name>

  • Create a new directory:
    mkdir <directory-name>

  • Remove an empty directory:
    rmdir <directory-name>

  • Remove a file:
    rm <file-name>

  • Create an empty file:
    touch <file-name>

  • Show current directory:
    pwd

User Management

  • Add a new user:
    sudo adduser <username>

  • Change file owner:
    sudo chown <new-owner> <file-name>

  • Change file group:
    sudo chgrp <new-group> <file-name>

Permissions

  • Change file permissions:
    sudo chmod <permissions> <file-name>

Process Management

  • View running processes:
    ps

  • View Docker processes:
    docker ps

Docker Commands

  • Pull a Docker image:
    docker pull <image-name>

  • Run a Docker container:
    docker run <image-name>

  • List Docker images:
    docker images

Networking

  • Check system status:
    sudo systemctl status <service-name>

  • Start a service:
    sudo systemctl start <service-name>

  • Enable a service to start at boot:
    sudo systemctl enable <service-name>

Miscellaneous

  • Clear the terminal screen:
    clear

  • Open a file in a text editor:
    vim <file-name>

Scheduling Tasks

  • Edit crontab:
    crontab -e

  • List crontab entries:
    crontab -l

Backup and Archive

  • Create a zip archive:
    zip <archive-name>.zip <file1> <file2>

  • List zip contents:
    unzip -l <archive-name>.zip

Version Checking

  • Check Java version:
    java -version
  • Jenkins Installation and Setup

    • Install Jenkins
      sudo apt update
      sudo apt install jenkins

    • Clean Up Package Cache
      sudo apt clean

    • Start and Enable Jenkins Service
      sudo systemctl start jenkins
      sudo systemctl enable jenkins

    • Check Jenkins Service Status
      sudo systemctl status jenkins

    • View Jenkins Log
      sudo cat /var/log/jenkins/jenkins.log

    • View Detailed Jenkins Log
      sudo journalctl -xe -u jenkins

    • Restart Jenkins Service
      sudo systemctl restart jenkins

    • Stop Jenkins Service
      sudo systemctl stop jenkins

Docker Commands

  • Enable Docker to Start on Boot
    systemctl enable docker

  • Check Docker Service Status
    systemctl status docker

  • View Docker Logs
    journalctl -u docker

Git Configuration and Repository Setup

  • Configure Git Username and Email
    git config --global user.name "Vani019"
    git config --global user.email "shivani019singh@gmail.com"

  • View Git Configuration
    git config --list

  • Initialize Git Repository
    mkdir github
    cd github
    git init

  • Set Default Branch Name
    git config --global init.defaultBranch main

  • Add Remote Repository
    git remote add origin https://github.com/Vani019/Test.git

  • Create Subdirectories and Add a File
    mkdir -p Devops/Git
    echo "Created new directory" > Devops/Git/GitTest1.txt

  • Add and Commit Changes
    git add .
    git commit -m "Initial commit with .txt file"

  • Push to Remote Repository
    git push -u origin main

  • Switch to a New Branch
    git checkout -b main

  • Check Git Status
    git status

In summary, this cheat sheet provides a quick reference for essential commands to install, configure, and manage Jenkins, Docker, and Git. The Jenkins section covers steps to install, start, enable, and check the status of the Jenkins service, as well as viewing and managing logs. Docker commands include enabling Docker to start on boot, checking its status, and viewing logs, which helps ensure your Docker environment runs smoothly. The Git section details key setup commands such as configuring user information, initializing repositories, setting branch names, and managing commits and branches, which is crucial for efficient version control.

With these commands, you can set up and maintain continuous integration with Jenkins, containerization with Docker, and streamlined version control with Git—providing a solid foundation for DevOps and collaborative software development.

"The DevOps Insight and Learning with Shivani"

Part 10 of 22

"DevOps Insight with Shivani" is a beginner-friendly series exploring DevOps tools, practices, and concepts like CI/CD pipelines. Join me for easy tutorials, practical tips, and industry updates to help you learn and grow in the DevOps world.

Up next

Day 13 Task: Advance Git & GitHub for DevOps Engineers

Git Branching Branches are a core concept in Git that allow you to isolate development work without affecting other parts of your repository. Each repository has one default branch, and can have multiple other branches. You can merge a branch into an...

More from this blog

T

The DevOps Insight with Shivani

23 posts