https://github.com/s4nkalp/linux-cheat-sheet
A list of essential LINUX information and commands every users should know
https://github.com/s4nkalp/linux-cheat-sheet
cheat-sheat cheatsheet linux
Last synced: 9 months ago
JSON representation
A list of essential LINUX information and commands every users should know
- Host: GitHub
- URL: https://github.com/s4nkalp/linux-cheat-sheet
- Owner: S4NKALP
- Created: 2023-02-21T15:14:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T15:15:16.000Z (over 3 years ago)
- Last Synced: 2025-02-15T12:47:50.227Z (over 1 year ago)
- Topics: cheat-sheat, cheatsheet, linux
- Homepage:
- Size: 2.93 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Linux Cheat Sheet
A curated list of essential Linux information and commands every user should know

# Index
**File Management** :file_folder:
• [Change Directories](#change-directories)
• [List Files](#list-files)
• [Current Directory](#current-directory)
• [File Contents](#file-contents)
• [File Creation](#file-creation)
• [File Deletion](#file-deletion)
• [Copy Files](#copy-files)
• [Move Files](#move-files)
• [Compare Files](#compare-files)
• [Symbolic Links](#symbolic-links)
**Permission Manipulation** :briefcase:
• [Accessors](#accessors)
• [Permissions](#permissions)
• [Symbolic vs Absolute](#symbolic-vs-absolute)
• [Change Ownership](#change-ownership)
• [Set Permissions](#set-permissions)
**Packaging** :package:
• [Sync Package List](#sync-package-list)
• [Query Packages](#query-packages)
• [Install Packages](#install-packages)
• [Delete Packages](#delete-packages)
• [List Packages](#list-packages)
• [Package Information](#package-information)
**Source Control** :octocat:
• [Clone Repositories](#clone-repositories)
• [Stage Files](#stage-files)
• [Commit Files](#commit-files)
• [Upload Files](#upload-files)
## Legend
• angle brackets ``
• square brackets `[optional option]`
• curly braces `{default values}`
• parenthesis `(miscellaneous info)`
• hastag `# comment`
:file_folder: File Management
In Linux everything is a file. Directories are just a list of files and for that reason, many programs such as `ls` and `mv` don't disctriminate
## Change Directories
change to a directory (home)
```bash
cd [dirPath]
```
## List Files
list all files in a directory (current)
```bash
ls [dirPath]
# including hidden
ls -A [dirPath]
```
## Current Directory
return path to working directory
```bash
pwd
```
## File Contents
output file content to terminal
```bash
cat
# first lines
head
# last lines
tail
```
## File Creation
make file
```bash
cat [someText] >
# join two files into a new file
cat >
# make directory
mkdir
```
## File Deletion
```bash
rm
# and directories
rm -r
# recursive force (without confirmation)
rm -fr
```
## Copy Files
copy files to a destination directory
```bash
cp
# and directories
cp -r
```
## Move Files
move files/directories to a destination
```bash
mv
# rename a file
mv
```
## Compare Files
check the difference between two files
```bash
diff
```
## Symbolic Links
create a link pointing to target file (shortcut)
```bash
ln -s
```
---
:briefcase: Permission Manipulation
Every file on a Linux system has read, write & execute permissions defined per user, group & other
## Accessors
[`u`]ser — who created the file
[`g`]roup — set of users with common permissions
[`o`]ther — anyone who isn't user or in groups
[`a`]ll — all of the above (`ugo`)
## Permissions
[`r`]ead — view file contents
[`w`]rite — edit/modify file
e[`x`]ecute — run executable or view directory
none - no rights (`-`)
## Symbolic vs Absolute
symbolic | absolute, read, write & execute per user, group & other command sequence table
• | u | g | o | ug | uo | go | a
--- | --- | --- | --- | --- | --- | --- | ---
**r** | `u=r`|`400` | `g=r`|`040` | `o=r`|`004` | `ug=r`|`440` | `uo=r`|`404` | `go=r`|`044` | `a=r`|`444`
**w** | `u=w`|`200` | `g=w`|`020` | `o=w`|`002` | `ug=w`|`220` | `uo=w`|`202` | `go=w`|`022` | `a=w`|`222`
**x** | `u=x`|`100` | `g=x`|`010` | `o=x`|`001` | `ug=x`|`110` | `uo=x`|`101` | `go=x`|`011` | `a=x`|`111`
**rw** | `u=rw`|`600` | `g=rw`|`060` | `o=rw`|`006` | `ug=rw`|`660` | `uo=rw`|`606` | `go=rw`|`066` | `a=rw`|`666`
**rx** | `u=rx`|`500` | `g=rx`|`050` | `o=rx`|`005` | `ug=rx`|`550` | `uo=rx`|`505` | `go=rx`|`055` | `a=rx`|`555`
**wx** | `u=wx`|`300` | `g=wx`|`030` | `o=wx`|`003` | `ug=wx`|`330` | `uo=wx`|`303` | `go=wx`|`033` | `a=wx`|`333`
**rwx** | `u=rwx`|`700` | `g=rwx`|`070` | `o=rwx`|`007` | `ug=rwx`|`770` | `uo=rwx`|`707` | `go=rwx`|`007` | `a=rwx`|`777`
## Change Ownership
set a user (and group) to a file
```bash
chown [:group]
```
## Set Permissions
define permissions per user, group & other of file
```bash
chmod
```
:package: Packaging
Installing programs in Linux is a bit different than on Windows. When you need a specific program, it's best to use your system's package manager to install software. Package managers handle dependencies, upgrading, querying, installing, removing, listing packages and much more. They severly reduce the complexity of installing software for the end-user
## Sync Package List
upgrade packages & sync repositories
```bash
# arch linux
pacman -Syu
# debian
apt update && apt upgrade
```
## Query Packages
search for a package
```bash
# arch linux
pacman -Ss [package]
# debian
apt search [package]
```
## Install Packages
install a package
```bash
# arch linux
pacman -S
# debian
apt install
```
## Delete Packages
uninstall a package
```bash
# arch linux
pacman -Runss
# debian
apt purge
```
## List Installed
list installed packages
```bash
# arch linux
pacman -Qe
# debian
apt list --installed
```
## Package Information
```bash
# arch linux
pacman -Si
# debian
apt info
```
:octocat: Source Control
Using below methods to clone an existing (empty) repository, means we can skip several unecessary, over-complicated commands
## Clone Repositories
download a repositories contents (& .git)
```bash
git clone https://github.com//
# or a specific branch
git clone -b --single-branch https://github.com//
```
﹡ _although this command uses github as a refrence, any suitable version control software should work as intended_
## Stage Files
add new or changed files to the staging area
```bash
git add .
```
## Commit Files
snapshot staged files with a message
```bash
git commit -m 'initial commit'
```
## Upload Files
upload staged files
```bash
git push
```