teluzia.Cloud Engineer · Day 3
CHAPTER 01 · LINUX FUNDAMENTALS AND GIT

Permissions, ownership, pipes and redirection

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Linux access control and shell data flow meet in everyday commands. A file can exist yet be unreadable, and a command can produce both useful output and an error. Today you learn permission bits, ownership and the three standard streams, then connect programs with a pipe. Your lab uses only files in your home directory and deliberately removes read permission from one test file. You will restore it, compare overwriting with appending, and save errors separately from normal output. The goal is to explain who may access a file and where each command's output actually goes.

Think of it this way

Permissions are door keys; pipes are conveyor belts; redirection chooses the bin where a conveyor ends.

TOPIC 01 / 03Step by step

Permissions and ownership

A Linux file has an owner, a group and permission classes for owner, group and others. Read, write and execute mean different things for files and directories: directory execute permission allows traversal, while directory read permission allows listing names. ls -l shows these bits and names. chmod changes permissions; chown changes ownership and typically requires appropriate privilege. Numeric mode 600 permits the owner to read and write while denying group and others. Ownership is not authentication, and granting everyone write access is rarely an appropriate repair for a permission problem.

WORKED EXAMPLE
printf "private\n" > secret.txt; chmod 600 secret.txt; ls -l secret.txt
Why this matters

Reading permissions and ownership separately helps diagnose denied access without granting excessive privileges or changing system files that another account depends upon.

A common trap

Using chmod 777 as a universal fix exposes files to unintended users and can hide the actual ownership or directory-traversal problem underneath.

MAKE IT VISIBLE

Build the permission you mean

READ. WRITE. EXECUTE.

Who should be allowed to do what?

File permissions apply to the owner, group, and everyone else. Toggle a permission to see its symbolic and numeric forms.

Owner

rw-

Group

r--

Others

---
chmod 640 notes.txtrw-r-----
What this grants

Owner: read, write. Group: read. Others: no permissions. For a directory, execute means traversal; for a file, execute means permission to run it.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Permissions and ownership

A Linux file has an owner, a group and permission classes for owner, group and others. Read, write and execute mean different things for files and directories: directory execute permission allows traversal, while directory read permission allows listing names. ls -l shows these bits and names. chmod changes permissions; chown changes ownership and typically requires appropriate privilege. Numeric mode 600 permits the owner to read and write while denying group and others. Ownership is not authentication, and granting everyone write access is rarely an appropriate repair for a permission problem.

WORKED EXAMPLE
printf "private\n" > secret.txt; chmod 600 secret.txt; ls -l secret.txt

Why this matters

Reading permissions and ownership separately helps diagnose denied access without granting excessive privileges or changing system files that another account depends upon.

A common trap

Using chmod 777 as a universal fix exposes files to unintended users and can hide the actual ownership or directory-traversal problem underneath.

Standard streams and redirection

Processes conventionally receive input on standard input, write normal results to standard output, and report diagnostics on standard error. The shell's > redirects output to a file and truncates it before the program runs; >> appends instead. The form 2> redirects standard error. This is why command > log.txt can still show an error on screen. Redirections are processed by the shell, so sudo on a command does not automatically elevate the shell opening the output file. Keep lab output under your own home to avoid that complication.

WORKED EXAMPLE
cat missing.txt > normal.txt 2> errors.txt; cat errors.txt

Why this matters

Separating results from diagnostics preserves machine-readable output and gives you evidence when a script appears silent but has actually failed during execution.

A common trap

Using > when you intend to append silently replaces earlier notes; check the operator before running a command against an existing output file.

Pipes and exit status

A pipe connects the standard output of one process to the standard input of another without an intermediate file. Standard error does not automatically travel through that pipe. A command such as printf followed by sort and uniq composes simple operations into a transformation. In Bash, the status of a pipeline normally reflects its last command, so an earlier failure can be overlooked. set -o pipefail changes pipeline status reporting to expose failing stages. Inspect each stage while learning, and do not assume that output from the final stage proves every previous command succeeded.

WORKED EXAMPLE
printf "b\na\nb\n" | sort | uniq; expect a followed by b

Why this matters

Understanding stream connections and pipeline status prevents misleading success reports when one stage fails while later commands still produce plausible output for you.

A common trap

Assuming a pipe includes standard error or guarantees every stage succeeded can conceal upstream failures; inspect diagnostics and use pipefail in Bash scripts.

KEEP THESE WITH YOU

Today’s takeaways

Ownership and permission bits answer different questions.

Choose overwrite, append and diagnostic capture deliberately.

A successful last stage can hide an earlier pipeline failure.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed