Skip to content

Chapter 2 of 7

Navigating and Managing the Filesystem

Linux organizes files in a single hierarchical tree rooted at /. To understand where you are at any moment, the pwd (Print Working Directory) command shows the absolute path of your current location. To inspect the contents of that directory, ls lists files and folders. Adding flags refines the output: ls -l shows a detailed view including permissions and sizes, ls -a reveals hidden files (those whose names begin with a dot), and ls -h produces human-readable sizes.

Movement between directories is handled by cd (Change Directory). You can supply an absolute path such as cd /var/log to jump directly to a known location, or use relative paths like cd .. to move up one level and cd ~ to return to your home directory. The home directory, located at /home/username, is each user's personal workspace and the default landing spot when a new shell opens.

Creating and organizing directories and files is fundamental daily work. mkdir directory_name makes a new directory, and mkdir -p /path/to/nested/dir creates any missing parent directories along the way. The touch filename command creates an empty file or updates the timestamp of an existing one, which is handy for placeholder files. For moving data around, cp source destination copies files (add -r for directories and -i for an interactive confirmation), while mv source destination either moves or renames items depending on whether the destination is a new path or a new name in the same directory. The rm command deletes files; rm -r removes directories recursively, and -f forces the action without prompting, so it should be used with care because deletions are permanent. You can also create pointers to existing files with ln: ln -s target linkname produces a symbolic link (a small reference that points to the original), while a plain ln target linkname creates a hard link that shares the same underlying data.

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.