Nov 21 2011

Delete File or Directory from Linux System

Category: Linux & UnixFatih Acar @ 00:11

rm and rmdir commands uses to delete from linux system. rm command use for delete file. On the other hand, rmdir command uses for delete directory from linux system. Also, rm command can delete directory with -rf option.

Firstly, we would create a directory and files for test.

create directory and files

#> mkdir /testdirectory
#> vi testfile1.abc
#> vi testfile2.cba

delete directory and files with rm command

#> rm -rf /testdirectory
Note : This command do that delete /testdirectory and files.
#>rm -f /testdirectory/testfile1.abc
Note : This command do that delete testfile1.abc

delete directory with rmdir command

#> rmdir /testdirectory
Note : If /testdirectory do not have file, this command can delete directory. Else, can not delete. You have to use rm -rf command for delete with files.

13,360 total views, 5 views today

Tags: Linux, System Administration

facebook comments:

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.