Disk and File Management Tools that Make Life Simpler

0
4229

If spare disk space could be sold, everyone would become rich. The gigabytes of free space in an average computer enables users to store more and more data. But without powerful and user-friendly software utilities, any storage medium is just a brick. Let’s list out some free file system tools that literally make life simpler for anyone who’s got something to store. These range from browsers to monitoring, backup and recovery tools.

Before we begin, please note that this article is not a definitive how-to for free file system tools. After you decide to go with one, make sure to read all the necessary documentation and do some test runs since fiddling with disk utilities can be risky.

File managers

First things first — browsing must be the first activity that a novice user performs on disks, as the setting up of the computer is left to experts. The popular way to do this is, of course, by using the so-called file managers, which offer multiple functionalities such as listing, creation, copying, moving, search, etc. The other way is to use dedicated command-line tools, manually.

An average user is familiar with the following navigational file managers:

  • Nautilus and its forks — Nautilus (a.k.a. GNOME files) is the default file manager of the GNOME desktop. Simple and straightforward, it offers easy navigation with breadcrumbs and tabs, works with network places, and even offers full-text search. However, the interface modernisation following the inception of GNOME3 has drawn considerable criticism, making its forks more popular, like Caja (pronounced kah-hah) and Nemo.
  • Thunar — The default one in Xfce, a good alternative if you don’t like the new Nautilus.
  • Konqueror — This KDE component tries to be a file manager, Web browser and file viewer, all at the same time, now focusing on the Web part more. Although it’s not too user friendly as a file manager, the search feature is useful.
  • Dolphin – This is the default KDE file manager.

There are other kinds of file managers, like orthodox file managers, 3D visualisers, etc. Orthodox managers usually provide two listing panes and a console pane. GNU Midnight Commander (sudo apt install mc in Debian based systems) is a text-based orthodox file manager, which means it works in the console (suitable for server management). A popular GUI counterpart is Krusader. It is advanced and capable of taking advantage of several low-level tools.

Figure 1: Krusader orthodox file manager

The power of commands: Those who have a grip on the command line interface will find it easier to manage files using the classic commands ls, cp, mv, mkdir, rm, etc, in certain scenarios. However, there is always the next level.

What if you want to find all files with the extension .txt? You can use the command ls *.txt, of course. But what if you want to perform a case-insensitive search for all files in all sub-directories that has the word ‘receipt’ somewhere in the path and has a name that ends with .pdf or .txt? The trick is to combine multiple commands:

find . -type f|grep -iE '.*receipt.*\.(pdf|txt)'

The full explanation of the above command is beyond the scope of this article. The ‘find’ command is used to list all the items in a given directory (and its children, recursively), while we can use the grep command to filter its output using regular expressions.

grep can also search inside files, and there is sed, which can perform editing also. If you are a programmer and want to rename a certain variable in multiple source files, sed is the tool you are looking for.

Bulk renaming: Selecting multiple files and choosing the Rename option will pop open the bulk renaming dialogue in some file managers like Nautilus and Thunar. There are standalone tools, too, which include krename.

Disk partitioning and monitoring

Popular GNU/Linux distros come with some handy disk management tools like GNOME Disks which can do all the basic tasks including mounting, unmounting, partitioning, formatting and benchmarking. However, if you are into advanced stuff, it may be better to go with the tools made for them.

gparted is perhaps the most popular GUI partitioning tool used in GNU/Linux. Apart from partitioning, it offers resizing and file rescue. gparted.org offers a live CD version also. The power of gparted comes from libparted, which in turn is part of GNU Parted, a console utility for partition management.

More low-level utilities include fdisk and gdisk. Although the man pages of both utilities claim they understand GPT and MBR schemes, fdisk is recommended for MBR based partitioning and gdisk is recommended for GPT partitioning.

Cautionary note: There are multiple partitioning schemes. Those that were MBR based used to be the popular ones for a long time, but GPT is the current trend. Never perform partitioning operations until you understand the difference and find out which one you are currently using, especially if you are in fear of data loss or OS loss.

Partitioning just marks a region. Formatting, or assigning a file system type (e.g., Ext4, FAT32, NTFS, etc) is a must to make it useful. GUI partitioning tools incorporate this capability, while in the command line, you have to invoke separate tools like mkfs.

Disk monitoring: Monitoring the usage and health of disks is very important. Having no space left can sometimes cause apps to stop working and the OS to not boot, without any warning.

