Primero introduzca los tipos de archivo en el sistema de archivos de Linux de la siguiente manera:
-:表示普通文件
d:表示目录文件
b:表示块设备文件
c:表示字符设备文件
l:表示软链接文件
p:表示管道文件
s:表示套接字文件
Ejemplo 1
Ver tipo de archivo
[root@centos7 ~]# ll
total 40
-rw-------. 1 root root 1897 Sep 20 2019 anaconda-ks.cfg
-rw-r--r-- 1 root root 181 Oct 15 2019 base.repo
drwxr-xr-x. 2 root root 6 Sep 20 2019 Desktop
drwxr-xr-x. 2 root root 6 Sep 20 2019 Documents
drwxr-xr-x. 2 root root 6 Sep 20 2019 Downloads
drwx------. 38 root root 4096 Oct 10 2019 etc
-rw-r--r-- 1 root root 6 Nov 7 2019 filel
-rw-r--r-- 1 root root 33 Nov 7 2019 filel.ciper
显示结果中,第一个位置的符号“-”就代表了文件类型为普通文件。
El ejemplo 2
muestra el directorio de trabajo actual
[root@centos7 ~]# pwd
/root
Ejemplo 3
Obtenga el nombre base de / etc / sysconfig /
[root@centos7 ~]#basename /etc/sysconfig/
sysconfig
Ejemplo 4
Obtenga el nombre del directorio de / etc / sysconfig /
[root@centos7 ~]#dirname /etc/sysconfig/
/etc
Ejemplo 5
Cambiar al directorio de inicio del usuario
[root@centos7 /etc/sysconfig]#cd
[root@centos7 ~]#
或
[root@centos7 /etc/sysconfig]#cd ~
[root@centos7 ~]#
Ejemplo 6
Cambiar al directorio principal
[root@centos7 /etc/sysconfig]#cd ~
[root@centos7 ~]#
Ejemplo 7
Cambie al directorio / etc / sysconfig
[root@centos7 ~]#cd /etc/sysconfig/
[root@centos7 /etc/sysconfig]#
Ejemplo 8
Cambiar al último directorio
[root@centos7 /etc/sysconfig]#cd -
/root
Ejemplo 9
Mostrar todos los archivos en el directorio actual
[root@centos7 ~]#ls -a
. Documents .pki
.. Downloads private2.key
anaconda-ks.cfg .esd_auth private2.keyu
base.repo etc private.key
.bash_history filel Public
.bash_logout filel.ciper public.key
.bash_profile .ICEauthority .rnd
.bashrc initial-setup-ks.cfg .tcshrc
.cache .initial-setup-ks.cfg.swp Templates
.config .lesshst Videos
.cshrc .local .viminfo
.dbus Music .vimrc
Desktop Pictures .Xauthority
El ejemplo 10
muestra información adicional sobre el contenido del directorio
[root@centos7 ~]#ls -l
total 40
-rw-------. 1 root root 1897 Sep 20 2019 anaconda-ks.cfg
-rw-r--r-- 1 root root 181 Oct 15 2019 base.repo
drwxr-xr-x. 2 root root 6 Sep 20 2019 Desktop
drwxr-xr-x. 2 root root 6 Sep 20 2019 Documents
或
[root@centos7 ~]#ll
total 40
-rw-------. 1 root root 1897 Sep 20 2019 anaconda-ks.cfg
-rw-r--r-- 1 root root 181 Oct 15 2019 base.repo
drwxr-xr-x. 2 root root 6 Sep 20 2019 Desktop
drwxr-xr-x. 2 root root 6 Sep 20 2019 Documents
Ejemplo 11
Mostrar contenido de directorio de forma recursiva
[root@centos7 ~]#ls -r
Videos private2.keyu filel.ciper Desktop
Templates private2.key filel base.repo
public.key Pictures etc anaconda-ks.cfg
Public Music Downloads
private.key initial-setup-ks.cfg Documents
Ejemplo 12
Aplicación combinada
[root@centos7 ~]#ls -ar
.Xauthority Pictures Desktop
.vimrc Music .dbus
.viminfo .local .cshrc
Videos .lesshst .config
Templates .initial-setup-ks.cfg.swp .cache
Ejemplo 13
Ver el estado del archivo filel, prestar atención a las tres marcas de tiempo
[root@centos7 ~]#stat filel
File: ‘filel’
Size: 6 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 201551289 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-09-12 18:36:47.799983521 +0800
Modify: 2019-11-07 10:22:48.764939245 +0800
Change: 2019-11-07 10:22:48.764939245 +0800
Birth: -
Ejemplo 14
Cree un archivo tist.sh vacío
[root@centos7 /data]#touch tist.sh
[root@centos7 /data]#ll tist.sh
-rw-r--r-- 1 root root 0 Oct 20 14:48 tist.sh
Ejemplo 15
Copie el archivo / etc / virc en el directorio actual
[root@centos7 /data]#cp /etc/virc ./
[root@centos7 /data]#ll
total 16
-rw-r--r-- 1 root root 1026 Sep 16 10:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 1761 Sep 10 08:29 awktest.txt
drwxr-xr-x 2 root root 6 Sep 14 11:08 cdrom
drwxr-xr-x 2 root root 6 Oct 31 2019 dir
drwxr-xr-x 5 mysql mysql 110 May 17 15:32 mysql
drwxr-xr-x. 2 root root 4096 Oct 11 17:09 script39
-rw-r--r-- 1 root root 0 Oct 20 14:48 tist.sh
-rw-r--r-- 1 root root 1982 Oct 20 14:52 virc
Ejemplo 16
Copie el directorio / data / script39 y todos los archivos y subdirectorios en el directorio actual
[root@centos7 ~]#cp -R /data/script39/ ./
[root@centos7 ~]#ls script39/
argsnum.sh disk.sh mkcdrom.sh sumfile.sh yesorno.sh
backup.sh hello.sh pass.sh sumid.sh
chkscore.sh initial.sh REG sysinfo.sh
createuser.sh links.sh rename.sh systeminfo.sh