日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

7 centos 查看程序文件数量_解析CentOS 7中系统文件与目录管理

發布時間:2023/12/2 windows 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 7 centos 查看程序文件数量_解析CentOS 7中系统文件与目录管理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

LINUX

Linux操作系統

解析CentOS 7中系統文件與目錄管理

Linux目錄結構

Linux目錄結構是樹形的目錄結構

根目錄

所有分區、目錄、文件等的位置起點

整個樹形目錄結構中,使用獨立的一個“/”表示

常見的子目錄

目錄

目錄名稱

目錄

目錄名稱/root

管理員家目錄

/bin

所有用戶可執行命令文件目錄

/boot

系統內核、啟動文件目錄

/dev

設備文件

/etc

配置文件

/home

用戶家文件目錄

/var

變量文件(日志文件)

/usr

用戶應用程序文件目錄

/sbin

管理員可執行的管理命令

/proc

硬件信息存放目錄

查看及檢索文件命令

cat命令

cat命令:顯示并連接文件內容

格式

? cat [選項] 文件名 …

[root@localhost ~]# cat /mnt/tast02.txt //輸入命令,查看文件內容

this is tast02 //顯示文件內容

[root@localhost ~]#

more 和 less 命令

more命令:全屏方式分頁顯示文件內容(當閱讀完時自動退出閱讀模式,不可直接回看)

格式

? more [選項] 文件名 ...

交互操作方法

按Enter鍵向下逐行滾動

按空格鍵向下翻一屏

按b鍵向上翻一屏

按q鍵退出[root@localhost ~]# more /etc/httpd/conf/httpd.conf

#

# This is the main Apache HTTP server configuration file. It contains the

# configuration directives that give the server its instructions.

# See for detailed information.

# In particular, see

#

# for a discussion of each configuration directive.

#

# Do NOT simply read the instructions in here without understanding

# what they do. They're here only as hints or reminders. If you are unsure

# consult the online docs. You have been warned.

#

# Configuration and logfile names: If the filenames you specify for many

# of the server's control files beg...//以下省略內容...

less命令:與more命令相同,但擴展功能更過(閱讀結束后可向上翻頁,繼續閱讀)

格式

less [選項] 文件名 ...

交互操作方法

page up 向上翻頁

page down 向下翻頁

“/”鍵查找內容

“n”下一個內容

“N”上一個內容

其他功能與more命令基本類似[root@localhost ~]# less /etc/httpd/conf/httpd.conf

#

# This is the main Apache HTTP server configuration file. It contains the

# configuration directives that give the server its instructions.

# See for detailed information.

# In particular, see

#

# for a discussion of each configuration directive.

#

# Do NOT simply read the instructions in here without understanding

# what they do. They're here only as hints or reminders. If you are unsure

# consult the online ...//以下省略內容...

head和tail命令

head命令:查看文件開頭部分內容(默認10行)

格式

head [選項] 文件名 ...

命令字

選項

作用head

查看文件開頭一部分內容(默認10行)

head

-n(數字)

查看頭n行內容[root@localhost ~]# head /etc/passwd //查看目錄文件頭10行內容

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

halt:x:7:0:halt:/sbin:/sbin/halt

mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

operator:x:11:0:operator:/root:/sbin/nologin //查看目錄文件頭3行內容

[root@localhost ~]# head -3 /etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

tail命令:查看文件結尾的少部分內容(默認為10行)

格式

tail [選項] 文件名 ...

命令字

選項

作用tail

查看文件結尾的少部分內容(默認為10行)

tail

-n

查看結尾n行內容

tail

-f

跟蹤文件尾部內容的動態更新(在公共日志等文件中用)[root@localhost ~]# tail /etc/passwd //查看目錄文件結尾10行內容

setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin

sssd:x:992:987:User for sssd:/:/sbin/nologin

gdm:x:42:42::/var/lib/gdm:/sbin/nologin

gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin

postfix:x:89:89::/var/spool/postfix:/sbin/nologin

tcpdump:x:72:72::/:/sbin/nologin

sun:x:1000:1000:sun:/home/sun:/bin/bash

apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin

[root@localhost ~]# tail -3 /etc/passwd //查看目錄文件結尾3行內容

tcpdump:x:72:72::/:/sbin/nologin

sun:x:1000:1000:sun:/home/sun:/bin/bash

apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin

[root@localhost ~]#

統計文件內容命令

wc命令:統計文件中的單詞數量等信息

格式

wc [選項]... 目標文件 ...

命令字

選項

作用wc

默認統計行數、單詞數、字節數

wc

-l

統計行數

wc

-w

統計單詞個數

wc

-c

統計字節數[root@localhost ~]# wc /etc/httpd/conf/httpd.conf //統計文件行數、單詞數、字節數

353 1801 11753 /etc/httpd/conf/httpd.conf //顯示行數、單詞數、字節數

[root@localhost ~]# wc -l /etc/httpd/conf/httpd.conf //只統計文件行數

353 /etc/httpd/conf/httpd.conf //顯示行數

[root@localhost ~]# wc -w /etc/httpd/conf/httpd.conf //只統計文件單詞數

1801 /etc/httpd/conf/httpd.conf //顯示單詞數

