Linux Cheat Sheet:
Navigation:
pwd
: Print working directory.ls
: List files and directories.cd <directory>
: Change directory.cd ..
: Move to the parent directory.cd ~
orcd
: Move to the home directory.
File Management:
touch <filename>
: Create a new file.mkdir <directory>
: Create a new directory.rm <filename>
: Remove a file.rm -r <directory>
: Remove a directory and its contents recursively.cp <source> <destination>
: Copy files or directories.mv <source> <destination>
: Move or rename files or directories.
File Viewing and Editing:
cat <filename>
: Display file content.less <filename>
: View file content interactively.nano <filename>
: Edit file in the Nano text editor.vim <filename>
: Edit file in the Vim text editor.
File Permissions:
chmod <permissions> <file>
: Change file permissions.chown <owner>:<group> <file>
: Change file owner and group.
Process Management:
ps
: List running processes.top
: Display dynamic real-time view of running system processes.kill <PID>
: Terminate a process by its ID.
System Information:
uname -a
: Display system information.df -h
: Show disk space usage.free -m
: Display free and used memory.
Networking:
ifconfig
: Display network interfaces and their configurations.ping <host>
: Send ICMP echo request to check connectivity.wget <URL>
: Download files from the internet.ssh <username>@<host>
: Connect to a remote host via SSH.
Package Management:
apt update
: Update package lists.apt upgrade
: Upgrade installed packages.apt install <package>
: Install a new package.apt remove <package>
: Remove a package.apt search <keyword>
: Search for packages.
User Management:
useradd <username>
: Add a new user.passwd <username>
: Change user's password.userdel <username>
: Delete a user.
Miscellaneous:
history
: Display command history.man <command>
: Display manual page for a command.sudo <command>
: Execute a command with superuser privileges.exit
: Close the current shell session.
This cheat sheet covers some of the most commonly used Linux commands for basic file management, system administration, process management, networking, and more. Always refer to the manual pages (man
) for detailed information on specific commands.
Git Cheat Sheet:
Configuration:
git config --global
user.name
"Your Name"
: Set username globally.git config --global
user.email
"
your.email@example.com
"
: Set email globally.git config --list
: List all Git configurations.
Initialization:
git init
: Initialize a new Git repository.git clone <repository_url>
: Clone a repository from a remote server.
Basic Commands:
git add <file>
: Add file(s) to the staging area.git commit -m "Commit message"
: Commit staged changes.git status
: Check the status of your working directory and staging area.git diff
: Show changes between working directory and staging area.git diff --staged
: Show changes between staging area and last commit.
Branching:
git branch
: List all local branches.git branch <branch_name>
: Create a new branch.git checkout <branch_name>
: Switch to a different branch.git merge <branch_name>
: Merge a branch into the current branch.git branch -d <branch_name>
: Delete a local branch.
Remote Repository:
git remote add <name> <url>
: Add a new remote repository.git remote -v
: List all remote repositories.git pull <remote> <branch>
: Fetch and merge changes from a remote repository.git push <remote> <branch>
: Push local commits to a remote repository.
Undoing Changes:
git reset <file>
: Unstage a file.git reset --hard
: Reset staging area and working directory to the last commit.git checkout -- <file>
: Discard changes in the working directory for a specific file.
GitHub Cheat Sheet:
Repository Operations:
git clone <repository_url>
: Clone a repository from GitHub.git remote add origin <repository_url>
: Add a remote repository as the origin.git push -u origin <branch>
: Push the local branch to GitHub.
Pull Requests:
Fork a repository: Create a personal copy of a repository.
Create a pull request: Propose changes from a forked repository to the original repository.
Review pull requests: Examine and comment on proposed changes.
Collaboration:
Collaborate using branches: Work on features or fixes in separate branches and merge them via pull requests.
Issue tracking: Use GitHub Issues to track tasks, bugs, and enhancements.
This cheat sheet covers the basics of Git and GitHub commands for version control, collaboration, and managing repositories. Remember to refer to the official documentation for more detailed information and advanced usage.