This module describes how to manage disk space. First you will learn about the
du
command, which has several options for displaying the size of files and directories. This module also
explains how to save disk space by using file compression. You will learn the
compress
,
uncompress
, and
zcat
commands. Finally, you will learn to work with archives in various ways by using the
tar
command.
By the end of this module, you will be able to:
- Use
du
to display your disk usage
- Use
compress
and uncompress
to manage file sizes
- Use
zcat
to view compressed files
- Describe an archive
- Use
tar
cvf
to create an archive
- Use
tar
tf
to list the file names in an archive
- Use
tar
xvf
to extract files from an archive
There are several ways to manage space on a Unix system. One common method is to use the command line tool "df" to check the available disk space on all file systems, and "du" to check the space used by a specific directory or file.
The df command stands for "disk-free," and shows available and used disk space on the Linux system.
df -T
shows the disk usage along with each block's filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.) You can get this information in a graphical view using the Disks (gnome-disk-utility) in the GNOME desktop.
Another useful command is "find" which allows you to search for large files or directories that may be taking up unnecessary space. Additionally, you can use a tool such as "ncdu" which provides a more user-friendly, ncurses-based interface for exploring disk usage. Regularly cleaning up unnecessary files, removing old backups, and using a log rotation tool to limit the size of log files can also help to keep disk usage in check.