Rocky Linux Core Commands: Page 1

This page covers fundamental commands for navigating your file system and managing directories.


1. ls - List Directory Contents

Purpose: The ls command is used to list the contents of a directory. It's one of the most fundamental commands for navigating and understanding your file system.

Syntax: ls [OPTIONS] [FILE...]

Key Options:

Examples:

ls
ls -l
ls -a
ls -lh /home/user/documents

2. cd - Change Directory

Purpose: The cd command allows you to change your current working directory. This is crucial for navigating the file system.

Syntax: cd [DIRECTORY]

Key Uses:

Examples:

cd /etc
cd my_project
cd ..

3. pwd - Print Working Directory

Purpose: The pwd command stands for "print working directory." It displays the full path of your current location within the file system.

Syntax: pwd

Example:

pwd

4. mkdir - Make Directories

Purpose: The mkdir command is used to create new directories (folders).

Syntax: mkdir [OPTIONS] DIRECTORY_NAME...

Key Options:

Examples:

mkdir new_folder
mkdir -p project/src/main

5. rmdir - Remove Empty Directories

Purpose: The rmdir command is used to remove empty directories. If a directory contains files or other subdirectories, rmdir will fail.

Syntax: rmdir DIRECTORY_NAME...

Example:

rmdir empty_folder