# File Storage and Compression

* `quota`
  * Luria has a disk usage quota on the head node. You can use the `quota` command to check what the size of the quota is and how much space you're currently using.
  * The `-s` flag will display the quota in a human-readable format. (e.g. 18K, 14M, 65G).

```bash
quota -s

Disk quotas for user asoberan (uid 247789): 
     Filesystem   space   quota   limit   grace   files   quota   limit   grace
/dev/mapper/cl-home
                  4391M  18432M    100G           24925       0       0        

# Space column shows how much space you're currently using on the head node
# Quota column is total amount of space allotted to you
```

* `du`
  * Stands for "disk usage". Reports how much disk space a directory is taken up.
  * Defaults to displaying the disk usage in kilobytes, but passing it the `-h` flag will return disk usage in a human-readable format. (e.g. 18K, 14M, 65G).
  * Will search the entire depth of the Unix tree starting from the directory you give it. You can control the depth which it searches by passing the `-d <num>` flag.

<pre class="language-bash"><code class="lang-bash"><strong># Displays the disk usage of every file under your home directory
</strong># The last entry will be the disk usage of your entire home directory
du -h ~

# Displays the disk usage of every file and directory immediately
# under your home directory
du -h -d 1 ~

# Displays the disk usage of one file, file.txt
du -h file.txt
</code></pre>

* `tar`
  * Combines multiple files or directories into one archive for easy sharing. Similar to "zipping" files, however tar does not compress by default.
  * Create an archive by passing the `-cf` flags
  * Can compress multiple files/folders using `gzip` by passing the `-z` flag when creating a new archive.
  * Useful when you have files that take up a lot of space and you want to save space.
  * Extract an archive by passing the `-xf` flags. Un-compress an archive by passing the `-z` flag to those two flags. &#x20;

```bash
# Create an archive of a directory and name it my_directory.tar
tar -cf my_directory.tar <directory>

# Create a compressed archive of a directory and
# name it my_compressed_directory.tar.gz
tar -czf my_compressed_directory.tar.gz <directory>

# Extract archive my_directory.tar
tar -xf my_directory.tar

# Uncompress the archive my_compressed_directory.tar.gz
tar -xzf my_compressed_directory.tar.gz
```

* `zip`
  * Zip multiple files and directories into one file. Zipping is similar to archiving with `tar`, but zipped files are easier to deal with on Windows machines.

```bash
# Zip a directory to the file my_directory.zip
zip my_directory.zip <directory>

# Unzip my_directory.zip
unzip my_directory.zip
```
