当前位置:首页>Linux>【系列】每天一个 Linux 命令(37)ls命令

【系列】每天一个 Linux 命令(37)ls命令

  • 2026-10-11 07:42:23
【系列】每天一个 Linux 命令(37)ls命令

ls命令来自英文单词list的缩写,中文译为“列出”,其功能是显示目录中的文件及其属性信息,是最常使用的Linux命令之一。

默认不添加任何参数的情况下,k命令会列出当前工作目录中的文件信息,常与cd或pwd命令搭配使用,十分方便。带上参数后,我们可以做更多的事情。作为最基础、最频繁使用的命令,有必要仔细了解其常用功能。

1.命令格式:

Is  参数  文件名

2.常用参数:

-a  显示所有文件及目录-A  不显示当前目录和父目录-d  显示目录自身的属性信息-i  显示文件的inode属性信息-l  显示文件的详细属性信息-m  以逗号为间隔符,水平显示文件信息-r  依据首字母将文件以相反次序显示-R  递归显示所有子文件-S  依据内容大小将文件排序显示-t  依据最后修改时间将文件排序显示-X  依据扩展名将文件排序显示-color  以彩色显示信息

3.参考示例

显示当前目录中的文件名(默认不含隐藏文件):

[root@linuxcool ~]# lsanacondaks.cfg Documents initialsetupks.cfg Pictures Templates Desktop        Downloads   Music            Public      Videos

显示当前目录中的文件名(含隐藏文件):

[root@linuxcool ~]# ls -a .                .bashrc   Documents            Music     Videos..               .cache    Downloads            Pictures  .viminfoanaconda-ks.cfg  .config   .esd_auth            .pki.bash_history    .cshrc    .ICEauthorityPublic.bash_logout     .dbus     initial-setup-ks.cfg .tcshrc.bash_profile    Desktop   .local               Templates

以详细信息模式输出文件名及其属性信息:

[root@linuxcool ~]# ls -l total 8 -rw-------. 1 root root 1430 Dec 14 08:05 anaconda-ks.cfgdrwxrxrx. 2 root root 6 Dec 14 08:37 Desktopdrwxr-xr-x. 2 root root 6 Dec 14 08:37 Documents drwxr-xr-x. 2 root root 6 Dec 14 08:37 Downloads rwrr--. 1 root root 1585 Dec 14 08:34 initialsetupks.cfg

4.Is命令:显示目录中文件及其属性信息

drwxr-xr-x. 2 root root 6 Dec 14 08:37 Music drwxr-xr-x. 2 root root 6 Dec 14 08:37 Pictures drwxr-xr-x. 2 root root 6 Dec 14 08:37 Public drwxr-xr-x. 2 root root 6 Dec 14 08:37 Templates drwxr-xr-x. 2 root root 6 Dec 14 08:37 Videos

显示指定目录中的文件列表:

[root@linuxcool ~]# ls /etc adjtime                 hosts            pulse aliases                 hosts.allow      qemu-ga alsa                    hosts.deny       qemu-kvm alternatives            hp               radvd.confanacrontab              idmapd.conf      ras asound.conf             init.d           rc0.dat.deny                 inittab          rc1.d ………………省略部分输出信息……………

显示当前目录中的文件名及inode属性信息:

[root@linuxcool ~]# 1s -i35290115 anaconda-ks.cfg     35290137 initial-setup-ks.cfg      35290164 Templates17840039Music                1137391 Desktop                    51609597 videos1137392 Documents            35290165 Pictures51609596 Public              17840038 Downloads

结合通配符一起使用,显示指定目录中所有以sd开头的文件列表

[root@linuxcool ~]# 1s /dev/sd*/dev/sda /dev/sdal /dev/sda2

依据文件内容大小进行排序,显示指定目录中文件名及其属性详情信息:

[root@linuxcool ~]# *ls -Sl /etctotal 1348-rw-r--r--.   1   root   root            692241    sep  10 2023 services-rw-r--r--.   1   root   root            66482     Dec  14 08:34 ld.so.cache-rw-r--r--.   1   root   root            60352     May  11 2023 mime.types-rw-r--r--.   1   root   dnsmasq         26843     Aug  12 2023 dnsmasq.conf-rw-r--r--.   1   root   root            25696     Dec  12 2023 brltty.conf-rw-r--r--.   1   root   root            9450      Aug  12 2023 nanorc-rw-r--r--.   1   root   root            7265      Dec  14 08:03 kdump.conf-rw-------.   1   mtss   tss             7046      Aug  13 2023 tcsd.conf.............................省略部分输出信息.............................

— Linux文章推荐 —

【资料领取】200个Linux常用命令手册

《鸟哥Linux私房菜》全新完整中文版PDF

RHCE 证书价值解析:薪资水平与热门招聘企业分析

linux运维必备,100道常见面试题

超强linux学习笔记,值得一看(附PDF下载)

红红帽认证、麒麟认证与 K8S 该如何选择?

5 种 Linux 安装包管理工具中文手册!抓紧看!

微 思 网 络
(点击查看介绍)

2026热门课开课时间表


系统集成

认证培训

IT维保,找我们

IT培训,找我们买设备,找我们

最新文章

随机文章