---
# System prepended metadata

title: Navigating with the Command Line (Mac + Linux)

---

# Navigating with the Command Line (Mac + Linux)

1. **Opening the terminal**: To start, open your terminal application. On macOS, you can find it in the Utilities folder within the Applications folder, or by searching for "Terminal" using Spotlight. On Linux, it may be called "Terminal", "Konsole", "Gnome Terminal", or similar, depending on your distribution.

2. **Displaying the current directory**: To see the current directory you are in, type the following command and press Enter:

   ```
   pwd
   ```

3. **Listing files and directories**: To list the files and directories within your current directory, type the following command and press Enter:

   ```
   ls
   ```

   To view hidden files and directories as well, use the `-a` option:

   ```
   ls -a
   ```

4. **Changing directories**: To change to a different directory, use the `cd` command followed by the directory path. For example:

   ```
   cd Documents
   ```

   To move up one directory level, use the `..` notation:

   ```
   cd ..
   ```

   To navigate to your home directory, use the tilde `~` notation:

   ```
   cd ~
   ```

5. **Creating a directory**: To create a new directory, use the `mkdir` command followed by the desired directory name:

   ```
   mkdir new_directory
   ```

6. **Removing a directory**: To remove a directory, use the `rmdir` command followed by the directory name:

   ```
   rmdir directory_name
   ```

   To remove a non-empty directory, use the `rm` command with the `-r` option:

   ```
   rm -r directory_name
   ```

7. **Opening a file**: To open a file using its default application, use the `open` command on macOS:

   ```
   open file.txt
   ```

   On Linux, use the `xdg-open` command:

   ```
   xdg-open file.txt
   ```

8. **Creating a new file**: To create a new file, use the `touch` command followed by the desired file name:

   ```
   touch new_file.txt
   ```

9. **Removing a file**: To remove a file, use the `rm` command followed by the file name:

   ```
   rm file.txt
   ```