The Linux Delete File Function for Novices

The Linux Delete File Function for Novices
Page content

Learning how to discard data you no longer need on your system using the Linux delete file function is essential to good management of resources. You have two options for removing unwanted files; the easiest and most popular way is to use the Graphical User Interface (GUI) available in your distribution. Please note that because of the numerous different flavors of Linux, not all GUI’s will look alike. Nevertheless, they all work basically the same. You usually right click on the file you want to delete, look for a menu window to appear, and choose the logical option to delete the file. That option may have various names.

The Linux Delete File Function in a GUI

I’ll use two Linux distributions (distros) to better illustrate the differences you’ll encounter. In Puppy Linux, you delete a file by right-clicking on it. A menu will appear in which you’ll see the name of the file on which you clicked. Your mouse pointer should automatically land on this name. Within a second, another menu will appear in which you’ll see the option “Delete Ctrl+X” and an icon of a trash can. You simply point your mouse over the delete option and click once. Alternatively, you can open the directory holding the file and press “Ctrl+X” then click on the file you want to discard.

Once you do this, Puppy will ask if you really want to delete the file. You have the options: Cancel, No, Yes, Quiet. If you don’t want to delete the file simply choose “Cancel” or “No.” If you do want to delete it without any further questions, choose “Quiet.” Choosing “Yes” will, in some cases, cause the system to verify the deletion of files. I’ve only seen this happen when deleting an entire directory, not just one single file. However, if you don’t want to be bothered with further questions, it’s best to choose “Quiet.” Below are screen shots of this Linux delete file function in Puppy; simply click to enlarge them.

Deleting Files in Puppy

Deleting a file in a GUI in the Fedora distro also requires right-clicking on the file to open a menu list in which you’ll see the option “Move to Trash.” That’s pretty self-explanatory. You can also click once to highlight the file and press the delete key. Keep in mind that the file still exists, it has just been removed to the trash which you’ll want to periodically empty, also accomplished by right clicking. The screen shot below shows what this operation looks like

File Deletion in Fedora

The Linux Delete File Function in a Terminal

If you’re a regular Microsoft Windows user, you’re probably not interested in the Linux delete file function on the command line. However, this basic operation isn’t hard and the more you learn to work in text-based mode, the more control you’ll have over the system.

You can access the interactive command prompt known as a shell by opening a terminal, called a console on some systems. In both Puppy and most versions of Fedora, you’ll see this option on the desktop or you can press Ctrl+Alt+F2. New users of Linux will be less comfortable with this way because you’ll be prompted to log in. The delete file operation from within a terminal can be more intimidating because you need some familiarity with the Linux file system to find your file. You’ll also need at least very basic UNIX commands which are beyond the scope of this article.

Basically, once you’re at the directory holding your file, you can type ls to list all files and sub-directories in it. You then type rm + fileName (replace “fileName” with the real name of your file) and press the enter key. You can verify the deletion by immediately typing ls to again list the files. This time the file you removed through the use of the rm command should not appear. In the screen shot below you can see how these commands were used to delete a sample file named “test.txt.”

Command Line File Deletion