Random Useful Linux Commands

These useful Linux commands and snippets are a reference for myself, all in one place, so I can refer to them quickly during my workflow without searching for them again and again. These are mostly valid for Debian/Ubuntu systems.

How many lines of code are there in a project?

How to see all the git commits concisely?

How long has a process been running?

How many vCPUs do I have?

How to setup aliases in ~/.bashrc

How to grep network traffic in realtime?

REF: ngrep man pages

What iptables input rules are in effect?

Why was a process killed?

REF: What killed my process and why?
REF: How to read dmesg from previous session?

What ports are open and what processes are listening?

REF: Netstat: See process name like in `ps aux`

How to limit the memory usage of journald?

How to clean up journal logs?

REF: How To Use Journalctl to View and Manipulate Systemd Logs

How many shells are connected?

REF: How to count how many shell/terminals are running?

How to restart the system?

How to disable wifi and Bluetooth on Raspberry Pi 3s?

How to release and renew all the DHCP-assigned IP addresses?

What DNS server(s) am I using?

More to come…