Show Menu
Cheatography

Linux Basics Cheat Sheet by

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-s­pecific system config­uration
/home/
user home direct­ories
/lib/
essential shared libraries and kernel modules
/media/
mount point for removable media such as USB
/mnt/
mount point for a tempor­arily mounted filesy­stems
/opt/
optional commercial software
/sbin/
system binaries
/usr/
user utilities and applic­ations
/usr/s­hare/
shared files over the system
/root/
home directory for the root user
these are not all the filesystem direct­ories ,but they're the most important to know

user accounts operations

sudo <co­mma­nd>
do a command as a super user (root)
passwd
change the user password
whoami
show the current user
who
show user detaled data
su <us­ern­ame>
switch user
sudo adduser <us­ern­ame>
make new user
sudo adduser <us­ern­ame> <gr­oup­nam­e>>
add existing user to a group
sudo adduser <us­ern­ame> sudo
add the user to the sudoers file (giving him the root privilage)
sudo deluser <us­ern­ame>
delete user account (doesn't remove his files in the home directory remove it yourself)

other

uname -a
displays detaled system inform­ation
free
display memory size (total­,used and free sizes)
free -h
display memory size in human readable format
lsblk
list block devices
badblocks <de­vic­e> -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 direct­ories

cd <di­rec­tor­y>
change direct­ory: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 direct­ory>
searchs for file or directory in the working directory
locate <file or direct­ory>
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
<co­mma­nd> | 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
<co­mma­nd> | more
for long output commands: view only one page and give you the ability to navigate through output pages using Enter exit using Q
<co­mma­nd> && <co­mma­nd>
perform two commands one after the other
man <comman or progra­m>
show manual of that program or tool
 

operations on files and direct­ories

cp <fi­le> <target dir>
copy file to a target directory
mv <fi­le> <target dir>
move file to a target direct­ory,and can be used to rename files
rm <fi­le>
remove file
rm -r <di­r>
remove directory recurs­ively
rm -i
prompt for every removal
rm -v
explain what's being done
nano <fi­le>
a terminal based text editor
chmod <mo­de> <fi­le>
changes mode (permi­ssions) of the file
chmod -R <mo­de> <di­r>
change mode of directory and its contents recurs­ively
chown <ow­ner> file
change owner of the file
chown <ow­ner> : <gr­oup> file
change owner and group of file
mkdir <dir name>
makes new directory
zip <ar­chive name> <files to be archiv­ed>>
make a .zip archive including the selected files
unzip <ar­chi­ve>
extract the archive in the working directory

apt package manager

apt search <pa­ckage name>
search for package in the database
apt show <pa­ckage name>
show detaled inform­ation about the package
sudo apt install <pa­ckage 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 <pa­ckage name>
remove installed package
apt list --inst­alled
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
           
 

Comments

super handy

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          Linux Every Day Commands Cheat Sheet