Finally!! ๐
You have completed the Linux & Git-GitHub hands-on tasks, and I hope you have learned something interesting from it. ๐
Now, let's create an interesting ๐ blog that will benefit the DevOps community!
๐ป Linux Commands Cheat Sheet
๐ File and Directory Operations
ls
: List files and directories in the current directory.cd <directory>
: Change the current directory.pwd
: Print the current working directory.mkdir <directory>
: Create a new directory.rmdir <directory>
: Remove an empty directory.touch <file>
: Create an empty file or update the timestamp of an existing file.cp <source> <destination>
: Copy files or directories.mv <source> <destination>
: Move or rename files or directories.rm <file>
: Remove files.cat <file>
: View the content of a file.
๐ File Permissions
chmod <permissions> <file>
: Change file or directory permissions (e.g.,chmod 777 <file>
).chown <user>:<group> <file>
: Change the owner and group of a file.
๐ Viewing and Searching
cat <file>
: Display the contents of a file.less <file>
: View the content of a file page by page.grep <pattern> <file>
: Search for a specific pattern in a file.find <directory> -name <filename>
: Search for a file by name in a directory.
๐ฅ System Monitoring
top
: Display real-time system processes.ps
: Display currently running processes.df -h
: Show disk space usage in a human-readable format.free -m
: Display memory usage in megabytes.
๐ Networking
ifconfig
: Display network interfaces and IP addresses.ping <host>
: Send ICMP echo requests to check connectivity to a host.netstat
: Display network connections, routing tables, and interface statistics.
๐ฆ Package Management
apt update
: Update package list (Debian/Ubuntu).apt upgrade
: Upgrade installed packages (Debian/Ubuntu).yum update
: Update packages (CentOS/RHEL).yum install <package>
: Install a package (CentOS/RHEL).
๐ Process Management
kill <PID>
: Terminate a process by PID.killall <process_name>
: Terminate all processes with a specific name.nice -n <priority> <command>
: Run a command with a specific priority.
๐ Shell Scripting
nano <
script.sh
>
: Edit a script file using the Nano text editor../
script.sh
: Execute a shell script.echo "text"
: Print text to the terminal.
๐ Archiving and Compression
tar -cvf <archive.tar> <files>
: Create a tar archive.tar -xvf <archive.tar>
: Extract a tar archive.gzip <file>
: Compress a file using gzip.gunzip <file.gz>
: Decompress a gzip file.
โ๏ธ For more advanced commands, like AWK, GREP and SED, please refer my Advanced Linux blog :)
๐ Git and GitHub Commands Cheat Sheet
๐ฑ Getting Started with Git
git init
: Initialize a new Git repository in the current directory.git config --global user.name <Name>
andgit config --global user.email <Email>
: Used to configure git and to help it recognize out machine.git clone <repo_url>
: Clone a repository into a new directory.
๐ Working with Files
git add <file>
: Add a file to the staging area.git add .
: Add all changes in the current directory to the staging area.git commit -m "message"
: Commit changes in the staging area with a descriptive message.git status
: Show the working tree status.git diff
: View changes between the working directory and the staging area.
๐ Viewing History
git log
: Show the commit history.git log --oneline
: Show the commit history in a condensed, one-line format.
๐ Undoing Changes
git restore <file_name>
: Discard changes in the working directory.git reset <file_name>
: Unstage a file without losing its changes. Not recommended to do.git revert <commit_hash>
: Create a new commit that undoes the changes of a specific commit.
๐ฟ Branching
git branch
: List branches.git branch <branch_name>
: Create a new branch.git checkout <branch_name>
: Switch to an existing branch.git switch <branch_name>
: Another way to switch branches.
๐ Merging & Rebase
git merge <branch_name>
: Merge a branch into the current branch.git rebase <branch_name>
: Reapply commits from the current branch onto another branch.
๐ Syncing with Remote
git remote add origin <repo_url>
: Add a remote repository.git push origin <branch_name>
: Push changes to the remote repository.git pull origin <branch_name>
: Fetch and merge changes from the remote repository.
๐ GitHub Basics
git fork
: Create a copy of a repository on your GitHub account.git clone <forked_repo_url>
: Clone the forked repository.git push origin <branch_name>
: Push changes to your forked repository.Pull Request (PR): After pushing changes to GitHub, create a PR to merge changes into the original repository.
๐ Github Advanced commands
git cherry-pick <commit_id>
: Used to merge a particular commit from one branch to another rather than merging the complete branch.git stash <branch_name>
: Reapply commits from the current branch onto another branch.
๐ SSH Setup
ssh-keygen -t rsa -b 4096 -C "
your_email@example.com
"
: Generate a new SSH key.eval "$(ssh-agent -s)"
: Start the SSH agent.ssh-add ~/.ssh/id_rsa
: Add your SSH private key to the agent.
This bog covers the essentials of working with Linux, Git and GitHub, focusing on the most frequently used commands. ๐. I hope this helps, for any queries please feel free to reach me out on Linkedin :)