
Getty Images
Dive into 9 Bash commands for Linux storage management
Learning these essential tools simplifies your life as an admin and enables you to manage Linux servers more effectively. Use these examples to start working with storage space.
Server storage management persists as a common Linux admin issue, as users rarely delete files and applications seem to generate increasingly larger documents. That's where Bash commands come in.
Go in depth here with some of the most common Linux storage management commands to help you review and maintain your available storage capacity.
Begin by understanding how the system identifies the storage areas with lshw, lsblk, blkid and cat /proc/partitions commands. Audit how the storage space is used with du and df. Manage storage device partitions with fdisk and parted. Use the mount command to attach the storage space to directories users can access.
Some commands have many options to explore after you learn the basics.
1. lshw
The lshw command displays information about detected hardware generated by the contents of the /proc directory. This tool displays results for many components, though it's the storage drives that are of interest here. You also have various options for structuring the results:
- -short. Provides basic information with hardware paths.
- -businfo. Provides bus information.
- -html. Structures the results in HTML.
- -xml. Structures the results in XML.
The most relevant option is -class disk -numeric, which displays storage device information.

Use this Linux storage management command to inventory your system's devices and the rest of its hardware. This information helps you determine whether to install additional storage devices or ensure that installed devices are recognized.
2. lsblk
The lsblk command lists block storage devices, including HDDs, SSDs, USB storage and optical drives. It displays results in a tree format to help you understand the relationship between storage devices and partitions. The command shows the device name, number, type and mount point. It also indicates whether the device is removable.
You can modify lsblk's output with various flags to show necessary configuration or troubleshooting information. Try the -f option to add file system information to the lsblk output. Add the -t option to display topology information.
If you run lsblk without arguments, it displays all storage devices. Specify a particular storage device to focus the tool on it.
# lsblk
# lsblk /dev/sdb

The lsblk results are essential for understanding and identifying system storage devices. You use this information when working with tools like fdisk, parted, du and df, as discussed below.
3. blkid
The blkid command also displays useful storage device information for troubleshooting or modifying the system's configuration. It's highly customizable, so run man blkid for a complete list of features. It shows information for all block devices on the system when run without options or arguments.
Specify a device to show information about it, such as /dev/sdb. Use options like -L to identify block devices by label or -U to use the Universally Unique Identifier.
The output is useful when identifying devices you configure with fdisk or parted.

4. cat /proc/partitions
Many storage tools pull information from the /proc directory. However, it may sometimes be easier to view the hardware information stored there directly. One great example is displaying partition information. Partitions divide total disk capacity into smaller chunks for easier Linux storage management. Each partition has its own file system, such as XFS or ext4, and may be backed up or otherwise managed individually.
Display partition information by using the cat /proc/partitions command.
# cat /proc/partitions

5. fdisk
The fdisk partition manager has existed for a long time, but it's still an essential Linux storage management tool in every sys admin's arsenal. Use fdisk when you add storage capacity to a server and want to create partitions to organize new file systems.
Specify a storage device when you launch fdisk to begin your configuration.
# fdisk /dev/sdb

Display fdisk's help menu with the m command. Additional interactive mode commands include the following:
- n. Creates a new partition.
- d. Deletes an existing partition.
- w. Writes changes to the partition table and quits fdisk.
- q. Quits fdisk without writing changes to the partition table.
Always use caution when working with fdisk to avoid making accidental changes. It's a good idea to back up your data before opening the utility.
6. parted
Another common partitioning tool is the GNU Partition Editor (parted). This utility creates and deletes partitions, much like fdisk. It also resizes existing partitions, even with Windows file systems, such as New Technology File System.
Run parted by specifying a storage device -- you can get its identity using lsblk. Parted is interactive, and your first command will likely be help to display your configuration options.
# parted /dev/sdb
Use parted as an alternative to fdisk or when you need its more powerful resizing features to configure storage capacity.

Be careful with parted. You may lose access to data if you issue the wrong commands. Consider backing up your data before running parted.
7. mount
You need to make storage space available to users by mounting it. Create a directory, and then use the mount command to attach the capacity. For example, if you're adding storage space at /dev/sdb1 to support development projects, you might type these commands to attach it to the file system.
# mkdir /dev-projects
# mount /dev/sdb1 /dev-projects
Use the ls command to display the storage space.
Detach the storage capacity by using the umount command. Note the spelling -- it is umount, not unmount.
The mount and umount commands do not persist through reboots. You must edit the /etc/fstab file or create .mount files in the /etc/systemd/system directory to mount storage automatically.
Run the mount command to display all currently mounted file systems.
8. du
Two of the most common Linux storage analysis tools are du and df. Many administrators use these tools together, but they have distinct purposes and features. Both include helpful options to display the information you need.
The du command analyzes storage space usage within directories. This usage measures files and subdirectories within the target object to show which files consume the most space.

One of the most important options is -h, which formats the results into human-friendly measurements, such as gigabytes or terabytes.
The -s option summarizes the disk utilization results. Add the -c flag to display a total utilization summary after the per-file and per-directory output.
9. df
The df command summarizes free storage capacity across file systems. It's broader but vaguer than du.

The df command also recognizes the -h option to display output in easily understood sizes. Use the --total option to show summary information on free storage space. Use the df command's man page to discover even more options.
Both tools are essential, and many administrators use them back to back when analyzing storage capacity on a Linux system.
For example, suppose you're trying to determine whether to increase storage capacity on a file server that hosts projects for your internal development team. You might use df to determine how much free space currently exists before using du to display information about the largest projects.
Damon Garn owns Cogspinner Coaction and provides freelance IT writing and editing services. He has written multiple CompTIA study guides, including the Linux+, Cloud Essentials+ and Server+ guides, and contributes extensively to Informa TechTarget, The New Stack and CompTIA Blogs.