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
- Initialization: Create a new Git repository:
Bash command
git init - Cloning: Get a copy of an existing repository:
Bash command
git clone - Staging: Add changes to the staging area:
Bash command
git add - Committing: Save changes to the repository:
Bash command
git commit -m “Commit message” - Pushing: Send changes to a remote repository:
Bash command
git push - 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.
- Initialize a repository:
Bash
cd /etc/ssh
git init - Add the file:
Bash
git add sshd_config - Commit the initial state:
Bash
git commit -m “Initial sshd_config”
- Make changes: Edit the sshd_config file as needed.
- Commit the changes:
Bash
git commit -m “Changed PortNumber to 2222” - 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

