Linux: Searching, Permissions & Processes
Searching
grep SSH notes.md # print lines in notes.md that contain "SSH"
find . # list files under the current folder, recursively
grep searches inside files for matching text. find searches for files by name or location. Together they answer "where is that thing?" almost every time.
Permissions
Run ls -la and look at the first column:
-rw-r--r-- 1 learner learner 128 Jun 29 09:18 notes.md
Read it in groups of three after the first character:
- rw- r-- r--
type owner group others
- type:
-file,ddirectory - then owner, group, others, each can have read, write, execute
So rw-r--r-- means the owner can read+write, while group and everyone else can only read. chmod changes these:
chmod 600 secret.txt # owner read+write, nobody else anything
Permissions are a security control in miniature: they enforce who can do what to a file, the same idea as authorization, one lesson down.
Users and processes
useradd alice # create a user (needs root in the real world)
ps # list processes running in this session
ps shows what is running right now, with each process's PID (process id). Knowing what should be running is how you spot what should not be.
Try it
grep TCP notes.md, then find ., then ls -la and read a permission string, and finally ps to see the shell itself listed.