Skip to content

Chapter 4 of 7

Permissions, Searching, and Data Flow

Every file and directory in Linux carries a permission set that controls who can read, write, or execute it. These permissions appear in the output of ls -l as a string like rwxr-xr-x, broken into three triplets for the owner, the group, and everyone else. The chmod command changes them, either using octal numbers such as chmod 755 file (giving the owner full access and others read/execute), or symbolic forms like chmod u+x file to add execute permission for the user. Ownership itself is changed with chown user:group file, which requires root privileges when applied to files you do not own.

Searching through files and the filesystem is another everyday need. grep pattern file prints lines that match a pattern; -i makes the search case-insensitive and -r walks through directories recursively. To locate files by name, find /path -name "*pattern*" searches in real time, with -type f narrowing results to files and -type d to directories. For a faster alternative, locate filename queries a pre-built index updated by the updatedb command, returning matches almost instantly at the cost of slight staleness.

One of the shell's most powerful features is the ability to chain commands together and redirect their data. Output redirection with > writes a command's output to a file, overwriting any existing content, while >> appends to the file instead — for example, ls > list.txt saves a directory listing. Input redirection with < feeds a file into a command, as in sort < names.txt. Pipes (|) go further by sending the output of one command directly into another, enabling compositions like ls | grep txt to show only files whose names contain "txt". These primitives let you build complex data-processing pipelines from simple tools.

All chapters
  1. 1Introduction to the Linux Command Line
  2. 2Navigating and Managing the Filesystem
  3. 3Inspecting and Editing Files
  4. 4Permissions, Searching, and Data Flow
  5. 5Processes, Resources, and Shell Customization
  6. 6Networking and Package Management
  7. 7Archiving, Compression, and Automation

Drill it

Reading is not remembering. These come from the Linux Command Line deck:

Q

What is the Linux command line interface (CLI)?

The Linux CLI is a text-based interface for interacting with the operating system using commands entered via a terminal emulator, allowing users to perform task...

Q

What is a shell in Linux?

A shell is a program that interprets commands entered into the CLI, processes them, and communicates with the kernel; common shells include Bash (Bourne Again S...

Q

How do you open a terminal in Linux?

Use keyboard shortcuts like Ctrl+Alt+T on Ubuntu or search for 'Terminal' in the applications menu; it launches a shell session for command execution.

Q

What does the <code>pwd</code> command do?

The pwd (Print Working Directory) command displays the absolute path of the current working directory, helping users confirm their location in the filesystem.