Linux操作系统基础命令使⽤-ls查看目录内的内容(学习笔记)

ls - list

ls [可选参数] [路径信息]

⼀⼤列- 普通⽂件
d ⽬录⽂件
l 链接⽂件
b 块设备⽂件
p 管理⽂件/管道⽂件
3个⼀组
权限 ⽂件拥有者权限 , ⽂件所属组权限,  ⽂件其他⼈(其他⽤户)
r 读权限
w 写权限
x 执⾏权限- ⽆权限
权限对普通⽂件 和 对于⽬录 意义不同
⼆⼤列
普通⽂件 - 链接数
⽬录⽂件 - 第⼀级⼦⽬录

三/四 ⼤列  
⽂件拥有者 / ⽂件所属组
五 ⼤列 
⽂件⼤⼩ - 字节
六/七/⼋ ⼤列  最后⼀次对⽂件内容的修改时间
[tom@centos7 ~]$ stat 123.txt 
  File: ‘123.txt’
  Size: 8 Blocks: 8  IO Block: 4096   regular file
 Device: 803h/2051d      Inode: 101328417   Links: 1
 Access: (0664/-rw-rw-r--)  Uid: ( 1000/     tom)   Gid: ( 1000/     tom)
 Context: unconfined_u:object_r:user_home_t:s0
 Access: 2026-01-12 22:43:28.235883784 +0800
 Modify: 2026-01-12 22:43:26.064012338 +0800
 Change: 2026-01-12 22:43:26.064012338 +0800
 Access: 2026-01-12 22:43:28.235883784 +0800
 Access-time :  最后⼀次更改后的 , ⾸次访问时间
Modify: 2026-01-12 22:43:26.064012338 +0800
 Modify-time :  最后⼀次对⽂件内容修改时间
Change: 2026-01-12 22:43:26.064012338 +0800
 Change-time :  最后⼀次对⽂件进⾏属性更改的时间
[tom@centos7 ~]$ touch 456.txt #创建空⽂件
[tom@centos7 ~]$ echo "sy-test456" >> 456.txt  
九 ⼤列  ⽂件名称
⽩/灰  普通⽂件
暗蓝⾊ - ⽬录⽂件
亮蓝⾊/⻘ - 链接⽂件
亮绿⾊ -可执⾏⽂件
红⾊  -压缩⽂件
背景⾊ - ⽂件特殊权限位
          IO Block: 4096
   regular file
 [tom@centos7 ~]$ ls -r # 反向列出
Videos  Templates  Public  Pictures  Music  Downloads  Documents  Desktop  core.2066 
123.txt
 [tom@centos7 ~]$ 
[tom@centos7 ~]$
[tom@centos7 ~]$ ls -R #递归查看
.:
 123.txt  core.2066  Desktop  Documents  Downloads  Music  Pictures  Public  Templates  
Videos
 ./Desktop:
 456.txt
 ./Documents:
 ./Downloads:
 ./Music:
 ./Pictures:
 ./Public:
 ./Templates:
 [tom@centos7 ~]$ ls -lha  /
 total 24K
 dr-xr-xr-x.  17 root root  224 May 10  2021 .
 dr-xr-xr-x.  17 root root  224 May 10  2021 ..

 drwxrwxrwt.  15 root root 4.0K Jan 12 23:16 tmp
 drwxr-xr-x.  13 root root  155 May 10  2021 usr
 drwxr-xr-x.  20 root root  282 May 10  2021 var
[tom@centos7 ~]$ ls #查看⽬录中的内容
core.2066  Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
 [tom@centos7 ~]$ ls .  #查看当前⽬录中的内容
core.2066  Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
 [tom@centos7 ~]$ pwd
 /home/tom
 [tom@centos7 ~]$ ls ..
 tom
 [tom@centos7 ~]$ ls /
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  
tmp  usr  var
 [tom@centos7 ~]$ cd /
 [tom@centos7 /]$ ls 
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  
tmp  usr  var
 [tom@centos7 /]$ cd 
/home/tom
 [tom@centos7 ~]$ ls /
 bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  
tmp  usr  var
 [tom@centos7 ~]$ ls -l #显示详细信息
total 5096
-rw-------. 1 tom tom 5218304 Jun  7  2021 core.2066
drwxr-xr-x. 2 tom tom      25 Jan 12 20:33 Desktop
drwxr-xr-x. 2 tom tom       6 May 10  2021 Documents
       

 
 [tom@centos7 Downloads]$ ls
 [tom@centos7 Downloads]$ ls -a    #显示隐藏内容

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值