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=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
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