unit2、、linux中文件与目录的建立、删除以及移动,查看文件的信息,和linux中的帮助命令

本文主要介绍了Linux系统中文件和目录的操作命令。包括文件的建立(touch)、删除(rm)、复制(cp)、移动(mv)、查看(cat、less等),目录的建立(mkdir)、删除、复制,还提及文件时间标识、路径(相对和绝对)、自动补齐、属性查看等内容,以及命令帮助获取方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

########在系统中建立文件
1、touch命令

[root@desktop Desktop]# touch file file1
[root@desktop Desktop]# ls                 ####查看有哪些文件
file  file1

这样我们就建立了一个文夹,对于文件来说要注意以下几个:
文件是有时间的如下:

[root@desktop Desktop]# stat file1                ###查看file1的状态
  文件:"file1"
  大小:0         	块:0          IO 块:4096   普通空文件
设备:fd01h/64769d	Inode:41943195    硬链接:1
权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
最近访问:2019-08-12 12:13:58.971680076 -0400
最近更改:2019-08-12 12:13:58.971680076 -0400
最近改动:2019-08-12 12:13:58.971680076 -0400
创建时间:

我用的是翻译过后的的,但是和英语版的没多大区别,英文的是下面三个名称:
atime:文件内容被访问的时间标识
mtime:文件内容被修改的时间标识
ctime:文件属性或文件内容被修改的时间标识
touch是可以更改上面的时间的例如

[root@desktop Desktop]# touch file1
[root@desktop Desktop]# stat file1
  文件:"file1"
  大小:0         	块:0          IO 块:4096   普通空文件
设备:fd01h/64769d	Inode:41943195    硬链接:1
权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
最近访问:2019-08-12 12:15:49.542680076 -0400
最近更改:2019-08-12 12:15:49.542680076 -0400
最近改动:2019-08-12 12:15:49.542680076 -0400
创建时间:-

当我们从新建立以file1,文件的atime,mtime,ctime都进行了改变
#######目录建立
2、mkdir命令
类如:

[root@desktop Desktop]# mkdir dir
[root@desktop Desktop]# ls
dir  file  file1
在目录中嵌套目录的方法、参数写-p
[root@desktop Desktop]# mkdir dir
[root@desktop Desktop]# ls
dir  file  file1
[root@desktop Desktop]# cd dir
[root@desktop dir]# mkdir -p dir1/dir2/dir3
[root@desktop dir]# ls
dir1
[root@desktop dir]# cd dir1
[root@desktop dir1]# ls
dir2

##########文件删除
rm命令
删除文件

[root@desktop Desktop]# rm file1
rm:是否删除普通文件 "file1"?y
[root@desktop Desktop]# ls
dir  file
加上参数-f表示强制删除
[root@desktop Desktop]# ls
dir  file
[root@desktop Desktop]# rm -f file
[root@desktop Desktop]# ls
dir

dir
###########目录删除
rm命令
[root@desktop dir1]# rm dir2
rm: 无法删除"dir2": 是一个目录

[root@desktop dir1]# rm -r dir2     ######加-r后可以删除
rm:是否进入目录"dir2"? y
rm:是否删除目录 "dir2/dir3"?y
rm:是否删除目录 "dir2"?y
加上-f强制删除不用询问
[root@desktop Desktop]# rm -rf dir

###########编辑文件gedit也可以用来建立一个文件,需要安装图形见面

[root@desktop Desktop]# gedit file1
file1                                                ###是文件名

#############文件的复制
cp

[root@desktop Desktop]# mkdir dir       ####建立文件夹
[root@desktop Desktop]# ls
dir  file  file1~  file2
[root@desktop Desktop]# ll
总用量 0
drwxr-xr-x 2 root root 6 8月  12 12:52 dir
-rw-r--r-- 1 root root 0 8月  12 12:51 file
-rw-r--r-- 1 root root 0 8月  12 12:49 file1~
-rw-r--r-- 1 root root 0 8月  12 12:50 file2
[root@desktop Desktop]# cp file dir    将file复制到dir目录中
[root@desktop Desktop]# cd dir                  ######进入目录
[root@desktop dir]# ll                         #######查看目录又有的东西
总用量 0
-rw-r--r-- 1 root root 0 8月  12 12:53 file         #########可以看出文件已经复制到里面去了
[root@desktop dir]# cd ..                       ######返回桌面
[root@desktop Desktop]# ls                        ########看到文夹仍在外面
dir  file  file1~  file2

