Deleting Files and Directories

team bbl


To delete a file or a directory when in Konqueror, highlight the icon and right-click. Select eitherMove to Trash or Delete. Move to trash is the safer option because the file can be retrieved from the trash can so long as the trash hasn't been emptied. Files that are deleted are not retrievable.

Konqueror also allows you to delete a file or directory by using your mouse to drag it into the trash can on your desktop.

To delete a file from the command line, type:

 rm filename 

You can use wildcards (e.g., ch* or ch?) to delete more than one file at a time. Be very cautious when using wildcards. Linux allows you to issue a command like the following:

 rm * 

It deletes all the files in the current directory. It's easy to make a disastrous mistake using wildcards. Listing the files with the wildcard, such as with:

 ls * 

shows the files that will be deleted. It's worth a few seconds to be careful.

To remove a directory, use the command:

 rmdir dirname 

However, dirname needs to be empty. If it's not, you will get an error message and it won't be deleted. You can remove all the files and issue rmdir again. Or, you can use the rm command, as follows:

 rm -r dirname 

This will remove dirname and all its contents, including all nested directories. This command deserves a caution. Be sure you know what's in the directory and that you want to delete it all before issuing this command.

To delete files, you must have write permissions on the directory containing the files. You don't need to have write permissions on the files themselves. However, if you don't have write permissions on the file you are deleting, you will be asked whether you really want to delete the file. If you answer yes, the file is then deleted.

    team bbl



    Spring Into Linux
    Spring Into Linux
    ISBN: 0131853546
    EAN: 2147483647
    Year: 2005
    Pages: 362
    Authors: Janet Valade

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net