Table of contents
Linux Commands :
Certainly, here's a Linux command cheat sheet with some commonly used commands and their brief descriptions. Remember that Linux offers a vast array of commands, so this list is not exhaustive, but it should give you a good starting point.
Basic Commands:
ls
: List files and directories.cd
: Change directory.pwd
: Print working directory.cp
: Copy files/directories.mv
: Move (rename) files/directories.rm
: Remove files/directories.mkdir
: Create a directory.rmdir
: Remove a directory (if empty).cat
: Concatenate and display file content.echo
: Print text to the terminal.man
: Display the manual for a command.help
: Get help for shell builtins.
File Operations:
touch
: Create an empty file.nano
orvim
: Text editors for file editing.head
: Display the beginning of a file.tail
: Display the end of a file.grep
: Search for text in files.find
: Search for files and directories.wc
: Count lines, words, and characters in a file.chmod
: Change file permissions.chown
: Change file ownership.
System Information:
uname
: Display system information.df
: Display disk space usage.free
: Display memory usage.top
: Display real-time system processes.ps
: Display information about processes.uptime
: Display system uptime.who
: Display logged-in users.
Package Management:
Package managers can vary based on the Linux distribution. Here are a few examples:
apt
(Debian/Ubuntu)dnf
(Fedora)pacman
(Arch Linux)zypper
(openSUSE)Commands:
sudo apt update
: Update package list (Debian/Ubuntu).sudo apt install package_name
: Install a package (Debian/Ubuntu).sudo apt remove package_name
: Remove a package (Debian/Ubuntu).sudo dnf install package_name
: Install a package (Fedora).sudo dnf remove package_name
: Remove a package (Fedora).sudo pacman -S package_name
: Install a package (Arch Linux).sudo pacman -R package_name
: Remove a package (Arch Linux).
Networking:
ifconfig
orip
: Display network interfaces and configuration.ping
: Send ICMP echo requests to a host.netstat
: Display network statistics.ss
: Display socket statistics.ssh
: Securely connect to a remote server.scp
: Securely copy files between hosts.
Remember to use the man
command for more detailed information about each command. The commands and package management examples may vary slightly depending on the Linux distribution you're using.
Git - Github commands :
Git Commands:
git init
: Initialize a new Git repository.git clone <repository_url>
: Clone a remote repository to your local machine.git status
: Check the status of your repository.git add <file(s)>
: Add changes to the staging area.git commit -m "Commit message"
: Commit the changes in the staging area with a message.git commit -am "Commit message"
: Stage and commit changes in one step.git log
: View commit history.git diff
: View commit differences.git diff --staged
: View changes in the staging area.git checkout -- <file(s)>
: Discard changes in the working directory.git reset HEAD <file(s)>
: Unstage changes from the staging area.git revert <commit_hash>
: Revert a commit.git reset --hard <commit_hash>
: Reset to a specific commit.git branch
: List, create, or delete branches.git checkout <branch_name>
: Switch to the specified branch.git checkout -b <branch_name>
: Create and switch to a new branch.git merge <branch_name>
: Merge the specified branch into your current branch.git branch -d <branch_name>
: Delete a branch.git tag <tag_name>
: Create a lightweight tag.git tag -a <tag_name> -m "Tag message"
: Create an annotated tag.git stash
: Temporarily save changes to a stack for later use.git stash apply
: Apply the last stashed changes.git stash pop
: Apply and remove the last stashed changes.git stash list
: List stashed changes.git stash drop
: Discard the last stashed changes.git remote add <remote_name> <repository_url>
: Add a remote repository.git remote -v
: List remote repositories and their URLs.git push <remote_name> <branch_name>
: Push your local commits to a remote branch.git fetch <remote_name>
: Fetch changes from a remote repository.git pull <remote_name> <branch_name>
: Pull changes from a remote branch into your local branch.
GitHub Commands:
git pull-request
: Create a pull request for code review and merging on GitHub.git merge <pull_request_branch>
: Merge a pull request into the main branch on GitHub.git push --tags
: Push tags to the remote repository on GitHub.git remote set-url origin <new_repository_url>
: Update the URL of the remote repository (e.g., when switching from HTTPS to SSH).git remote remove <remote_name>
: Remove a remote repository from your local configuration.git reflog
: View the history of references (useful for recovering lost commits).git clean -n
: List untracked files that will be removed withgit clean -f
.git log --graph --oneline --all
: Visualize the commit graph in a concise way.git cherry-pick <commit_hash>
: Apply a specific commit from one branch to another.git rebase <branch_name>
: Reapply commits on top of another base branch.
Remember to refer to official documentation or use git --help
for more information on each command. Regular usage and practice with these commands will improve your efficiency and proficiency in version control and collaboration with Git and GitHub.