Removing a Directory In Linux

h‮ww//:sptt‬w.lautturi.com
Removing a Directory In Linux

To remove a directory in Linux, you can use the rmdir command. This command will remove the specified directory, but only if it is empty. If the directory contains any files or subdirectories, rmdir will not delete it and will instead display an error message.

For example, to delete an empty directory named "mydir", you can use the following command:

rmdir mydir

If you want to delete a directory that is not empty, you can use the rm command with the -r option to delete the directory and all of its contents. For example:

rm -r mydir

Be careful when using the rm command, as it can delete files and directories permanently without prompting for confirmation. Make sure you specify the correct directory name and use the -i option to confirm each file before deleting it.

rm -ri mydir

This will prompt you to confirm the deletion of each file and subdirectory in the "mydir" directory before deleting them.

Created Time:2017-10-30 14:27:16  Author:lautturi