This is a draft cheat sheet. It is a work in progress and is not finished yet.
System info
System and kernel |
uname -a |
Show IP and MAC |
ifconfig |
Hardware |
sudo lshw -short |
CPU |
sudo lscpu |
Drives |
sudo lsblk -a |
Hardware |
hwinfo |
All info |
inxi -Fx |
Running commands
Stop command |
CTRL + c |
Sleep command |
CTRL + z |
Input file to command |
cmd < file |
Stdout to file |
cmd > file |
Append stdout to file |
cmd >> file |
Stdout to screen and file |
cmd | tee file |
Run 1 and 2 |
cmd1 ; cmd2 |
Run 2 after 1 is successful |
cmd1 && cmd2 |
Run 2 if 1 is not successful |
cmd1 || cmd2 |
Kill with pid |
kill pid |
Kill with name |
pkill name |
Kill all with name beginning |
killall name |
Screenshots
Save screen |
Print |
Save window |
Print + ALT |
Save area |
Print + SHIFT |
Clipboard screen |
CTRL + Print |
Clipboard window |
CTRL + Print + ALT |
Clipboard area |
CTRL + Print + SHIFT |
PostgreSQL
Start |
psql dbname |
Show user |
select current_user |
Create database |
create database name |
List dabatases |
\l |
Exit |
\q |
|
|
File permissions
Change owner |
chmod user:group file |
Change mode |
chmod 755 file |
Change mode recursively |
chmod -R 600 folder |
First digit is owner, second group, third everyone |
Calculate by adding these numbers |
Read (r) |
4 |
Write (w) |
2 |
Execute (x) |
1 |
Services
|
SysVinit |
SystemD |
Start / stop / status / restart / reload |
Start service |
service name start |
systemctl start name |
|
update-rc.d |
chkconfig |
Add service |
update-rc.d name defaults |
chkconfig --add name |
Update service |
update-rc.d name start 20 3 4 5 |
chkconfig --level 345 <service> on |
Remove service |
update-rc.d -f <service> remove |
chkconfig --del <service> |
|
Debian |
RedHat |
List avtive units |
systemctl list-unit-files |
chkconfig --list |
List all units |
systemctl list-units |
Enable service |
systemctl enable name |
chkconfig name on |
Disable service |
systemctl disable name |
chkconfg name off |
|