3.4. Linux Cheat Sheet

Get Help:

man [command]

System Navigation:

Log into host:

ssh [username]@[host_name_or_ip_address]

move around in shell:

cd~; cd ..; cd -; cd /

log out:

exit; logout

reboot

sudo reboot

command history:

[arrow keys (up and down)]

autocomplete:

[start typing] tab

copy-n-paste in terminal:

[highlight & right-click]

Manage User:

add new user:

sudo adduser [username]

add user to group:

sudo adduser [username] [groupname]

user session:

users; who; w

list all users:

cut -d: -f1 /etc/passwd

list user’s groups:

groups

Manage Files

create empty files:

touch

create folder:

mkdir [foldername]

copy files:

cp [filename] [new_filename]

remove files:

rm [filename]

remove directory

rmdir [directory] (empty folder)

rm -r [directory_name]

move files:

mv [filename] [path]

rename file

mv [filename] [new filename]

change file permissions:

chmod [mode] [file]

Search for a file:

locate [filename]

find [dir] -name [filename]

Processes & Services

service management:

service [service] [status/restart/stop/start]

systemctl [status/restart/stop/start] [service_name]

monitor active services

top; htop

show all services:

ps -aef; service --status-all

stop services:

^-Z (suspend); ^-C (terminate); ^-D (end transmission)

stop processes:

kill [option] [process]

Networking & Software Management

network setting:

ip address

check connectivity:

ping [IP address]

install package:

sudo apt install [package]

update package:

apt install --only-upgrade [package]

remove package

sudo apt remove [package]