Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

already in your /home directory, you can use the following:


Click here to view code image
matthew@seymour:~$ rmdir music/directoryname


Or from anywhere using an absolute path, you can use this:


Click here to view code image
matthew@seymour:~$ rmdir /home/matthew/music/directoryname


Or from anywhere using a path shortcut, you can use the following command:


Click here to view code image
matthew@seymour:~$ rmdir ~/music/directoryname


The directory must be empty to be removed using rmdir. However, you can
remove a directory with its contents by using rm.


CAUTION
You cannot easily recover anything that has been deleted using rmdir or
rm, so proceed carefully. Be absolutely certain you will never need what
you are about to delete before you do so. Only a professional data recovery
service is likely to be able to recover the files, and even then at great
expense.

Deleting a File or Directory with rm


If you are the user matthew, to delete a file named filename, use this
command:


Click here to view code image
matthew@seymour:~$ rm filename


You can remove a file in a different location by changing what is after rm. To
remove a directory in /home/matthew/randomdirectory, if you are
already in your /home directory, you can use the following:


Click here to view code image
matthew@seymour:~$ rm randomdirectory/filename


Or from anywhere using an absolute path, you can use this:


Click here to view code image
matthew@seymour:~$ rm /home/matthew/randomdirectory/filename


Or from anywhere using a path shortcut, you can use the following command:

Free download pdf