您的位置:首页 > 运维架构 > Linux

Linux 常用命令3-- 目录操作rmdir 和 rm

2016-02-28 17:49 666 查看
rmdir 删除文件或目录 全称: Remove Directory

使用方式 : rmdir [-p] 目录名称

参数:

-p:递归的删除目录(目录必须为空)

[root@localhost mail]# rmdir --help
Usage: rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.

--ignore-fail-on-non-empty
ignore each failure that is solely because a directory
is non-empty
-p, --parents   remove DIRECTORY and its ancestors; e.g., `rmdir -p a/b/c' is
similar to `rmdir a/b/c a/b a'
-v, --verbose   output a diagnostic for every directory processed
--help     display this help and exit
--version  output version information and exit


rm 删除文件或目录 全称: Remove

使用方式 : rm [-pr] 目录名称

参数:

-f:忽略不存在的文件,不出先警告信息

-i:互动模式,在删除前询问是否操作

-r:递归删除,常用在目录删除,相当危险

[root@localhost mail]# rm --help
Usage: rm [OPTION]... FILE...
Remove (unlink) the FILE(s).

-f, --force           ignore nonexistent files, never prompt
-i                    prompt before every removal
-I                    prompt once before removing more than three files, or
when removing recursively.  Less intrusive than -i,
while still giving protection against most mistakes
--interactive[=WHEN]  prompt according to WHEN: never, once (-I), or
always (-i).  Without WHEN, prompt always
--one-file-system  when removing a hierarchy recursively, skip any
directory that is on a file system different from
that of the corresponding command line argument
--no-preserve-root  do not treat `/' specially
--preserve-root   do not remove `/' (default)
-r, -R, --recursive   remove directories and their contents recursively
-v, --verbose         explain what is being done
--help     display this help and exit
--version  output version information and exit

By default, rm does not remove directories.  Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.

To remove a file whose name starts with a `-', for example `-foo',
use one of these commands:
rm -- -foo

rm ./-foo

Note that if you use rm to remove a file, it is usually possible to recover
the contents of that file.  If you want more assurance that the contents are
truly unrecoverable, consider using shred.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: