learn/phase-2/p2-w4/lesson 02
Week 4 · lesson 2

Linux: Searching, Permissions & Processes

Hands-on. Searching, file permissions, and running processes.

What you'll learn

  • Search inside and across files with grep and find.
  • Read a permission string from ls -la and change it with chmod.
  • List users and running processes with useradd and ps.

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, d directory
  • 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.

Check your understanding

3 questions

Type an answer and press Check. Grading is keyword-based and forgiving, so short answers are fine.

  1. 1

    ls -la shows -rwxr-xr-- on a file. Can members of the group execute it?

  2. 2

    Which command changes a file so only its owner can read and write it (mode 600)?

  3. 3

    Which command lists only the lines of notes.md that contain the word SSH?