文件类型:
-:普通文件(File)
d:目录文件
b:块设备文件(Block)
c:字符设备文件(Character)
l:符号链接文件(Symboic link file)
p:命令管道文件(Pipe)
s:套接字文件(Socket)
查看多个目录:ls path1 path2
[root@ecs-x-medium-2-linux-20200307131357 /]# ls / /var
/:
bin lib sbin
boot lib64 selinux
CloudResetPwdUpdateAgent lost+found srv
CloudrResetPwdAgent media sys
dev mnt tmp
etc opt usr
home proc var
HostGuardAgent_Linux64_V1.12.50.rpm.sha256 root
hostguard_setup_config.dat run
/var:
account crash db games local log nis preserve spool yp
cache cvs empty lib lock mail opt run tmp
查看隐藏文件:ls -a
[root@ecs-x-medium-2-linux-20200307131357 /]# ls -a
. home root
.. HostGuardAgent_Linux64_V1.12.50.rpm.sha256 run
.autofsck hostguard_setup_config.dat sbin
.autorelabel lib selinux
bin lib64 srv
boot lost+found sys
CloudResetPwdUpdateAgent media tmp
CloudrResetPwdAgent mnt usr
dev opt var
etc proc
4. cd:切换工作目录
切换到根目录:cd /
[root@ecs-x-medium-2-linux-20200307131357 ~]# cd /
[root@ecs-x-medium-2-linux-20200307131357 /]#
切换到上一级目录:cd …
[root@ecs-x-medium-2-linux-20200307131357 yum]# cd ..
[root@ecs-x-medium-2-linux-20200307131357 etc]#
切换到当前用户家目录: cd
[root@ecs-x-medium-2-linux-20200307131357 etc]# cd
[root@ecs-x-medium-2-linux-20200307131357 ~]#
[root@ecs-x-medium-2-linux-20200307131357 b]# ls
dir2 dir3
[root@ecs-x-medium-2-linux-20200307131357 b]# rm -rf dir2
[root@ecs-x-medium-2-linux-20200307131357 b]# ls
dir3
8. cp:拷贝
拷贝文件:cp a.txt b.txt
[root@ecs-x-medium-2-linux-20200307131357 c]# ls
a.txt
[root@ecs-x-medium-2-linux-20200307131357 c]# cp a.txt b.txt
[root@ecs-x-medium-2-linux-20200307131357 c]# ls
a.txt b.txt
拷贝文件夹
[root@ecs-x-medium-2-linux-20200307131357 c]# ls
a a.txt b.txt
[root@ecs-x-medium-2-linux-20200307131357 c]# cp -r a b
[root@ecs-x-medium-2-linux-20200307131357 c]# ls
a a.txt b b.txt
9. mv :移动
移动文件 mv file path
[root@ecs-x-medium-2-linux-20200307131357 dira]# ls
a.txt
[root@ecs-x-medium-2-linux-20200307131357 dira]# mv a.txt ../dirb
[root@ecs-x-medium-2-linux-20200307131357 dira]# ls
[root@ecs-x-medium-2-linux-20200307131357 dira]# ls ../dirb
a.txt
重命名 mv ofile nfile
[root@ecs-x-medium-2-linux-20200307131357 dirb]# ls
a.txt
[root@ecs-x-medium-2-linux-20200307131357 dirb]# mv a.txt a.md
[root@ecs-x-medium-2-linux-20200307131357 dirb]# ls
a.md
10. ln:链接
建立硬链接,相当于Java中指向的同一块地址
[root@ecs-x-medium-2-linux-20200307131357 a]# ls
a.txt
[root@ecs-x-medium-2-linux-20200307131357 a]# ln a.txt a.link
[root@ecs-x-medium-2-linux-20200307131357 a]# ll
total 0
-rw-r--r-- 2 root root 0 Oct 30 00:08 a.link
-rw-r--r-- 2 root root 0 Oct 30 00:08 a.txt
[root@ecs-x-medium-2-linux-20200307131357 a]# ls
a.link a.txt b.link
[root@ecs-x-medium-2-linux-20200307131357 a]# touch c.txt
[root@ecs-x-medium-2-linux-20200307131357 a]# ls
a.link a.txt b.link c.txt
二. 文本操作命令
1. cat 展示文本(more)
[root@ecs-x-medium-2-linux-20200307131357 a]# cat a.txt
qwer
qswd
dsfsfds
fsdfsf
fssdfs
fsfsdg
dfdf
sdfwsf
fdgfdsfg
fdsf
ddfdgd
gdgf
d
g
dg
d
f
gd
g
dg
drgdgegd
g
dhdg
dg
d
rgdd
g
rd
greg
efgd
2. less:分屏展示
[root@ecs-x-medium-2-linux-20200307131357 a]# less a.txt
qwer
qswd
dsfsfds
fsdfsf
fssdfs
fsfsdg
dfdf
sdfwsf
fdgfdsfg
fdsf
ddfdgd
gdgf
d
g
dg
d
f
gd
g
dg
drgdgegd
g
dhdg
a.txt