Day 12 - Mastering Linux and Git-GitHub: Your Ultimate Cheat-Sheet
Introduction
Welcome to your ultimate cheat-sheet for Linux and Git-GitHub! This guide is designed to be a quick reference for essential commands, providing brief explanations and usage examples to enhance your productivity and efficiency. Whether you're a beginner or an experienced developer, this cheat-sheet will serve as a valuable resource for both everyday tasks and advanced operations. Let's dive into the world of Linux and Git-GitHub!
Linux Commands
Basic Commands
ls
Usage: Lists the files and directories in the current directory.
Example:
ls ls -la # Includes hidden files and detailed information
cd
Usage: Changes the current directory.
Example:
cd /path/to/directory cd .. # Moves up one directory
pwd
Usage: Prints the working directory.
Example:
pwd
mkdir
Usage: Creates a new directory.
Example:
mkdir new_directory
rm
Usage: Removes files or directories.
Example:
rm file.txt rm -r directory # Recursively removes a directory
cp
Usage: Copies files or directories.
Example:
cp source.txt destination.txt cp -r source_directory destination_directory
mv
Usage: Moves or renames files or directories.
Example:
mv old_name.txt new_name.txt mv /path/to/file /new/path/
touch
Usage: Creates an empty file or updates the timestamp of an existing file.
Example:
touch newfile.txt
File Permissions
chmod
Usage: Changes the permissions of a file or directory.
Example:
chmod 755 script.sh # Sets read, write, execute for owner and read, execute for group and others
chown
Usage: Changes the owner of a file or directory.
Example:
chown user:group file.txt
Networking
ifconfig
/ip
Usage: Displays or configures network interfaces.
Example:
ifconfig ip addr show
ping
Usage: Checks connectivity to a host.
Example:
ping example.com
System Monitoring
top
Usage: Displays active processes and system resource usage.
Example:
top
df
Usage: Reports file system disk space usage.
Example:
df -h
du
Usage: Estimates file space usage.
Example:
du -sh *
Package Management
apt-get
(Debian/Ubuntu)Usage: Installs, updates, and removes packages.
Example:
sudo apt-get update sudo apt-get install package_name sudo apt-get remove package_name
yum
(CentOS/RHEL)Usage: Installs, updates, and removes packages.
Example:
sudo yum update sudo yum install package_name sudo yum remove package_name
Git-GitHub Commands
Git Basics
git init
Usage: Initializes a new Git repository.
Example:
git init
git clone
Usage: Clones a repository into a new directory.
Example:
git clone https://github.com/user/repository.git
git add
Usage: Adds files to the staging area.
Example:
git add file.txt git add .
git commit
Usage: Records changes to the repository.
Example:
git commit -m "Commit message"
git status
Usage: Displays the state of the working directory and the staging area.
Example:
git status
git log
Usage: Shows the commit history.
Example:
git log
Branching and Merging
git branch
Usage: Lists, creates, or deletes branches.
Example:
git branch # Lists branches git branch new-branch # Creates a new branch git branch -d old-branch # Deletes a branch
git checkout
Usage: Switches branches or restores files.
Example:
git checkout branch-name git checkout -b new-branch # Creates and switches to a new branch
git merge
Usage: Merges changes from one branch into another.
Example:
git checkout main git merge feature-branch
Remote Repositories
git remote
Usage: Manages remote repository connections.
Example:
git remote add origin https://github.com/user/repository.git git remote -v # Lists remote connections
git push
Usage: Uploads local repository content to a remote repository.
Example:
git push origin main
git pull
Usage: Fetches and integrates changes from a remote repository.
Example:
git pull origin main
git fetch
Usage: Downloads objects and refs from another repository.
Example:
git fetch origin
Conclusion
This cheat-sheet covers essential commands for Linux and Git-GitHub, providing a handy reference for daily use and advanced operations. By mastering these commands, you'll enhance your productivity and become more proficient in managing your development environment. Remember, practice is key to becoming comfortable with these tools, so don't hesitate to experiment and explore further.
Happy coding and contributing to the DevOps community! ๐๐
Thank you for reading our DevOps blog post. We hope you found it informative and helpful. If you have any questions or feedback, please don't hesitate to contact us.
I hope this helps!
Happy Learningโจ
Subscribe to my newsletter
Read articles from Rahul Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Rahul Gupta
Rahul Gupta
Hey there! ๐ I'm Rahul Gupta, a DevOps Engineer passionate about all things AWS DevOps Technology. Currently, on a learning adventure, I'm here to share my journey and Blogs in the world of cloud and DevOps. ๐ ๏ธ My focus? Making sense of AWS services, improving CI/CD, and diving into infrastructure as code. Whether you're fellow interns or curious enthusiasts, let's grow together in the vibrant DevOps space. ๐ Connect with me for friendly chats, shared experiences, and learning moments. Here's to embracing the learning curve and thriving in the exciting world of AWS DevOps Technology!