# Commonly Used Linux Commands

#### 1. `ls` - List Directory Contents

Displays files and directories within a given directory.

* **Popular flags**:
  * `-l`: Long listing format (permissions, owner, size, etc.)
  * `-a`: Show all files, including hidden files
  * `-h`: Human-readable file sizes

#### 2. `cd` - Change Directory

Used to navigate between directories.

* **Popular usage**:
  * `cd /path/to/directory`: Navigate to a specific directory
  * `cd ..`: Move to the parent directory
  * `cd ~`: Move to the home directory

#### 3. `pwd` - Print Working Directory

Displays the full path of the current directory.

* **Popular usage**:
  * No common flags; it simply prints the path of your current directory.

#### 4. `cp` - Copy Files and Directories

Copies files or directories from one location to another.

* **Popular flags**:
  * `-r`: Recursive copy (used for directories)
  * `-v`: Verbose (shows the progress of the copy)
  * `-i`: Interactive (prompts before overwriting files)

#### 5. `mv` - Move or Rename Files and Directories

Moves files or directories to a new location or renames them.

* **Popular flags**:
  * `-v`: Verbose (shows the progress of the move)
  * `-i`: Interactive (prompts before overwriting files)

#### 6. `rm` - Remove Files or Directories

Deletes files or directories.

* **Popular flags**:
  * `-r`: Recursive (used to delete directories and their contents)
  * `-f`: Force delete (no confirmation prompts)
  * `-v`: Verbose (shows what is being deleted)

#### 7. `chmod` - Change File Permissions

Modifies the read, write, and execute permissions for files and directories.

* **Popular flags**:
  * `-R`: Recursive (change permissions for all files in a directory)

#### 8. `chown` - Change File Ownership

Changes the ownership of a file or directory to a different user or group.

* **Popular flags**:
  * `-R`: Recursive (change ownership for all files in a directory)
  * `--from=<current_owner>`: Change ownership from a specific user

#### 9. `ps` - Process Status

Shows information about the running processes.

* **Popular flags**:
  * `-e`: Show information for all processes
  * `-f`: Full-format listing
  * `-aux`: Displays detailed information about processes

#### 10. `top` - Real-Time System Resource Usage

Shows a real-time view of system processes, CPU, and memory usage.

* **Popular flags**:
  * `-d <time>`: Set delay time between updates

#### 11. `cat` - Concatenate and Display File Contents

Displays the contents of a file.

* **Popular flags**:
  * `-n`: Number all output lines
  * `-E`: Display `$` at the end of each line

#### 12. `grep` - Search Through Text

Searches for specific patterns in files or text.

* **Popular flags**:
  * `-i`: Case-insensitive search
  * `-r`: Recursive (search in all subdirectories)
  * `-v`: Invert match (show lines that do not match the pattern)

#### 13. `find` - Search for Files and Directories

Searches for files and directories based on various criteria.

* **Popular flags**:
  * `-name <name>`: Search for a file by name
  * `-type <d|f>`: Search by file type (d for directory, f for file)
  * `-exec <command>`: Execute a command on each file found

#### 14. `sudo` - Superuser Do

Runs commands with elevated (root) privileges.

* **Popular usage**:
  * `sudo <command>`: Run a command with root privileges

#### 15. `apt` - Package Manager for Debian-Based Systems

Used to manage software packages.

* **Popular flags**:
  * `update`: Updates the package list
  * `upgrade`: Upgrades all installed packages to the newest versions
  * `install <package>`: Installs a new package

#### 16. `df` - Disk Space Usage

Shows the available and used disk space on mounted filesystems.

* **Popular flags**:
  * `-h`: Human-readable output
  * `-T`: Show the file system type

#### 17. `du` - Disk Usage

Estimates and displays the space used by files and directories.

* **Popular flags**:
  * `-h`: Human-readable output
  * `-s`: Summarize the total size of a directory

#### 18. `tar` - Archive Files

Used for creating and extracting archives.

* **Popular flags**:
  * `-c`: Create a new archive
  * `-x`: Extract files from an archive
  * `-v`: Verbose (show the progress)
  * `-z`: Compress the archive using gzip

#### 19. `wget` - Download Files from the Web

Downloads files from the web via HTTP, HTTPS, and FTP.

* **Popular flags**:
  * `-q`: Quiet (no output)
  * `-O <file>`: Output the download to a specific file name

#### 20. `ssh` - Secure Shell

Used for remote login to another machine.

* **Popular flags**:
  * `-p <port>`: Specify the port number
  * `-i <identity_file>`: Use a specific identity file (private key) for authentication

#### 21. `man` - Manual Pages

Displays the manual for a command.

* **Popular usage**:
  * `man <command>`: Show the manual page for a specific command


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.battlecoder.com/battlecoder/notes/commonly-used-linux-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