Total usage in partitions can be monitored using GNOME Disks, gparted or the command df. One can simply use the command df -h to know the free space of all mounted partitions (the -h option is for human-readable output).

Space consumption of directories can be monitored using the du command. du -sh will give you the total usage of the working directory (the directory your shell is in), while dropping the s option will cause the usage of each child to be listed. See the man page for more details. If you’d rather use a text-mode tool, use ncdu. Or if you are into GUIs, you can use a disk usage analyser (like Baobab).

There is a technology called SMART to monitor the health of a hard disk. GNOME Disks has a menu entry for this (one has to select the disk first). Alternatively, one can use the command smartctl, provided by the Debian package smartmontools. There is also a GUI package called smart-notifier, which just gives warnings.

Figure 2: GNOME disk usage analyser (Baobab) visualises the space consumption of each directory

Copying, backup and version control

For copying directories locally or across a network, rsync is the tool. It can copy a whole directory, leaving the files that are already present and new on the destination, so that time and bandwidth can be saved. A sysadmin can use this to clone something or take a backup while Web developers can use this to update their websites. However, one can easily commit mistakes with it, so read more about it and experiment with it before testing it on important files.

Sometimes one needs a bit-by-bit copy of a disk, which is called a disk image. It is useful for safe data recovery, copying OS disks, backup, etc. While the classic UNIX commands cp and dd are capable of doing this, there are other user-friendly options like Clonezilla and GNOME Disks.

If you are one of those who believe copying doesn’t make for a good backup scheme, then go for Déjà Dup, which offers features like incremental backup and encryption. Déjà Dup relies on Duplicity, which in turn relies on rsync.

If you are a software developer or the manager of a project with text files, version control systems like Git are great to keep track of the changes and roll back when needed. However, they do not replace backups in case of disk failures.

Comparison and verification: diff helps to compare two files. But if you want to verify the integrity of a downloaded file by comparing it against the MD5 checksum that the publisher has given, use md5sum to calculate the checksum of the file you have.

diff has limited support for comparing two directories, but rsync will be more useful and practical for this purpose.

Archiving, compression, splitting and merging

Archiving is the process of encapsulating multiple files and directories into a single file while compression saves space. We usually use both while zipping. File managers usually provide options to create and manage them, but it would be useful to get familiar with the dedicated tools.

One can use commands like tar, 7z, zip, etc, to archive and compress files. Some provide encryption support also. For example, password support in 7z is considered good. GUI tools like GNOME Archive Manager (file-roller) help do these interactively. archivemount helps mount an archive and handle it just like a folder.

The split command helps to split a file into smaller chunks, which can later be joined using cat.

Encryption: LUKS is the de facto standard specification for full-disk encryption in GNU/Linux. This feature is listed in popular partitioning/formatting tools. One can also use the command line tool cryptsetup.

If you want to encrypt a single file or an archive, the options include gpg or simply the password feature supported by archiving formats like 7z.

RAID management

RAID can offer data protection and speed, based on the configurations we choose. In GNU/Linux, software RAID is created and managed using mdadm.

Repair and recovery

fsck is the standard tool to check and repair a Linux file system. This is useful in cases like unexpected power-offs. However, if one wants to recover deleted partitions and files, perhaps the best package is testdisk (which photorec is part of).

Cautionary note: Be warned that data recovery can be dangerous. Seek expert support if you are not sure about what you are doing.

Shredding and wiping

When one deletes a file, the system simply removes the link to it, and that’s why it’s a quick process. Although the actual contents of the deleted file will get overwritten as new files come, until then, the file can be recovered. To prevent this, one has to shred a file before deleting it, and the command is, well, shred.
srm (package: secure-delete) will do both shredding and deletion. There is also wipe, which helps to wipe the contents of a whole partition or disk.

Remote files

Popular file managers like Nautilus support network based file management, although sometimes one will need to install some supporting packages. There are different ways to handle remote files, and personally, I find SSH-based ones to be the most reliable on GNU/Linux. SFTP (not FTPS) is an SSH-based file transfer protocol, which benefits from the encryption and authentication features of SSH. Simply press Ctrl+L (to open the location bar) in Nautilus or a compatible one, and give the address sftp://IPADDRESS/OPTIONAL_PATH to access a remote directory.

There is a magical tool called sshfs which helps mount a remote directory so that it can be used like a local one. This is very useful in command-line-only situations.

Seems like our list itself can fill a disk… so it’s time to stop. Take this listing just as a starting point and start exploring!

LEAVE A REPLY

Please enter your comment!
Please enter your name here