1. Computing & Technology

Introduction to Linux

From Machtelt Garrels

gives some errors involving file permissions, but all the errors have to do with private files that newguy doesn't need anyway. We will discuss in the next part how to change these permissions in case they really are a problem.

3.3.2.2.4. Removing files

Use the rm command to remove single files, rmdir to remove empty directories. (Use ls -a to check whether a directory is empty or not). The rm command also has options for removing non-empty directories with all their subdirectories, read the Info pages for these rather dangerous options.


       How empty can a directory be?
        

It is normal that the directories . (dot) and .. (dot-dot) can't be removed, since they are also necessary in an empty directory to determine the directories ranking in the file system hierarchy.

On Linux, just like on UNIX, there is no garbage can - at least not for the shell, although there are plenty of solutions for graphical use. So once removed, a file is really gone, and there is generally no way to get it back unless you have backups, or you are really fast and have a real good system administrator. To protect the beginning user from this malice, the interactive behavior of the rm , cp and mv commands can be activated using the -i option. In that case the system won't immediately act upon request. Instead it will ask for confirmation, so it takes an additional click on the Enter key to inflict the damage:


   

 mary:~> rm -ri archive/
 rm: descend into directory 'archive'? y
 rm: descend into directory 'archive/reports'? y
 rm: remove directory 'archive/reports'? y
 rm: descend into directory 'archive/backup'? y
 rm: remove 'archive/backup/sysbup200112.tar'? y
 rm: remove directory 'archive/backup'? y
 rm: remove directory 'archive'? y
 

We will discuss how to make this option the default in Chapter 7 , which discusses customizing your shell environment.

©2012 About.com. All rights reserved.

A part of The New York Times Company.