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 to grep for a string and truncate the results?


How to find all the files of a certain extension that matches a regex pattern?


What regex can I use to find API keys in source code?


What are the top ten largest folders?


What are the IP address of my running Docker containers?


How many lines of code are there in a Java 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?


How many files are there in a folder and all child folders?


How to zip an entire folder and subfolders?


How to gzip a huge folder tree with hundreds of thousands of files and avoid OOM?


How to clear all Docker logs?


How to follow all the logs from Docker Compose?


Disk out of space but there is plenty of space?


How to show all available hardware and connected devices?


How to backup and restore an entire partition or disk?


How to audit all system calls?


How to search man pages for a keyword like ‘encrypt’?


How to find all files modified in the last 10 minutes?


How to rename all the files in a folder?


How to Rsync the files in the current folder?


How to label Screen sessions?


How to share wlan0 Internet with eth0?


How to find the largest files of a certain type recursively?


How to stop all running Docker containers at once?


How to run Linux Mint with Cinnamon in 2D mode (no hardware acceleration in a VM) and prevent the “Running software in rendering mode” message?


More to come…