Skip to content

A list of essential LINUX information and commands every users should know

Notifications You must be signed in to change notification settings

S4NKALP/linux-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Linux Cheat Sheet

A curated list of essential Linux information and commands every user should know

OS-Linux-icon

Index

File Management 📁
 • Change Directories
 • List Files
 • Current Directory
 • File Contents
 • File Creation
 • File Deletion
 • Copy Files
 • Move Files
 • Compare Files
 • Symbolic Links
Permission Manipulation 💼
 • Accessors
 • Permissions
 • Symbolic vs Absolute
 • Change Ownership
 • Set Permissions
Packaging 📦
 • Sync Package List
 • Query Packages
 • Install Packages
 • Delete Packages
 • List Packages
 • Package Information
Source Control :octocat:
 • Clone Repositories
 • Stage Files
 • Commit Files
 • Upload Files

Legend

 • angle brackets <required argument>
 • square brackets [optional option]
 • curly braces {default values}
 • parenthesis (miscellaneous info)
 • hastag # comment

📁 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)

cd [dirPath]

List Files

list all files in a directory (current)

ls [dirPath]
# including hidden
ls -A [dirPath]

Current Directory

return path to working directory

pwd

File Contents

output file content to terminal

cat <filePath>
# first <N> lines
head <N> <filePath>
# last <N> lines
tail <N> <filePath>

File Creation

make file

cat [someText] > <filePath>
# join two files into a new file
cat <filePath> <filePath> > <filePath>
# make directory
mkdir <dirPath>

File Deletion

rm <filePath>
# and directories
rm -r <dirPath>
# recursive force (without confirmation)
rm -fr <dirPath>

Copy Files

copy files to a destination directory

cp <filePath> <dirPath>
# and directories
cp -r <dirPath> <dirPath>

Move Files

move files/directories to a destination

mv <filePath> <dirPath>
# rename a file
mv <fileName> <newFileName>

Compare Files

check the difference between two files

diff <filePath> <filePath>

Symbolic Links

create a link pointing to target file (shortcut)

ln -s <filePath> <linkName>

💼 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=r400 g=r040 o=r004 ug=r440 uo=r404 go=r044 a=r444
w u=w200 g=w020 o=w002 ug=w220 uo=w202 go=w022 a=w222
x u=x100 g=x010 o=x001 ug=x110 uo=x101 go=x011 a=x111
rw u=rw600 g=rw060 o=rw006 ug=rw660 uo=rw606 go=rw066 a=rw666
rx u=rx500 g=rx050 o=rx005 ug=rx550 uo=rx505 go=rx055 a=rx555
wx u=wx300 g=wx030 o=wx003 ug=wx330 uo=wx303 go=wx033 a=wx333
rwx u=rwx700 g=rwx070 o=rwx007 ug=rwx770 uo=rwx707 go=rwx007 a=rwx777

Change Ownership

set a user (and group) to a file

chown <user>[:group] <filePath>

Set Permissions

define permissions per user, group & other of file

chmod <permissions> <filePath>

📦 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

# arch linux
pacman -Syu
# debian
apt update && apt upgrade

Query Packages

search for a package

# arch linux
pacman -Ss [package]
# debian
apt search [package]

Install Packages

install a package

# arch linux
pacman -S <package>
# debian
apt install <package>

Delete Packages

uninstall a package

# arch linux
pacman -Runss <package>
# debian
apt purge <package>

List Installed

list installed packages

# arch linux
pacman -Qe
# debian
apt list --installed

Package Information

# arch linux
pacman -Si <package>
# debian
apt info <package>

: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)

git clone https://github.com/<user>/<repository>
# or a specific branch
git clone -b <branch> --single-branch https://github.com/<user>/<repository>

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

git add .

Commit Files

snapshot staged files with a message

git commit -m 'initial commit'

Upload Files

upload staged files

git push

About

A list of essential LINUX information and commands every users should know

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published