Basic Git command for Linux System Administrators


Git is a powerful version control system that’s essential for managing code and configuration files, especially in collaborative environments. For Linux system administrators, Git can be invaluable for tracking changes to system configurations, scripts, and other critical files.

Basic Git command for system administrator

  1. Initialization: Create a new Git repository:
    Bash command
    git init
  2. Cloning: Get a copy of an existing repository:
    Bash command
    git clone
  3. Staging: Add changes to the staging area:
    Bash command
    git add
  4. Committing: Save changes to the repository:
    Bash command
    git commit -m “Commit message”
  5. Pushing: Send changes to a remote repository:
    Bash command
    git push
  6. Pulling: Get updates from a remote repository:
    Bash command
    git pull

Example: Tracking Configuration Changes
Let’s say you want to track changes to your /etc/ssh/sshd_config file.

  1. Initialize a repository:
    Bash
    cd /etc/ssh
    git init
  2. Add the file:
    Bash
    git add sshd_config
  3. Commit the initial state:

Bash
git commit -m “Initial sshd_config”

  1. Make changes: Edit the sshd_config file as needed.
  2. Commit the changes:
    Bash
    git commit -m “Changed PortNumber to 2222”
  3. Push to a remote repository:
    Bash
    git remote add origin
    git push origin master
    Best Practices for System Administrators
  • Create separate repositories: For different projects or configurations to keep things
    organized.
  • Use meaningful commit messages: Describe the changes clearly for future
    reference.
  • Branching: Use branches for different features or bug fixes to isolate changes.
  • Reviewing: Have others review your changes before merging them into the main
    branch.
  • Backup: Always have a backup of your repository in case of accidental deletion or
    corruption.
    By following these guidelines, you can effectively use Git to manage your Linux
    system configurations and collaborate with other administrators.

REF : Gemini

Linux Basic to Linux system administration class

: ENROLL TODAY

Leave a comment