Finding, Deleting, and Compressing Files

Users often ask the Engineering Help Desk  what to do when they run out of disk quota in the home directory. One solution is to delete large, unneeded files, another is to compact files, and a third is to store files someplace not in your home directory. This write-up covers finding and deleting large files, using the zip or tar commands to compact files, and where else to store files.

Finding Large Files

Linux

One common problem in reducing your disk quota is finding what files are taking up your disk space. A simple way to view all your files is from a Linux workstation. You can either sit at a Linux workstation or connect to one from a Windows computer using SecureCRT or another ssh client. From the Linux command prompt, type:

% du -a | sort -k 1n,1

The du command summarizes your disk usage. The sort command sorts the files by size. The command shown above sorts from smallest to largest all files in the current directory and all directories contained below the starting directory. Because the sort starts with the smallest file, the end of the list shows the largest files. Deleting a large file is usually more efficient than deleting many small files. Often the largest files are core files or cache files, both of which you can delete.

For more help using the Linux computers or help on finding large files, see the ECS consultant at the Engineering Help Desk in 1253 SC, 319-335-5055, or send email.

Windows

To look at file sizes from a Windows computer, you must set Windows to show all files: open Computer; select Tools | Folder Options | View tab. Select Show hidden files, folders, and drives. Click OK. When viewing the folder (directory), you must show file details, so select View | Details. Sort files by size by clicking on the Size column of the file display, or right click in a file display, then select Sort by Size. Windows stores core files created by the NX Client for Windows in h:\.NX. There are some files that Windows will not display. For the most accurate list of files stored in your home directory, use the Linux du command discussed above.

Which Large Files to Delete

One way to keep your disk usage in check is to know what sorts of events and programs create large files and deleting those that you don’t need. The top quota killers are core files, cache files, and music and games files.

Core Files

Both Linux and Windows applications can create core files, large files that can usually be deleted. It is likely that any large file named "core" in your account has been created by an application that crashed or did not close properly. Some applications will identify the file as type "core" when they create the core file. (You may also have named a file “core,” which is a legitimate file.) You may find a core file after logging out of a Linux session with files still open.

Use the Linux file command to check the file type of any file. At a Linux command prompt, type:

% file core

where “core” is the name of the core file. You’ll see a response like this:
core: core file from 'Mathematica' - received SIGBUS
If you get a response like this, it is always safe to delete this core file. If you get a different message, use your best judgment as to whether the file is junk or legitimate.

Cache Files

Cache files, created by several applications to speed processing, can be deleted once the application is not running.For example, Firefox saves copies of pages you view during a session and puts them in H:\windowsdata\Application Data\Mozilla\Profiles\default\somestringoflettersandnumbers.slt\Cache. To remove Firefox cached files, go into the appropriate folder and empty the cache directory by deleting the files it contains.

Music & Game Files

Finally, look at the size of the music, video, and game files on your account. While you may enjoy having access to these files, they can be huge files. When you subtract the space used by class-related files from your quota, you may not have room for all your MP3 files. If you are getting near your quota limit, delete these files.

Compressing Files

Zipping Files

One very simple way to compress files that you aren’t using daily but still wish to save is to create a zip file. A zip file can be a condensed single file or a package file that combines one or more compressed files in a single, smaller file. Because zip files are compressed, they take up less disk space. The amount of reduction depends on how compressed the files were before you zipped them, as well as what type of file you are compressing. Creating a zip file lets you to keep files that you do not access daily while taking up less space.

From Linux

To zip a file from a Linux computer, go to the directory where the file is located and type:

gzip filename

This command zips that file and gives it the name filename.gz. To zip several files in the same directory, use:

gzip file*

which compresses all files that begin with “file”. If you add more filenames in the command, gzip will zip each file. The gzip command zips only individual files; it does not put several compressed files into a single file. To zip more than one file into a single compressed file, you must first "tar" the file (see below).

To unzip the file, type:

gunzip filename.gz

From Windows

To make a zip file on a Windows computer, you must first have a client that can zip and unzip files. The Hering and Elder lab Windows computers have WinRAR to zip and unzip files; go to Start | All Programs | WinRAR or type winrar in the search box.

To zip a file, right click the file and choose Add to archive or Add to filename.rar from the pop-up menu (see illustration). The first selection adds the file to other files you have chosen to be zipped into one, large file. The second selection creates a single, zipped file.

 
Disk Quota Usage
Disk Quota Usage
If you are zipping just one file, you are done. Your new zip file is placed into the same directory as the file you are zipping. If you are adding several files to one large zip file, select the files you would like to zip and choose Add to Archive. You will then be prompted by the window shown at right.

First choose the zip file you wish to add to, and the appropriate Action and Compression. If you’d like to save the file in .zip format, select ZIP under Archive format. Choose any other options as desired, and click OK. The resulting zip file is located in the same directory as the files you added.

For more information about WinRAR, see more information on WinRAR.

Creating Tar Files

If you are using a Linux computer and wish to put several smaller files into one single file, use the tar command. This command takes all of the listed files and makes a single file that contains all of them. This result is similar to a directory, except you can move a tar file just like a regular file, as well as compress the tar file in a manner such as zipping it. To make a tar file, from a Linux shell prompt type:

% tar -cvf filename.tar files_to_tar1 files_to_tar2

where filename.tar is the name for the new tar file that you are creating and files_to_tarx are the files that will be included in the new file. You can put as many files as you want into the tar file. Remember to put in the full path of the additional files if they are not in the same directory that you are currently in. To extract from a tar file, type:

% tar -xvf filename.tar

Other Ways to Save on Disk Space

Besides the above methods to save on disk space, another very easy and convenient way to save on disk space is to store the files elsewhere. Compact disks and DVDs are high capacity disks from which you can burn and retrieve data. All the computers in the labs, as well as faculty and staff machines, have a CD or DVD burner and software. Best practice is to keep a second copy of any important files on a different CD or DVD.

USB flash drives come in many sizes. Consider storing files you want to keep on a flash drive.

Another place to store files is local storage. Local storage on Linux is the /var/tmp directory; on Windows it is the D: drive. If you are working in the computing labs, don’t use local storage for important data and files, because the D:\ drives on Windows and the /var/tmp drives on Linux are cleaned (all contents removed) periodically to prevent them from being full. To access these drives, you must also be logged into that machine. Use local storage for files that you want to use now but not in the future, or files you can easily recreate if necessary.