#################目录的复制
目录的复制和文件的复制一样,不过要加参数 -r
cp 后面同时可以复制多个文件或目录到另一个地方最后跟文件名。复制相当于从新建立了一个原文件,如果在同一个目录下cp只是该了个名字,内容不变。
##########文件与目录的移动
mv命令

在这里插入代码片mv命令
[root@desktop Desktop]# ls                     ####桌面目录
dir  file  file1~  file2  file3  file4
[root@desktop Desktop]# cd dir      
[root@desktop dir]# ls                        #####dir里面文件
file
[root@desktop dir]# cd ..[root@desktop Desktop]# ls
dir  file  file1~  file2  file3  file4
[root@desktop Desktop]# mv file2 dir            #####移动后
[root@desktop Desktop]# ls                     ######file2已经消失
dir  file  file1~  file3  file4
[root@desktop Desktop]# cd dir
[root@desktop dir]# ls                        ######在dir中
file  file2

[文件的移动不更改文件文件的任何属性,但是在同一个目录下移动时可以改名字的

[root@desktop dir]# ls
 file2
[root@desktop dir]# mv file file3
[root@desktop dir]# ls
file2  file3

############文件的查看
cat命令
例子:

[root@desktop dir]# ls
file2  file3
[root@desktop dir]# cat file2
nihaoa
[root@desktop dir]# cat -b file2     ####加-b参数后可以看到文件中内容的序号
     1	nihaoa

###less命令也可以查看文件。后面加文件名即可。用于浏览文件内容较多时用,当页面中现实不下时可用,上下 逐行移动,也可以用pageup|pagedown,逐页移动。加“/”后面可以写自己想要寻找的内容查找。q是推出less模式。
head 看文件的开头
tail 看文件的末尾

[root@desktop dir]# head -n 3 file2
nihaoa
111111111111111111111111
222222222222222222222
[root@desktop dir]# head file2     默认前10行
nihaoa
111111111111111111111111
222222222222222222222
33333333333333333333333333
4444444444444444444444444
55555555555555555555555
666666666666666666666666666
7777777777777777777777778
88888888888888888888888888888
999999999999999999999999999


#################文件的大小统计

[root@desktop dir]# wc file2     ####file2文件内容的大小
 18  18 469 file2
[root@desktop dir]# wc -l file2  ######看行数
18 file2
[root@desktop dir]# wc -w file2  ######看单词数
18 file2
[root@desktop dir]# wc -m file2  ##########看字符数
469 file2
[root@desktop dir]# wc -c file2  #########看字节数
469 file2

###################文件的地址
文件的地址分为:
相对路径: 从当前目录出发
绝对路径:从最前面的‘/’根目录出发
一个写部分一个要写全
########自动补齐文件名
tab键可以自动补其系统中存在的命令,文件名称。连续按两次tab显示目录的下的文件,和以此关键字开头的内容。
########文件路径查看
pwd命令

[root@desktop dir]# pwd
/root/Desktop/dir

#########进入目录
cd键,到下一级

[root@desktop dir]# cd ..
[root@desktop Desktop]

到那个目录中去可以根据自己需求结合,‘相对、绝对’路径

[root@desktop Desktop]# cd dir
[root@desktop dir]# ls
file2  file3
[root@desktop dir]# cd ..
[root@desktop Desktop]# cd /root/Desktop/dir
[root@desktop dir]# ls
file2  file3

cd 后面还可以加‘—’‘~’‘~用户名’
分别当前目录与之前目录切换,进入家目录,进入所跟用户的家目录
###########查看文件与目录的属性,现实目录中所包含的东西
ls :
ls
ls -l file ##文件属性
ls dir ##目 ls
ls -l file ##文件属性
ls dir ##目录中保函的内容
ls -d dir ##目录本身
ls -a dir ##所有文件包含隐藏的录中保函的内容

root@desktop Desktop]# ls
dir  file  file1~  file3  file4
[root@desktop Desktop]# ls -l
总用量 8
drwxr-xr-x 2 root root 30 8月  12 13:15 dir
-rw-r--r-- 1 root root  8 8月  12 13:05 file
-rw-r--r-- 1 root root  0 8月  12 12:49 file1~
-rw-r--r-- 1 root root  0 8月  12 13:04 file3
-rw-r--r-- 1 root root  8 8月  12 13:06 file4
[root@desktop Desktop]# ls -l dir         ####dir目录
总用量 4
-rw-r--r-- 1 root root 7 8月  12 13:15 file2
-rw-r--r-- 1 root root 0 8月  12 12:53 file3
[root@desktop Desktop]# cd dir
[root@desktop dir]# ls         #####进入dir中看dir目录
file2  file3
[root@desktop dir]# [root@desktop Desktop]# ls -a
.  ..  dir  file  file1~  file3  file4

