Essential Linux Commands for Directory Navigation and File Management

Directory Navigation and Path Resolution

1. pwd

Prints the absolute path of the current working directory. This is useful for verifying your exact location within the filesystem hierarchy.

2. cd

Changes the active shell directory. It accepts both absolute paths (originating from the root /) and relative paths (originating from the current working directory).

3. ls

Lists the contents of a directory. When executed without arguments, it displays files and folders in the current location.

pwd                          # Verify current location
cd /opt/dev/modules          # Navigate via absolute path
ls                           # Display directory contents
pwd
cd ..                        # Step back to the parent directory
pwd
cd ./config                  # Enter a subdirectory using a relative path
pwd

File and Directory Creation

4. touch

Creates a new empty file. If the file already exists, it updates the access and modification timestamps without altering the content.

5. clear

Clears the terminla viewport, removing previous output from view. This behaves identically to the Ctrl+L keyboard shortcut.

6. mkdir

Creates a new directory at the specified path. Use the -p flag to generate parent directories automatically if they do not exist.

Removal and File System Manipulation

7. rm

Deletes files or directories. By default, it only removes regular files. Additional flags modify its behavior:

  • -r: Recursively removes directories and all nested contents.
  • -f: Forces deletion without prompting for confirmation.

Terminal color conventions: Compressed archives typically render in red, executable binaries in green, directories in blue, and standard text files in the default terminal color.

8. cp

Duplicates files or directory trees to a target destination.

Pattern 1: Copy a file into a directory

cp settings.json /etc/app/conf/    # Duplicate file into target folder

Pattern 2: Clone and rename a file

cp settings.json settings.bak.json # Create a renamed copy in the same location

Pattern 3: Duplicate a directory recursively

cp -a src_archive ../backup/       # Copy entire folder tree to parent directory

9. mv

Relocates files or directories, or renames them when the source and destination reside in the same path.

Pattern 1: Transfer to a specific directory

mv report.csv /tmp/analysis/       # Move file to a different directory

Pattern 2: Rename in place

mv report.csv final_report.csv     # Change the filename within the current folder

Pattern 3: Relocate a directory

mv build_artifacts ../release/     # Shift an entire folder to a new parent path

Tags: linux-cli bash file-management directory-navigation unix-utilities

Posted on Sat, 16 May 2026 17:49:10 +0000 by sanch