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
• Clone Repositories
• Stage Files
• Commit Files
• Upload Files
• angle brackets <required argument>
• square brackets [optional option]
• curly braces {default values}
• parenthesis (miscellaneous info)
• hastag # comment
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 to a directory (home)
cd [dirPath]
list all files in a directory (current)
ls [dirPath]
# including hidden
ls -A [dirPath]
return path to working directory
pwd
output file content to terminal
cat <filePath>
# first <N> lines
head <N> <filePath>
# last <N> lines
tail <N> <filePath>
make file
cat [someText] > <filePath>
# join two files into a new file
cat <filePath> <filePath> > <filePath>
# make directory
mkdir <dirPath>
rm <filePath>
# and directories
rm -r <dirPath>
# recursive force (without confirmation)
rm -fr <dirPath>
copy files to a destination directory
cp <filePath> <dirPath>
# and directories
cp -r <dirPath> <dirPath>
move files/directories to a destination
mv <filePath> <dirPath>
# rename a file
mv <fileName> <newFileName>
check the difference between two files
diff <filePath> <filePath>
create a link pointing to target file (shortcut)
ln -s <filePath> <linkName>
Every file on a Linux system has read, write & execute permissions defined per user, group & other
[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
)
[r
]ead — view file contents
[w
]rite — edit/modify file
e[x
]ecute — run executable or view directory
none - no rights (-
)
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 |
set a user (and group) to a file
chown <user>[:group] <filePath>
define permissions per user, group & other of file
chmod <permissions> <filePath>
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
upgrade packages & sync repositories
# arch linux
pacman -Syu
# debian
apt update && apt upgrade
search for a package
# arch linux
pacman -Ss [package]
# debian
apt search [package]
install a package
# arch linux
pacman -S <package>
# debian
apt install <package>
uninstall a package
# arch linux
pacman -Runss <package>
# debian
apt purge <package>
list installed packages
# arch linux
pacman -Qe
# debian
apt list --installed
# arch linux
pacman -Si <package>
# debian
apt info <package>
Using below methods to clone an existing (empty) repository, means we can skip several unecessary, over-complicated commands
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
add new or changed files to the staging area
git add .
snapshot staged files with a message
git commit -m 'initial commit'
upload staged files
git push