2、在命令后面加‘——help’也可以得到命令的相关帮助,以‘cat’为例(系统安装了中文自动翻译出来)
将[文件]或标准输入组合输出到标准输出。例子:

[root@desktop ~]# cat --help
用法:cat [选项]... [文件]...
将[文件]或标准输入组合输出到标准输出。  -A, --show-all           等于-vET
  -b, --number-nonblank    对非空输出行编号
  -e                       等于-vE
  -E, --show-ends          在每行结束处显示"$"
  -n, --number             对输出的所有行编号
  -s, --squeeze-blank      不输出多行空行
  -t                       与-vT 等价
  -T, --show-tabs          将跳格字符显示为^I
  -u                       (被忽略)
  -v, --show-nonprinting   使用^ 和M- 引用,除了LFD和 TAB 之外
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出如果没有指定文件,或者文件为"-",则从标准输入读取。示例:
  cat f - g  先输出f 的内容,然后输出标准输入的内容,最后输出g 的内容。
  cat        将标准输入的内容复制到标准输出。GNU coreutils online help: http://www.gnu.org/software/coreutils/
请向http://translationproject.org/team/zh_CN.html 报告cat 的翻译错误
要获取完整文档,请运行:info coreutils 'cat invocation'

###man则是查看命令的或文件的的说明手册。他的功能是非常强大的。
我们以时间命令为例
在这里插入图片描述

[root@desktop ~]# date       ######现实时间的命令
2019年 08月 12日 星期一 16:59:31 EDT
[root@desktop ~]# man date      #####使用man查看date用法

其中OPTION表示不同参数的意义,在括号外的‘…’表示后面可加任意参数。FORMAT则表示后面说西时要加的格式
man date中formate中的一个我们看看效果
%c locale’s date and time (e.g., Thu Mar 3 23:05:25 2005)

[root@desktop ~]# date +%c
2019年08月12日 星期一 17时14分11秒
查看周几
  %u     day of week (1..7); 1 is Monday
[root@desktop ~]# date +%u
1                                      ######今天是这周的第一天

又如cal命令是现实日历的

[root@desktop ~]# cal
      八月 2019     
日 一 二 三 四 五 六
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
[root@desktop ~]# man cal
在其中找到这个参数      
 -3, --three              Display prev/current/next month output

在这里插入图片描述
####匹配到目录下的任意字符
配合命令非常方便如
[root@desktop Desktop]# rm -rf * #####使用时请小心点
? ####匹配但个字符
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

内容概要:该论文探讨了一种基于粒子群优化(PSO)的STAR-RIS辅助NOMA无线通信网络优化方法。STAR-RIS作为一种新型可重构智能表面,能同时反射传输信号,传统仅能反射的RIS不同。结合NOMA技术,STAR-RIS可以提升覆盖范围、用户容量频谱效率。针对STAR-RIS元素众多导致获取完整信道状态信息(CSI)开销大的问题,作者提出一种在不依赖完整CSI的情况下,联合优化功率分配、基站波束成形以及STAR-RIS的传输反射波束成形向量的方法,以最大化总可实现速率并确保每个用户的最低速率要求。仿真结果显示,该方案优于STAR-RIS辅助的OMA系统。 适合人群:具备一定无线通信理论基础、对智能反射面技术非正交多址接入技术感兴趣的科研人员工程师。 使用场景及目标:①适用于希望深入了解STAR-RISNOMA结合的研究者;②为解决无线通信中频谱资源紧张、提高系统性能提供新的思路技术手段;③帮助理解PSO算法在无线通信优化问题中的应用。 其他说明:文中提供了详细的Python代码实现,涵盖系统参数设置、信道建模、速率计算、目标函数定义、约束条件设定、主优化函数设计及结果可视化等环节,便于读者理解复现实验结果。此外,文章还对比了PSO其他优化算法(如DDPG)的区别,强调了PSO在不需要显式CSI估计方面的优势。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值