Day 12: Cheat Sheets for Linux and Git: Simplified and Catchy Commands

Day 12: Cheat Sheets for Linux and Git: Simplified and Catchy Commands

ยท

3 min read

Table of contents

Now that you've learned the basics of Git and Linux, let's take a look at some easy-to-understand cheat sheets for these topics. These cheat sheets are like quick reference guides that list important commands in a simple way. Whether you're new to this or you've been using Git and Linux for a while, these cheat sheets will help you remember and use the most important commands easily. Let's get started and make your work simpler!

Linux Commands:

  1. pwd: Shows the current directory path.

  2. ls: Lists files and directories.

  3. ls -a: Lists all files and directories, including hidden ones.

  4. mkdir: Creates a new directory.

  5. rmdir: Removes an empty directory.

  6. vim: Opens a text editor and allows you to create or view a file.

  7. cat: Displays the content of a file.

  8. head -3 file_name: Shows the top three lines of a file.

  9. tail -3 file_name: Shows the last three lines of a file.

  10. diff f1 f2: Compares two files to find differences.

  11. chmod: Changes file permissions.

  12. chown: Changes the owner of a file.

  13. chgrp: Changes the group that owns a file.

  14. history: Shows the command history.

  15. Cron: Used for scheduling tasks like backups and maintenance.

  16. CronTab: Allows you to schedule and manage tasks.

  17. ls -ltr: Lists files with details, sorted by time.

File Permissions:

  • Read (r): Allows reading or viewing a file, or listing directory contents.

  • Write (w): Permits editing files or adding/removing files in directories.

  • Execute (x): Allows running executable files or accessing directories.

  • ACLs (Access Control Lists): Provide additional access control options.

  • getfacl: Shows ACL information.

  • setfacl: Modifies ACLs.

System Control Commands:

  • systemctl: Manages system services and units.

  • service: Used for controlling system services in older Linux distributions.

Git and GitHub Commands:

  1. sudo apt install git: Installs Git on Ubuntu.

  2. git init: Creates a new Git repository.

  3. git --version: Checks Git version.

  4. git clone <repository-url>: Downloads a remote repository to your computer.

  5. git status: Checks the current repository status.

  6. git add <file_name>: Stages a file for the next commit.

  7. git commit -m <Commit Message>: Makes a commit with a message.

  8. git push -u origin main: Pushes local commits to a remote repository.

  9. git revert <commit-id>: Reverts changes made in previous commits.

  10. git rebase <branch name>: Modifies previous commits.

  11. git merge: Combines branches while preserving commit history.

  12. git stash: Saves changes without committing.

  13. git log --oneline: Shows a condensed commit history.

  14. git checkout <branch_name>: Switches between branches.

  15. git cherry-pick <commit_id>: Applies changes from a specific commit.

  16. git push origin --delete <branch>: Deletes a remote branch on GitHub.

I hope this simplified cheat sheet helps you better understand these commands!

Conclusion

In a nutshell, these cheat sheets make it easy for anyone, whether you're new or experienced, to work with Linux and Git/GitHub. You can navigate your computer, handle files, and automate tasks with Linux. With Git, you can control versions and collaborate on projects. Keep these cheat sheets handy, and you'll be well-prepared for various tasks. Cheers to smoother work and better productivity with Linux and Git!

Did you find this article valuable?

Support Dipen's Blog by becoming a sponsor. Any amount is appreciated!

ย