Remove files and directories in Linux

In this tutorial i will teach you the command to rename the Linux file and directories. Although this is very basic tutorial but it will help out the people who are just recently started to use Linux. In Linux the rm command is used to remove the files and directories from the file system.

The general syntax of rm command is

The general syntax for rm is:

rm [options] [-r directories] filenames

In order to remove the file you need to write the following command.

$ rm file

The rm command can be used with the attribute -i which means interactive mode, by using this user will be prompted before the deletion of the file

$ rm -i file

You can also delete multiple files at once by using this command

$ rm file1 file2

To Remove the directory with files or without files

rm -r directory

The rm command with — delimeter is supported which means it end of the option, it is normally used in the situation when the file or directory name begins with – dash. For example, this will remove the -test directory.

rm -r — -dir1

Linux command rmdir is different from rm because it can only delete the empty directories.

Be Sociable, Share!

Leave a Reply