まず、次のようにlinuxファイルシステムにファイルタイプを導入します。
-:表示普通文件
d:表示目录文件
b:表示块设备文件
c:表示字符设备文件
l:表示软链接文件
p:表示管道文件
s:表示套接字文件
例1
ファイルタイプの表示
[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
显示结果中,第一个位置的符号“-”就代表了文件类型为普通文件。
例2
は、現在の作業ディレクトリを示しています
[root@centos7 ~]# pwd
/root
例3
/ etc / sysconfig /のベース名を取得します
[root@centos7 ~]#basename /etc/sysconfig/
sysconfig
例4
/ etc / sysconfig /のディレクトリ名を取得します
[root@centos7 ~]#dirname /etc/sysconfig/
/etc
例5
ユーザーのホームディレクトリに切り替える
[root@centos7 /etc/sysconfig]#cd
[root@centos7 ~]#
或
[root@centos7 /etc/sysconfig]#cd ~
[root@centos7 ~]#
例6
親ディレクトリに切り替えます
[root@centos7 /etc/sysconfig]#cd ~
[root@centos7 ~]#
例7
/ etc / sysconfigディレクトリに切り替えます
[root@centos7 ~]#cd /etc/sysconfig/
[root@centos7 /etc/sysconfig]#
例8
最後のディレクトリに切り替えます
[root@centos7 /etc/sysconfig]#cd -
/root
例9
現在のディレクトリ内のすべてのファイルを表示する
[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
例10
は、ディレクトリの内容に関する追加情報を表示します
[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
例11
ディレクトリの内容を再帰的に表示する
[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
例12
組み合わせたアプリケーション
[root@centos7 ~]#ls -ar
.Xauthority Pictures Desktop
.vimrc Music .dbus
.viminfo .local .cshrc
Videos .lesshst .config
Templates .initial-setup-ks.cfg.swp .cache
例
13filelファイルのステータスを表示し、3つのタイムスタンプに注意してください
[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: -
例14
空のファイルtist.shを作成します
[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
例15
/ etc / vircファイルを現在のディレクトリにコピーします
[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
例16
/ data / script39ディレクトリとその下のすべてのファイルとサブディレクトリを現在のディレクトリにコピーします
[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