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

2023-10-07 18:32

本文主要是介绍Linux 常用命令3-- 目录操作rmdir 和 rm,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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-emptyignore each failure that is solely because a directoryis non-empty-p, --parents   remove DIRECTORY and its ancestors; e.g., `rmdir -p a/b/c' issimilar 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, orwhen removing recursively.  Less intrusive than -i,while still giving protection against most mistakes--interactive[=WHEN]  prompt according to WHEN: never, once (-I), oralways (-i).  Without WHEN, prompt always--one-file-system  when removing a hierarchy recursively, skip anydirectory that is on a file system different fromthat 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 exitBy 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 -- -foorm ./-fooNote 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.

这篇关于Linux 常用命令3-- 目录操作rmdir 和 rm的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/159659

相关文章

Ubuntu 24.04启用root图形登录的操作流程

《Ubuntu24.04启用root图形登录的操作流程》Ubuntu默认禁用root账户的图形与SSH登录,这是为了安全,但在某些场景你可能需要直接用root登录GNOME桌面,本文以Ubuntu2... 目录一、前言二、准备工作三、设置 root 密码四、启用图形界面 root 登录1. 修改 GDM 配

Linux进程CPU绑定优化与实践过程

《Linux进程CPU绑定优化与实践过程》Linux支持进程绑定至特定CPU核心,通过sched_setaffinity系统调用和taskset工具实现,优化缓存效率与上下文切换,提升多核计算性能,适... 目录1. 多核处理器及并行计算概念1.1 多核处理器架构概述1.2 并行计算的含义及重要性1.3 并

JSONArray在Java中的应用操作实例

《JSONArray在Java中的应用操作实例》JSONArray是org.json库用于处理JSON数组的类,可将Java对象(Map/List)转换为JSON格式,提供增删改查等操作,适用于前后端... 目录1. jsONArray定义与功能1.1 JSONArray概念阐释1.1.1 什么是JSONA

Linux线程之线程的创建、属性、回收、退出、取消方式

《Linux线程之线程的创建、属性、回收、退出、取消方式》文章总结了线程管理核心知识:线程号唯一、创建方式、属性设置(如分离状态与栈大小)、回收机制(join/detach)、退出方法(返回/pthr... 目录1. 线程号2. 线程的创建3. 线程属性4. 线程的回收5. 线程的退出6. 线程的取消7.

Linux下进程的CPU配置与线程绑定过程

《Linux下进程的CPU配置与线程绑定过程》本文介绍Linux系统中基于进程和线程的CPU配置方法,通过taskset命令和pthread库调整亲和力,将进程/线程绑定到特定CPU核心以优化资源分配... 目录1 基于进程的CPU配置1.1 对CPU亲和力的配置1.2 绑定进程到指定CPU核上运行2 基于

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

Linux在线解压jar包的实现方式

《Linux在线解压jar包的实现方式》:本文主要介绍Linux在线解压jar包的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux在线解压jar包解压 jar包的步骤总结Linux在线解压jar包在 Centos 中解压 jar 包可以使用 u

linux解压缩 xxx.jar文件进行内部操作过程

《linux解压缩xxx.jar文件进行内部操作过程》:本文主要介绍linux解压缩xxx.jar文件进行内部操作,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、解压文件二、压缩文件总结一、解压文件1、把 xxx.jar 文件放在服务器上,并进入当前目录#

Linux系统性能检测命令详解

《Linux系统性能检测命令详解》本文介绍了Linux系统常用的监控命令(如top、vmstat、iostat、htop等)及其参数功能,涵盖进程状态、内存使用、磁盘I/O、系统负载等多维度资源监控,... 目录toppsuptimevmstatIOStatiotopslabtophtopdstatnmon