# Cheat Sheet #day69 - umount

### `umount` Command Cheatsheet

The `umount` command in Unix-like systems is used to unmount filesystems and network shares from the directory tree. It is essential for safely detaching storage devices and network mounts. Here’s a quick reference guide:

#### Basic Syntax

```sh
umount [OPTION]... [DIRECTORY | DEVICE]
```

#### Common Options

* `-f`, `--force`: Force unmount (terminate processes using the mounted filesystem).
    
    ```sh
    umount -f /mnt/data
    ```
    
* `-l`, `--lazy`: Detach filesystem immediately, but clean up later (often used with NFS mounts).
    
    ```sh
    umount -l /mnt/nfs
    ```
    
* `-r`, `--read-only`: Unmount the filesystem as read-only.
    
    ```sh
    umount -r /mnt/data
    ```
    
* `-v`, `--verbose`: Verbose mode, print detailed information during the unmount operation.
    
    ```sh
    umount -v /mnt/data
    ```
    

#### Examples

1. **Unmount a directory:**
    
    ```sh
    umount /mnt/data
    ```
    
2. **Force unmount a directory (terminate processes using it):**
    
    ```sh
    umount -f /mnt/data
    ```
    
3. **Lazy unmount (detach immediately, clean up later):**
    
    ```sh
    umount -l /mnt/nfs
    ```
    
4. **Unmount a read-only filesystem:**
    
    ```sh
    umount -r /mnt/data
    ```
    

#### Additional Information

* **List mounted filesystems:**
    
    ```sh
    mount
    ```
    
* **Help option:**
    
    ```sh
    umount --help
    ```
    
* **View manual page for** `umount`:
    
    ```sh
    man umount
    ```
    

The `umount` command is essential for safely unmounting filesystems and network shares in Unix-like systems. It ensures that all data is flushed to disk and processes using the mounted filesystem are gracefully terminated. For more detailed options and usage scenarios, refer to the `man` page or use `umount --help`.
