This chapter gives you a deeper look at the ls command and introduces two new commands, file and less. It then guides you on a tour of the Linux file system, explaining the purpose of some of the most important directories.
Having More Fun with ls
The ls command is very powerful. It can do more than just list files:
- List other directories: You can specify a directory to list, like
ls /usr. - List multiple directories: You can list several directories at once, for example,
ls ~ /usr. - Use options: Commands can be modified with options (also called “switches”) and arguments. Options change how a command works. For example,
ls -lshows a long format listing with more details. Options are case-sensitive. Commonlsoptions:-aor--all: Shows all files, including hidden ones (which start with a period).-Aor--almost-all: Similar to-abut doesn’t show.(current directory) and..(parent directory).-d: Shows details about a directory itself, not its contents.-hor--human-readable: Shows file sizes in an easy-to-read format (like KB, MB, GB).-t: Sorts the list by modification time.ls -lt: this command produces long format output, and sort the result by the file’s modification timels -lt reverse: the same as before, but the order of the sort is reversed.
-S: Sorts the list by file size.-l: Long format. This gives you detailed information about each file, including:
- Access rights: The first part of the listing, like
-rw-r--r--, shows file permissions. The first character indicates the file type (e.g.,-for a regular file,dfor a directory,lfor a symbolic link). The next three characters are for the file’s owner, the next three are for the group that owns the file, and the final three are for everyone else. These permissions determine who can read, write, or execute the file. - Number of links, file owner, group owner, file size (in bytes), and the last modification date and time.
- Filename.
- Access rights: The first part of the listing, like
Determining a File’s Type with file
In Linux, a file’s name doesn’t always tell you what’s inside. The file command helps you find out the type of data a file contains. For example, file picture.jpg might tell you it’s a “JPEG image data” file. This command is useful because in Linux, the idea is that “everything is a file.”

Viewing File Contents with less
The less command is a program used to view text files. Many important system files and configuration files are simple text files.
- What is “Text”?: Text, specifically ASCII text, is a simple way of storing information where each character (like a letter or number) is mapped to a unique number. It is very compact and differs from a complex word-processor document, which contains additional formatting information.
- Using
less: You use it like this:less filename. It allows you to scroll through the file page by page. - Navigating in
less: You can use theup/down arrowkeys,Page Up/Page Down(orspaceandb),gto go to the beginning, andGto go to the end. To exit, pressq.
Exploring the System
The Linux file system follows a standard layout called the Linux Filesystem Hierarchy Standard. Here’s a quick tour of some important directories:
/: The root directory. Everything starts here./bin,/sbin: Contain basic system programs (binaries). Modern systems often use/usr/binand/usr/sbininstead./etc: Contains all system-wide configuration files. These are mostly human-readable text files.- Examples:
/etc/fstab(mount points for storage devices),/etc/passwd(user accounts list).
- Examples:
/home: The location for user home directories. A normal user can only write files in their own home directory./lib: Contains shared library files used by the core system programs. These are similar to dynamic link libraries (DLLs) in Windows. This directory has been deprecated in modern distributions in favor of/usr/lib./usr: This is a very large directory tree containing most of the programs and support files for regular users./var: Contains data that changes often, such as log files (/var/log)./dev: A special directory that contains files representing hardware devices./procand/sys: These are virtual file systems that provide information about the Linux kernel and detected hardware.~/.configand~/.local: These two directories are located in the home directory of each desktop user. They are used to store user-specific configuration data for desktop applications.
The chapter also mentions that if your terminal gets scrambled after viewing a non-text file, you can type the resetcommand to fix it.
Symbolic and Hard Links
- Symbolic Links (Symlinks): A symbolic link is a special file that points to another file. It is like a shortcut in Windows. This is useful for managing different versions of a program or library. A long listing (
ls -l) shows a symbolic link with anlat the beginning and an arrow (->) pointing to the real file.- Example:
libc.so.6 -> libc-2.6.so
- Example:
- Hard Links: These are a different type of link that also allows a file to have multiple names, but they work in a different way. More about them will be explained later.
The chapter concludes by highlighting that Linux is an open system where you can examine many important files because they are stored as plain text.