Document created by Jonas52
- Networking
- Security
- Packages
- Files
- System
- Hardware Information
- Users
- File Permission
- Keyboard Shortcuts
- Environment Variable Commands
networkctl status
hostname -I
ip addr show
ip address add
[IP_address]
ifconfig
netstat -pnltu
netstat -nutlp
whois [domain]
dig [domain]
dig -x host
reverse lookup of an IP address
host [domain]
wget [file_name]
ip link set <interface> up
ip link set <interface> down
ip route
ip route get <IP>
sudo ss -tulpn
Enable firewall: sudo ufw enable
List rules: sudo ufw status
Allow port: sudo ufw allow <port>
Deny port: sudo ufw deny <port>
Disable firewall: sudo ufw disable
ssh <user>@<host IP>
w
chage -l <user>
chage <user>
sudo passwd -l <user>
sudo passwd -u <user>
sudo apt install fail2ban
sudo fail2ban-client status
sudo fail2ban-client status <jail>
apt search <string>
snap find <string>
apt-cache policy <package>
apt list --upgradable
sudo apt update && sudo apt upgrade
sudo apt install <package>
sudo snap install <package>
sudo apt remove <package>
sudo snap remove <package>
sudo apt purge <package>
sudo apt install -f --reinstall
<package>
dpkg-query -L <package>
dpkg-query -S <path>
ls
list all files, including hidden
ls -al
nano file
vim file
cat file
pwd
diff
head
file
mkdir [directory]
rm [file_name]
rm -r [directory_name]
rm -rf [directory_name]
cp [file_name1] [file_name2]
cp -r [directory_name1] [directory_name2]
mv [file_name1] [file_name2]
or
rename [file_name1] [file_name2]
ln -s /path/to/[file_name] [link_name]
gpg -c [file_name]
gpg [file_name.gpg]
and bytes in a file
wc
create empty: touch <filename>
create with size: fallocate -l <size>
<filename>
create with content: echo "<content>" >
<filename>
locate <filename>
grep <string> <filename>
grep -Iris <string> <directory>
find <directory> -mmin -<n> -type
f
eg. find . -mmin -5 -type f
col<n> “<separator>” <filename>
eg. col2 “,” foo.csv
less <filename>
head -n <n> <filename>
tail -n <n> <filename>
tail -f <filename>
tar.gz: tar cvzf <target>.tar.gz
<source dir>
zip: zip -r <target> <source dir>
tar.gz: tar xf <tar.gz file>
zip: unzip <zip file>
rsync <filename> <user@
server>:<destination>
eg. rsync config.yaml
admin@192.0.0.0:/config
rsync -avruz <user@
server>:<source> <destination>
eg. rsync -avruz admin@192.0.0.0:/
config /tmp
uname -ar
reboot
poweroff
ps
man
history
systemctl
pstree
pmap
top
killall [proc_name]
bg
lsof
uptime
hostname
hostname -i
last reboot
date
timedatectl
cal
df -h
cat /proc/meminfo
timedatectl status
timedatectl list-timezones
sudo timedatectl set-timezone <zone>
mysql -u root -p
systemctl status <service>
systemctl --state running
systemctl --state failed
systemctl start/stop/restart <service>
systemctl cat <service>
systemctl edit <service>
journalctl -u <service> --since now -f
journalctl --boot 0
last
htop
kill <process id>
pkill <process name>
<command> &
# staying alive after hangup and logging to file
nohup <command> >> /var/log/yourcommand.log 2>&1 &
jobs
fg <n>
dmesg
df -h
df -i
fdisk -l
du -ah
du -sh
findmnt
mount [device_path] [mount_point]
cat /proc/cpuinfo
free -h
lshw
lsblk
lspci -tv
lsusb -tv
dmidecode
hdparm -i /dev/[disk]
hdparm -tT /dev/[disk]
badblocks -s /dev/[disk]
See general information about host bridge, VGA controller, ethernet controller, USB controller, SATA controller, etc.
lspci
dmidecode
cat /proc/cpuinfo
x86info or x86info -a
cat /proc/meminfo
lshw
lshw -C memory -short
hwinfo
biosdecode
dmidecode -s bios-vendor
lsusb
ls -la /dev/disk/by-id/usb-*
hdparm -I /dev/sdx
hdparm -tT /dev/sdx
Locate CD or DVD device file
whoami
finger[username]
id
last
who
w
groupadd [group_name]
adduser [user_name]
usermod -aG [group_name] [user_name]
sudo usermod -a -G sudo user
userdel [user_name]
usermod
su username
passwd username
chmod {ugo}{+-=}{rwx} <files>
chmod 777 [file_name]
chmod 755 [file_name]
chmod 766 [file_name]
chown [user] [file_name]
connect to host as user ownership of a file
chown [user]: [group] [file_name]
Ctrl + C
Ctrl + Z
Ctrl + W
Ctrl + U
Ctrl + K
Ctrl + Y
Ctrl + R
Ctrl + O
Ctrl + G
!!
exit
printenv or printenv variable_name
whereis and which
export MY_SITE="yourwebsite.com"
echo $VARIABLE
unset