Cheatography
https://cheatography.com
cheat sheet for basic linux commands and filesystem
Linux files ystem
/ |
root directory of the entire file system hirarchy |
/bin/ |
Essential user command binaries |
/boot/ |
static files of the boot loader |
/dev/ |
device files |
/etc/ |
host-specific system configuration |
/home/ |
user home directories |
/lib/ |
essential shared libraries and kernel modules |
/media/ |
mount point for removable media such as USB |
/mnt/ |
mount point for a temporarily mounted filesystems |
/opt/ |
optional commercial software |
/sbin/ |
system binaries |
/usr/ |
user utilities and applications |
/usr/share/ |
shared files over the system |
/root/ |
home directory for the root user |
these are not all the filesystem directories ,but they're the most important to know
user accounts operations
sudo <command> |
do a command as a super user (root) |
passwd |
change the user password |
whoami |
show the current user |
who |
show user detaled data |
su <username> |
switch user |
sudo adduser <username> |
make new user |
sudo adduser <username> <groupname>> |
add existing user to a group |
sudo adduser <username> sudo |
add the user to the sudoers file (giving him the root privilage) |
sudo deluser <username> |
delete user account (doesn't remove his files in the home directory remove it yourself) |
other
uname -a |
displays detaled system information |
free |
display memory size (total,used and free sizes) |
free -h |
display memory size in human readable format |
lsblk |
list block devices |
badblocks <device> -v |
searches for bad sectors in device |
badblocks /dev/sda1 -v > file |
searches for bad sectors in sda1 and put the output in file |
the > here is a part of the command
|
|
Navigating directories
cd <directory> |
change directory:go to the given directory |
cd ~ |
change directory to home |
cd .. |
go up one directory |
cd - |
go to the previous working directory |
ls |
list directory contents |
ls -l |
use long listing format |
ls -lh |
use human readable long listing format |
find <file or directory> |
searchs for file or directory in the working directory |
locate <file or directory> |
searchs for file or directory in the whole system |
pwd |
print working directory |
the '<' and '>' are not used in the command they're just for making things here obvious
terminal tips
using up and down arrows |
navigating throw your command history |
ctrl+R |
searching for previously typed command in your history |
clear |
clears terminal |
history |
view command history |
<command> | less |
for long output commands: view only one page and give you the ability to navigate through output lines using arrow keys exit using Q |
<command> | more |
for long output commands: view only one page and give you the ability to navigate through output pages using Enter exit using Q |
<command> && <command> |
perform two commands one after the other |
man <comman or program> |
show manual of that program or tool |
|
|
operations on files and directories
cp <file> <target dir> |
copy file to a target directory |
mv <file> <target dir> |
move file to a target directory,and can be used to rename files |
rm <file> |
remove file |
rm -r <dir> |
remove directory recursively |
rm -i |
prompt for every removal |
rm -v |
explain what's being done |
nano <file> |
a terminal based text editor |
chmod <mode> <file> |
changes mode (permissions) of the file |
chmod -R <mode> <dir> |
change mode of directory and its contents recursively |
chown <owner> file |
change owner of the file |
chown <owner> : <group> file |
change owner and group of file |
mkdir <dir name> |
makes new directory |
zip <archive name> <files to be archived>> |
make a .zip archive including the selected files |
unzip <archive> |
extract the archive in the working directory |
apt package manager
apt search <package name> |
search for package in the database |
apt show <package name> |
show detaled information about the package |
sudo apt install <package name> |
install package, if it's already installed it will search for updates for it,if it's already the last version it tell you that |
sudo apt remove <package name> |
remove installed package |
apt list --installed |
list installed packages |
sudo apt autoremove |
remove the packages that has no use |
sudo apt update |
update packages database |
sudo apt upgrade |
upgrade installed software |
apt is just a front-end for apt-get so it won't be different if you use any of them but for some user interface inhancing
|
Created By
Metadata
Favourited By
Comments
rajawali, 09:14 29 May 22
super handy
Add a Comment
Related Cheat Sheets