Privacy Policy
© 2025 linux101.dev

File System Commands

A cheatsheet for navigating and managing files and directories on a Linux system.

Navigation

Change directory

cd /path/to/directory

Navigates to the specified directory.

cd ..

Navigates to the parent directory.

cd

Navigates to the home directory of the current user while the home directory is stored in the environment variable `HOME`.

cd ~

Also navigates to the home directory of the current user but uses special ~ notation which means "home" directory.

cd ~username

Navigates to the home directory of the specified user if you have privileges.

cd -

Switches to the previous directory you were in.

Show current directory

pwd

Prints the full path of the current working directory.

Listing Files and Directories

List contents of a directory

ls

Lists the files and subdirectories in the current directory.

Detailed list with options

ls -l

Shows a long listing with detailed information for each file or directory. The output columns typically represent:
`Permissions` | `Links` | `Owner` | `Group` | `Size` | `Modification Date` | `Name`

ls -a

Includes hidden files and directories (those that start with a dot `.`)

ls -A

Similar to `-a`, but does not show the `.` (current directory) and `..` (parent directory) entries.

ls -h

When used with `-l`, it displays file sizes in a human-readable format (e.g., 1K, 234M, 2G).

ls -la

A common combination to see a detailed list of all files, including hidden ones.

ls -1

Lists all files, one per line

Creating and Removing

Create a directory

mkdir new_directory_name

Creates a new directory with the specified name.

Create an empty file

touch new_file_name.txt

Creates a new, empty file or updates the timestamp of an existing file.

Remove a file

rm file_to_remove.txt

Deletes a file. It may prompt you for confirmation depending on file permissions.

Remove a directory

rm -r directory_to_remove

Recursively removes a directory and all of its contents.

Forcefully remove files/directories

rm -rf directory_to_remove

This is a powerful and dangerous command that **recursively** and **forcefully** removes a directory and its contents without any prompts. Use with extreme caution.