Linux查看目录下的文件及根目录文件的解释
在Linux操作系统当中,文件名不区分后缀,但经常使用后缀来帮助用户区分文件。
在Linux操作系统当中,文件名不区分后缀,但经常使用后缀来帮助用户区分文件。
查看目录下的文件
语法结构:ls 路径
列出指定目录下的内容,该命令在没有指定要列出哪个选项和参数的时候,默认为列出当前目录下的内容,一本都有默认的(注:默认的情况下不区分文件和目录,注意,在linux操作系统当中,一切皆文件)
[root@www /]# ls
afs bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
[root@www /]#
[root@www /]# ls -a /tmp
. systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-ModemManager.service-yGpp6O vmware-root_994-2991203045
.. systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-power-profiles-daemon.service-jFfiRt .X0-lock
dbus-U5I0v2NMPT systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-rtkit-daemon.service-RChtGY .X1024-lock
.font-unix systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-switcheroo-control.service-N0ZtXS .X1025-lock
.ICE-unix systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-systemd-logind.service-XfEnZ7 .X11-unix
systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-bluetooth.service-N0VrDZ systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-upower.service-1uJLhf .X1-lock
systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-chronyd.service-5wcy5H vmware-root_988-2991203012 .XIM-unix
systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-colord.service-I0xq1g vmware-root_990-2999657286
systemd-private-b63f183ed99a43a3b3eeec3046dab7f8-dbus-broker.service-IkiGq8 vmware-root_991-4248615064
[root@www /]#
ls -l:“ll” 是“ls -l” 的缩写,直接用 “ll” 效果一样,以长目录的方式列出指定目录内容(长目录会列出该目录中所有文件的一些属性,属性中的时间是指mtime)
[root@www /]# ls -l
total 28
dr-xr-xr-x. 2 root root 6 Aug 10 2021 afs
lrwxrwxrwx. 1 root root 7 Aug 10 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Oct 30 19:16 boot
drwxr-xr-x. 20 root root 3380 Mar 5 22:20 dev
drwxr-xr-x. 132 root root 8192 Mar 6 20:19 etc
drwxr-xr-x. 4 root root 32 Mar 6 19:39 home
lrwxrwxrwx. 1 root root 7 Aug 10 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 10 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Aug 10 2021 media
drwxr-xr-x. 3 root root 18 Oct 30 19:03 mnt
drwxr-xr-x. 2 root root 6 Aug 10 2021 opt
dr-xr-xr-x. 404 root root 0 Mar 5 22:20 proc
dr-xr-x---. 13 root root 4096 Mar 5 22:47 root
drwxr-xr-x. 43 root root 1160 Mar 5 22:20 run
lrwxrwxrwx. 1 root root 8 Aug 10 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Aug 10 2021 srv
dr-xr-xr-x. 13 root root 0 Mar 5 22:20 sys
drwxr-xr-x. 4 root root 24 Nov 11 21:29 test
drwxrwxrwt. 20 root root 4096 Mar 7 03:51 tmp
drwxr-xr-x. 12 root root 144 Oct 30 19:01 usr
drwxr-xr-x. 20 root root 4096 Oct 30 19:16 var
[root@www /]# ll
total 28
dr-xr-xr-x. 2 root root 6 Aug 10 2021 afs
lrwxrwxrwx. 1 root root 7 Aug 10 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Oct 30 19:16 boot
drwxr-xr-x. 20 root root 3380 Mar 5 22:20 dev
drwxr-xr-x. 132 root root 8192 Mar 6 20:19 etc
drwxr-xr-x. 4 root root 32 Mar 6 19:39 home
lrwxrwxrwx. 1 root root 7 Aug 10 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 10 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Aug 10 2021 media
drwxr-xr-x. 3 root root 18 Oct 30 19:03 mnt
drwxr-xr-x. 2 root root 6 Aug 10 2021 opt
dr-xr-xr-x. 404 root root 0 Mar 5 22:20 proc
dr-xr-x---. 13 root root 4096 Mar 5 22:47 root
drwxr-xr-x. 43 root root 1160 Mar 5 22:20 run
lrwxrwxrwx. 1 root root 8 Aug 10 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Aug 10 2021 srv
dr-xr-xr-x. 13 root root 0 Mar 5 22:20 sys
drwxr-xr-x. 4 root root 24 Nov 11 21:29 test
drwxrwxrwt. 20 root root 4096 Mar 7 03:51 tmp
drwxr-xr-x. 12 root root 144 Oct 30 19:01 usr
drwxr-xr-x. 20 root root 4096 Oct 30 19:16 var
[root@www /]#
ls -a :列出指定目录下所有文件,包括隐藏文件 “.” 和 “点点” 文件
注: 以 “.” 开头的文件,在linux操作系统中,表示隐藏文件,但真正要隐藏文件,并不推荐这种方法,因为这种隐藏文件的目的更多是用来不显示一些不常用的文件和目录管理
[root@www /]# ls -a
. .. afs bin boot dev etc .haha.swp home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
[root@www /]#
ls -A 列出指定目录下的所有文件,包括隐藏文件,但不包含 “.” 文件和 “点点” 文件
[root@www /]# ls -A
afs bin boot dev etc .haha.swp home lib lib64 media mnt opt proc root run sbin srv sys test tmp usr var
[root@www /]#
ls -lh -lh是-l和-h的配合使用,用来显示文件的大小的单位(注:也可以写成ls -hl)。
-h 智能显示文件大小的单位,该选项的组合没有先后顺序,-lh和-hl效果一样,但是 - 一定要在前面。
[root@www /]# dd if=/dev/zero of=haha bs=1M count=1000-----------------(创建一个1000M大小的文件)
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 2.85587 s, 367 MB/s
[root@www /]# ls -lh
total 1001M
dr-xr-xr-x. 2 root root 6 Aug 10 2021 afs
lrwxrwxrwx. 1 root root 7 Aug 10 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4.0K Oct 30 19:16 boot
drwxr-xr-x. 20 root root 3.4K Mar 5 22:20 dev
drwxr-xr-x. 132 root root 8.0K Mar 6 20:19 etc
-rw-r--r--. 1 root root 1000M Mar 8 20:55 haha----------------(这里haha的文件大小为1000M)
drwxr-xr-x. 4 root root 32 Mar 6 19:39 home
lrwxrwxrwx. 1 root root 7 Aug 10 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 10 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Aug 10 2021 media
drwxr-xr-x. 3 root root 18 Oct 30 19:03 mnt
drwxr-xr-x. 2 root root 6 Aug 10 2021 opt
dr-xr-xr-x. 406 root root 0 Mar 5 22:20 proc
dr-xr-x---. 13 root root 4.0K Mar 5 22:47 root
drwxr-xr-x. 43 root root 1.2K Mar 5 22:20 run
lrwxrwxrwx. 1 root root 8 Aug 10 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Aug 10 2021 srv
dr-xr-xr-x. 13 root root 0 Mar 5 22:20 sys
drwxr-xr-x. 4 root root 24 Nov 11 21:29 test
drwxrwxrwt. 20 root root 4.0K Mar 8 03:32 tmp
drwxr-xr-x. 12 root root 144 Oct 30 19:01 usr
drwxr-xr-x. 20 root root 4.0K Oct 30 19:16 var
[root@www /]#
[root@www /]# dd if=/dev/zero of=haha bs=1M count=2000-----------------(创建一个2000M大小的文件)
2000+0 records in
2000+0 records out
2097152000 bytes (2.1 GB, 2.0 GiB) copied, 4.70232 s, 446 MB/s
[root@www /]# ls -lh
total 2.0G
dr-xr-xr-x. 2 root root 6 Aug 10 2021 afs
lrwxrwxrwx. 1 root root 7 Aug 10 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4.0K Oct 30 19:16 boot
drwxr-xr-x. 20 root root 3.4K Mar 5 22:20 dev
drwxr-xr-x. 132 root root 8.0K Mar 6 20:19 etc
-rw-r--r--. 1 root root 2.0G Mar 8 20:59 haha----------------(这里haha的文件大小为2G)
drwxr-xr-x. 4 root root 32 Mar 6 19:39 home
lrwxrwxrwx. 1 root root 7 Aug 10 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 10 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Aug 10 2021 media
drwxr-xr-x. 3 root root 18 Oct 30 19:03 mnt
drwxr-xr-x. 2 root root 6 Aug 10 2021 opt
dr-xr-xr-x. 403 root root 0 Mar 5 22:20 proc
dr-xr-x---. 13 root root 4.0K Mar 5 22:47 root
drwxr-xr-x. 43 root root 1.2K Mar 5 22:20 run
lrwxrwxrwx. 1 root root 8 Aug 10 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Aug 10 2021 srv
dr-xr-xr-x. 13 root root 0 Mar 5 22:20 sys
drwxr-xr-x. 4 root root 24 Nov 11 21:29 test
drwxrwxrwt. 20 root root 4.0K Mar 8 03:32 tmp
drwxr-xr-x. 12 root root 144 Oct 30 19:01 usr
drwxr-xr-x. 20 root root 4.0K Oct 30 19:16 var
[root@www /]#
根目录文件
[root@www ~]# cd /---------------(切换到根目录)
[root@www /]# ll
total 2048028
dr-xr-xr-x. 2 root root 6 Aug 10 2021 afs
lrwxrwxrwx. 1 root root 7 Aug 10 2021 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Oct 30 19:16 boot
drwxr-xr-x. 20 root root 3380 Mar 5 22:20 dev
drwxr-xr-x. 132 root root 8192 Mar 6 20:19 etc
-rw-r--r--. 1 root root 2097152000 Mar 8 20:59 haha-----(这个文件是上面为了测试你 -h 的作用是创建的)
drwxr-xr-x. 4 root root 32 Mar 6 19:39 home
lrwxrwxrwx. 1 root root 7 Aug 10 2021 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 10 2021 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Aug 10 2021 media
drwxr-xr-x. 3 root root 18 Oct 30 19:03 mnt
drwxr-xr-x. 2 root root 6 Aug 10 2021 opt
dr-xr-xr-x. 403 root root 0 Mar 5 22:20 proc
dr-xr-x---. 13 root root 4096 Mar 5 22:47 root
drwxr-xr-x. 43 root root 1160 Mar 5 22:20 run
lrwxrwxrwx. 1 root root 8 Aug 10 2021 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Aug 10 2021 srv
dr-xr-xr-x. 13 root root 0 Mar 5 22:20 sys
drwxr-xr-x. 4 root root 24 Nov 11 21:29 test
drwxrwxrwt. 20 root root 4096 Mar 8 03:32 tmp
drwxr-xr-x. 12 root root 144 Oct 30 19:01 usr
drwxr-xr-x. 20 root root 4096 Oct 30 19:16 var
[root@www /]#
根目录下相关文件的解释
bin文件:是一个可执行文件
boot文件:属于启动和引导系统的文件
dev文件:设备文件
home文件:所有普通用户的家目录
lib文件:32位的库文件
lib64文件:64位的库文件
media文件:多媒体文件
/proc:目录中存放进程的相关文件,数字是进程的id
/run:服务进程相关的文件
/sys:内存中运行的操作系统
sebin文件:存放只有超级管理员才能使用的命令或可执行程序
srv文件:存放临时文件的目录,定期会被清理
/usr/share/doc/:存放所有已经安装的软件的相关文档,软件名就是该目录下的目录名
/var:存放变化比较频繁的文件,比如:日志,邮件,审计信息……
……
[root@www /]# ps -ef |grep 26----------------(查看含有26的进程)
root 26 2 0 Mar05 ? 00:00:00 [kworker/2:0H-events_highpri]
root 92 2 0 Mar05 ? 00:00:00 [irq/26-pciehp]
root 126 2 0 Mar05 ? 00:00:00 [ipv6_addrconf]
root 267 2 0 Mar05 ? 00:00:00 [kworker/u257:0-hci0]
root 526 2 0 Mar05 ? 00:00:00 [scsi_tmf_17]
root 554 2 0 Mar05 ? 00:00:00 [scsi_eh_26]
root 555 2 0 Mar05 ? 00:00:00 [scsi_tmf_26]
root 826 1 0 Mar05 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 2601 2595 0 Mar05 pts/0 00:00:00 -bash
root 2622 2 0 Mar05 ? 00:00:00 [kworker/2:2-cgwb_release]
root 3550 2601 0 Mar06 pts/0 00:00:00 su - redhat
haha 4126 3767 0 Mar06 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
root 6826 2 0 21:11 ? 00:00:00 [kworker/1:0-events_freezable_power_]
root 6828 3579 0 21:15 pts/0 00:00:00 grep --color=auto 26
[root@www /]#
ps -ef |grep 26
ps -ef:表示打印所有进程
grep:通过管道过滤出26的相关文件
更多推荐
所有评论(0)