Table of contents
😊Linux Basic Commands :
ls
: List all the files or directoriesls -a
: Lists hidden files or directoriesls -l
: Long listing formatls -la
: Lists files and directories with detailed information like permissions, size, owner,etc:mkdir
: Create new directorymkdir -p A/B/C/D
: Multiple directory creationrmdir
: Remove directory(Empty directories only)rm -rf
: Remove multiple directories(the write-protected directory contains other files and subdirectories):cd
: Change directorycd ..
: Go back to the previous directory.cd/
: Move to the root directorypwd
: Print the current working directorysudo
: Allows regular users to run programs as root usertouch
: create an empty filerm
: Deletes a filemv
: move filecp
: Copy filecat
: Displays the file contentshistory
: list of all past commands typed in the current terminal sessionclear
: Clears the terminalgrep
: Search for a pattern in filesfind
: Search for files and directoriesman
: Display the user manual of any commandhostname
: List the hostname of the serverwhoami
: Show the current userwget
: Download files from the internetssh
: Secure Shell command in Linuxzip
: Zip files in Linuxunzip
: Unzip files in Linux.apt-get
- APT package handling utility
📒File Permission commands :
chmod
: Change file permissionschown
: Change file ownershipchgrp
: Change file group ownership
🙎♂️User management commands of Linux :
useradd
: Create a new userpasswd
: Set password for the userusermod
: change the existing user's datauserdel
: delete a Linux userusermod -a -G <groupname> <username>
: Add a user to a groupdeluser <username> <groupname>
: Remove a user from a groupfinger
: information about a particular user
⚙️Process management commands of Linux :
ps
: Display active processeskill
andkillall
: Kill active processes by process ID or nametop
: View active processes live with their system usagedf
: Check free disk spacefree
: Shows free and used memory (RAM)nice
: Starts a process with a given priorityrenice
**:**Changes priority of an already running process
💥Git Commands :
Git Configuration :
git config --global
user.name
"<name>"
: set author name to be used for all commits by the current usergit config --global
user.email
"<email address>"
: set author email to be used for all commits by the current usergit config --list
: show config information
Git Basics :
git init
: Initialize a new Git repository in the current directorygit add <file>
: Add a file to the staging areagit commit -m "commit message"
: Create a new commit with a messagegit clone <repository url>
: Clone a remote repository to your local machine.git status
: Show the current status of the repositorygit log
: Display the commit historygit log
--oneline : Displays the commit history in a single linegit diff
: View the differences between the working directory and the staging area.git rm <file>
: Remove a file from the repository and staging area
🌿Git Branching :
git branch
: list all of the branchesgit branch <branch>
: Create a new branchgit checkout -b <branch>
: creating and going to that branchgit checkout/switch <branch>
: For going to specific branchgit branch -d <branch>
: For deleting branchgit merge <branch>
: Merge branch into the current branch
💻Remote Repositories :
git remote -v
: View a list of remote repositoriesgit remote add origin <remote repo_url>
: Add remote origin URLgit remote remove origin
: Remove the remote origin URLgit push origin <branch>
: Push local repository to remote repositorygit pull origin <branch>
: Pull remote repository to local repositorygit remote set-url <remote> <url>
: Update the URL of a remote repositorygit fork
: Create a copy of a repository on your GitHub account (forking)
🍒Cherry-pick :
git cherry-pick [commit_id]
: Merge specific commit from another branch to your current branch
Git revert :
git revert <commit_id>
: Undo a single given commit, without modifying commits that come after it
Git reset :
Go back to specific commit
git reset <commit_id>
Git rebase :
git rebase
: Reapply commits on top of another base tip.
Git stash :
git stash
: Temporarily store changes not ready for a commitgit stash list
: List all stashed changesgit stash pop
: Apply and remove the most recently stashed changesgit stash drop
: Delete a specific stashgit stash apply
: Apply the changes from a specific stashgit stash clear
: Remove all stashes
📍 Conclusion :
In this session, we have prepared some essential Linux and Git Command Cheat Sheet. on this blog we explore how to navigating directories, managing files, user managment and processes managment in Linux & in Git initializing repositories, Configuration of git creating commits, and collaborating on remote repositories.
Thank you for reading!
Contact me at :
linkedin: https://www.linkedin.com/in/sutish-pradhan/
E-mail: psutish@gmail.com