[Linux][3_文件与目录管理]

举报
John2021 发表于 2021/10/22 22:03:52 2021/10/22
1.6k+ 0 0
【摘要】 Linux目录机构为树形结构,根目录为/处理目录的常用命令ls(list directory contents), 列出目录cd(change directory), 切换目录pwd(print name of current/working directory), 显示当前目录mkdir(make directories), 创建一个新的目录rmdir(remove empty direc...

Linux目录机构为树形结构,根目录为/

处理目录的常用命令

ls(list directory contents), 列出目录

cd(change directory), 切换目录

pwd(print name of current/working directory), 显示当前目录

mkdir(make directories), 创建一个新的目录

rmdir(remove empty directories), 删除一个目录

cp(copy files and directories), 复制文件或目录

rm(remove files or directories), 移除文件或目录

mv(move (rename)files), 移动文件与目录, 或修改文件与目录的名称

在学习Linux中可以使用man来查看各个命令的使用文档。

ls

ls –l

man中的解释: use a long listing format(列出文件详细信息)

ls –a, --all

man中的解释: do not ignore entries starting with .(列出隐藏文件)

ls –r, --reverse

man中的解释: reverse order while sorting(逆序显示文件)

ls –R, --recursive

Man中的解释: list subdirectories recursively(递归显示文件)

ls –t

Man中的解释: sort by modification time, newest first(按照修改时间排序)

通配符

*, 匹配任意字符

?, 匹配单个字符

[xyz], 匹配xyz任意一个字符

[a-z], 匹配字符范围

[!xyz][^xyz], 匹配不在xyz中的任意字符

cp

cp -r, -R, --recursive

Man中的解释: copy directories recursively

cp -p

连同文件的属性一起复制过去,而非使用默认属性,常用于备份

Man中的解释: same as –preserve=mode,ownership,timestamps

cp --preserve[=ATTR_LIST]

Man中的解释: preserve the specified attributes (default:mode,ownership,timestamps), if possible additional attributes: context, links, xattr,all

cp -a

Man中的解释: -a, --archive                same as -dR --preserve=all,

                        --attributes-only        don't copy the file data, just the attributes

                        --backup[=CONTROL]       make a backup of each existing destination file

rm

rm -f, --force

Man中的解释: ignore nonexistent files and arguments, never prompt

rm -r, -R, --recursive

Man中的解释: remove directories and their contents recursively

mv

mv file1 dir/ 移动文件

mv file1 file2 重命名文件

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

作者其他文章

评论(0

抱歉,系统识别当前为高风险访问,暂不支持该操作

    全部回复

    上滑加载中

    设置昵称

    在此一键设置昵称,即可参与社区互动!

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。