Linux Commands:
-
pwd - Print Working Directory Displays the full path of the current directory.
-
ls-List Directories Lists Files and Directories
- ls # Basic listing
- ls -la # Long format with hidden files
- ls -lh # Human-readable sizes
-
cd - Change Directory
- cd /path/to/dir # Go to specific path
- cd .. # Go up one level
- cd ~ # Go to home directory
-
mkdir-Make Directory
- mkdir new_folder # Create single directory
- mkdir -p path/to/nested # Create nested directories
-
rm- Remove Files/Directories
- rm file.txt # Remove file
- rm -r folder/ # Remove directory recursively
- rm -rf folder/ # Force remove (use with caution!)
-
cp - Copy Files/Directories
- cp file.txt backup.txt # Copy file
- cp -r src/ dest/ # Copy directory recursively
-
mv - Move/Rename Files
- mv old.txt new.txt # Rename file
- mv file.txt /new/path/ # Move file
Git Commands:
-
grep - Search Text Patterns
- grep "error" log.txt # Search in file
- grep -r "TODO" src/ # Recursive search
- grep -i "warning" file # Case-insensitive
-
git init - Initialize Repository
- git init # Initialize in current directory
- git init project-name # Create and initialize new directory
-
git clone - Clone Repository
- git clone https://github.com/user/repo.git
- git clone [email protected]:user/repo.git # SSH
-
git add - Stage Changes
- git add file.txt # Stage specific file
- git add . # Stage all changes
- git add -A # Stage all including deletions
-
git commit - Record Changes
- git commit -m "message" # Commit with message
- git commit -am "message" # Stage and commit tracked files
- git commit --amend # Modify last commit
-
git push - Upload to Remote
- git push origin main # Push to main branch
- git push -u origin main # Push and set upstream
- git push --all # Push all branches
-
git branch - Manage Branches
- git branch # List local branches
- git branch new-feature # Create new branch
- git branch -d branch-name # Delete branch
-
git merge - Combine Branches
- git merge feature-branch # Merge into current branch
- git merge --no-ff feature # Create merge commit
- git merge --abort # Cancel merge in progress