see cheats
General #
Emergency #
Ctrl+Alt+F{1-12}
: Get virtual terminal (tty)- Magic SysRq key (Alt+SysRq+F)
reset
command (when terminal emulator messes up )
System information #
- User-space:
w
,id
,last
,uptime
,history
,uname
- Kernel:
lsmod
,dmesg
- CPU: lstopo
,
lscpu
,numastat
,hwloc-ls
,numactl
- Security: audit framework
, rflament/loggedfs
,
pscap
- Devices:
lspci
,libinput
,lsblk
- Containers:
lsns
Processes #
- Files:
fuser
,lsof
- Visual:
atop
, htop - Statistics:
dstat
(iotop
,nethogs
andtop
combined) - Debugging:
strace
,gcore
, bpftrace tools - Lookup/Signal:
pgrep
,ps
,pstree
,pkill
,killall
,kill
- Operations:
nohup
,disown
nohup
: IgnoresSIGHUP
and thenexec
the mentioned commanddisown
: shell utility that we can use to tell the shell not to send SIGHUP to that process.
- Resources
Files, devices and filesystems #
- Statistics:
df
,duf
(prettydf
),iotop
,iostat
- File
- inode:
stat
,file
- content:
strings
(useful w non-text files), stringsext ,filefrag
,dd
- inode:
- FS:
tune2fs
,dumpe2fs
,/proc/filesystems
- Block device:
blkid
,findmnt
,blockdev
(good for getting various sizes),/sys/block/sda/queue/scheduler
- Lookback devides:
losetup
(inspect io, sector size etc.) - Disk:
fdisk
,smartctl
- TO EXPLORE:
bcc
and0x.tools
(ebpf tooling)
Memory #
/proc/meminfo
/proc/buddyinfo
/proc/[pid]/smaps
/proc/[pid]/statm
/proc/[pid]/status
- Statistics:
free
,vmstat
,slabtop
- Inspection:
pmap
,vmtouch
Network & Security #
- Debugging:
traceroute
,tracepath
, dropreason - Inspection:
ss/netstat
(what all is running),ip
,nethogs
(realtime),tcpdump/wireshark/ngrep
,iperf3
- DNS:
drill
- Transfer:
socat/netcat
,rsync
- Reconnaissance:
nmap
- Links
Opinionated development practices #
SQL/Databases #
- Table names
- Should be singular. i.e
user
instead ofusers
. This also helps with foreign key names(user_id
), junction table names (eg.actor_film
foractor
andfilm
tables) etc. - But main deal is keeping it consistent, whatever we end up picking. Singular/Plural
- Sometimes may conflict with the database engine keywords, so consider using
prefix
- Should be singular. i.e
- Booleans columns
- better represented as nullable Timestamps
, Eg.
DELETED
column instead of bool should be timestamp of timestamp of deletion.
- better represented as nullable Timestamps
, Eg.
- Query building
- Check squirrel for dynamic query building when sqlc is not flexible enough
- Migrations
- While dropping tables, drop the ones with fk first when writing migrations
- If developing in golang, if using a migration tool(eg.
goose
) andsqlc
,sqlc
’sschema.sql
will have duplicate table create statement. It’s fine and OK to have this duplication.
- NULL
- If you have a column set to
NOT NULL
, you probably also want to set aCHECK (column_name <> '')
to it aswell, not always but most times.
- If you have a column set to
- Primary Keys
- Natural keys / Surrogate keys if applicable
- For identifier column name, if it has to be id, i’d prefer
id
over<table_name>_id
, just cleaner. - If not using serial keys, use timestamp ordered random ids instead of plain UUID (eg. ULID/UUIDv7)
- For pg, use pg_idkit
/
pg_uuidv7
- For pg, use pg_idkit
/
- Upserts
- TODO
Data Interchange #
- Don’t think too much and just do the manual conversion of timestamp to protobuf’s format from postgres when needed.
- If developing using golang and using
sqlc
andprotobuf
, we’d have two different generated structs of the same entity. They might look similar but they’re for different purposes, we want to keep this separated. One is for database and another one is for interchange.
Web #
- Fonts: https://fontsource.org/
- Color Scheme: https://www.radix-ui.com/colors/custom
- Icons:
pnpm i -D unplugin-icons
and thenpnpm i -D @iconify/json
(Search icons across all icon sets here )