파일 관리 관련 명령

먼저 다음과 같이 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

예제 13
filel 파일의 상태를보고 세 개의 타임 스탬프에주의하십시오.

[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

추천

출처blog.51cto.com/14233656/2542617