[root@localhost ~]# wc -c /etc/httpd/conf/httpd.conf //只統計文件字節數

11753 /etc/httpd/conf/httpd.conf //顯示字節數

[root@localhost ~]#

檢索和過濾文件內容命令

grep命令:在文件中查找并顯示包含指定字符串的行

格式

grep [選項] 查找條件 目標文件

命令字

選項

作用grep

在目錄中查找文件(正向查找,查找我們需要的信息)

grep

-i

查找時忽略大小寫

grep

-v

反轉查找,輸出與查找條件不相符的行

查找條件設置

要查找的字符串以雙引號括起來

“^……“表示以……開頭,”……$‘表示以……結尾

“^$”表示空行[root@localhost ~]# grep "ftp" /etc/passwd //在passwd中查找“ftp”文件

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin //查找出的文件信息

[root@localhost ~]# cd /etc/httpd/conf //進入到conf文件目錄

[root@localhost conf]# ls //查看目錄內配置文件

httpd.conf magic //顯示內容

[root@localhost conf]# grep -v "#" httpd.conf //查找httpd.conf文件中不帶#的文件

ServerRoot "/etc/httpd"

Listen 80

Include conf.modules.d/*.conf

User apache

Group apache //顯示查找的內容

ServerAdmin root@localhost

//以下省略...

[root@localhost conf]# grep "bash$" /etc/passwd //在passwd文件中查找以bash為結尾

root:x:0:0:root:/root:/bin/bash 的文件

sun:x:1000:1000:sun:/home/sun:/bin/bash //顯示以bash為結尾的文件

[root@localhost conf]# grep "^n" /etc/passwd //在passwd文件中查找以n為開頭的文件

nobody:x:99:99:Nobody:/:/sbin/nologin

nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin

ntp:x:38:38::/etc/ntp:/sbin/nologin //顯示以n為開頭的文件內容

使用壓縮和解壓縮工具

gzip命令與bzip2命令

gzip 制作的壓縮文件默認的擴展名為“.gz”

bzip2 制作的壓縮文件默認的擴展名為“.bz2“

(gzip格式 bzip2格式 創建壓縮包或者解開壓縮包原文件會消失)

格式

命令字

選項

作用gzip/bzip2

-9

壓縮文件(命令字后面不輸入選項時默認為 ”-9”)

gzip/bzip2

-d

解壓文件[root@localhost conf]# cd /mnt //進入mnt文件目錄

[root@localhost mnt]# ls //查看目錄文件

demo02.txt demo.jpg tast01.txt tast02.txt //顯示目錄文件

[root@localhost mnt]# gzip -9 demo02.txt //以gzip格式壓縮demo02文件

[root@localhost mnt]# ls //查看

demo02.txt.gz demo.jpg tast01.txt tast02.txt //demo02為gz格式壓縮文件

[root@localhost mnt]# gzip -d demo02.txt.gz //解壓demo02

[root@localhost mnt]# ls //查看

demo02.txt demo.jpg tast01.txt tast02.txt //demo02解壓

[root@localhost mnt]# bzip2 -9 demo02.txt //以bzip2格式壓縮demo02文件

[root@localhost mnt]# ls //查看

demo02.txt.bz2 demo.jpg tast01.txt tast02.txt //demo02為bz2格式壓縮文件

[root@localhost mnt]# bzip2 -d demo02.txt.bz2 //解壓demo02

[root@localhost mnt]# ls //查看

demo02.txt demo.jpg tast01.txt tast02.txt //demo02解壓

歸檔命令

tar命令:制作歸檔文件、釋放歸檔文件

格式

tar [選項] .... 歸檔文件名 源文件或目錄

tar [選項] ... 歸檔文件名 [-C 目標目錄]

命令字-

選項

作用tar

-c

創建壓縮包

tar

-x

解壓

tar

-v

顯示詳細信息

tar

-f

執行

tar

-p

保留原有權限

tar

-t

查看壓縮包內容

tar

-C

解壓目標路徑

tar

-z

gzip格式

tar

-j

bzip2格式[root@localhost mnt]# tar czvf demo.tar.gz demo02.txt tast01.txt

demo02.txt //將demo02、tast02文件壓縮為gz格式的壓縮文件命令為demo

tast01.txt

[root@localhost mnt]# ls //查看

demo02.txt demo.jpg demo.tar.gz tast01.txt tast02.txt //顯示demo壓縮文件

[root@localhost mnt]# mkdir /data //創建新文件夾data

[root@localhost mnt]# tar xzvf demo.tar.gz -C /data/

demo02.txt //將demo解壓到新建的data文件夾

tast01.txt

[root@localhost mnt]# cd /data //進入data文件就夾

[root@localhost data]# ls //查看

demo02.txt tast01.txt //顯示解壓內容

補充知識點

">":重定向符號的應用(輸出重定向到一個文件或設備 覆蓋原來的文件)

“>>”:輸出重定向到一個文件或設備 追加原來的文件

“|”:管道符號(格式:命令A|命令B,即命令1的正確輸出作為命令B的操作對象)

內容來源于網絡,如有侵權請聯系客服刪除

總結

以上是生活随笔為你收集整理的7 centos 查看程序文件数量_解析CentOS 7中系统文件与目录管理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。