🐧 The Ultimate Linux & Git-GitHub Cheat Sheet for DevOps πŸ› οΈ

🐧 The Ultimate Linux & Git-GitHub Cheat Sheet for DevOps πŸ› οΈ

This cheat sheet will cover Linux commands, Git commands, and GitHub essentials, with descriptions, examples, and real-world relevance.

Β·

4 min read


🐧 Linux Commands for Everyday Use

CommandDescriptionExample
whoamiDisplays the current logged-in user.whoami
uname -rDisplays the Linux kernel version.uname -r
df -hShows disk usage in a human-readable format.df -h
du -sh [directory]Shows the size of a directory or file.du -sh /home/user
ls -laLists all files and directories with detailed information.ls -la
pwdPrints the current working directory.pwd
mkdir [directory]Creates a new directory.mkdir project_folder
rm -rf [directory/file]Deletes files or directories (use with caution).rm -rf old_files
chmod [permissions] [file]Changes file permissions.chmod 755 script.sh
chown [user]:[group] [file]Changes ownership of a file or directory.chown user:group file.txt
ps -auxDisplays all running processes.ps -aux
kill [process_id]Terminates a process by its PID.kill 1234
historyShows command history.history
alias [name]='[command]'Creates a shortcut for a command.alias ll='ls -la'
curl [url]Fetches data from a URL.curl https://example.com
wget [url]Downloads a file from a URL.wget https://example.com/file.zip
scp [file] [user@host:/path]Securely copies files between local and remote systems.scp file.txt user@192.168.1.1:/tmp
ssh [user@host]Connects to a remote server via SSH.ssh user@192.168.1.1

πŸ” Text Processing Commands.

CommandDescriptionExample
find [directory] -name "[name]"Searches for files by name.find /home -name "*.txt"
awk '/pattern/ {action}' [file]Processes text based on patterns in files.awk '/error/ {print $2}' log.txt
sed -i 's/[old]/[new]/g' [file]Finds and replaces text in a file.sed -i 's/foo/bar/g' file.txt
sort [file]Sorts lines in a file.sort data.txt
uniq [file]Removes duplicate lines from a file.uniq data.txt
wc -l [file]Counts the number of lines in a file.wc -l file.txt
grep [pattern] [file]Searches for a pattern in a file.grep "error" log.txt
crontab -eEdits the crontab to schedule recurring tasks.crontab -e

🌐 Networking Commands

CommandDescriptionExample
ping [host]Tests connectivity to a server.ping google.com
netstat -tulnDisplays open ports and network connections.netstat -tuln
ip aDisplays IP address and network details.ip a
scp [file] [user@host:/path]Copies files between local and remote systems.scp backup.zip user@192.168.1.1:/tmp
ssh [user@host]Connects to a remote server via SSH.ssh user@192.168.1.1
curl -I [url]Fetches HTTP headers for a URL.curl -I https://example.com

πŸ› οΈ Git Essentials

CommandDescriptionExample
git initInitializes a Git repository in the current directory.git init
git clone [url]Creates a local copy of a remote repository.git clone https://github.com/user/repo.git
git statusShows the status of changes in the working directory.git status
git add [file]Stages a file for commit.git add README.md
git commit -m "[message]"Saves staged changes with a commit message.git commit -m "Initial commit"
git push origin [branch]Pushes changes to the remote repository.git push origin main
git pull origin [branch]Fetches and merges changes from a remote repository.git pull origin main
git branchLists all branches in the repository.git branch
git checkout -b [branch]Creates and switches to a new branch.git checkout -b feature-branch
git merge [branch]Merges a branch into the current branch.git merge feature-branch
git logDisplays the commit history.git log

🌟 GitHub Essentials

ActionDescriptionSteps
Create a RepositorySets up a new repository on GitHub.Go to GitHub β†’ Click on "New" β†’ Fill details.
Clone a RepositoryCopies an existing repository to your local system.git clone [url]
Push ChangesUpdates the remote repository with local changes.git push origin main
Pull RequestsProposes changes to a branch.Navigate to your branch β†’ Click "Pull Request".
Β