linux日常筆記3

一、管理權(quán)限和歸屬

為商洛等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及商洛網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為做網(wǎng)站、成都網(wǎng)站制作、商洛網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

1.權(quán)限概述

文檔歸屬

所有者(u):擁有此文件/目錄的用戶-user

所屬組(g):擁有此文件/目錄的組-group

其他用戶(o):除所有者、所屬組以外的用戶-other

訪問權(quán)限

讀取(r):允許查看內(nèi)容-read

寫入(w):允許修改內(nèi)容-write

可執(zhí)行(x):允許運行和切換-excute

2.查看權(quán)限  ls -l 

# ls -l /etc/passwd

-|rw-|r--|r--. 1 root root 2481 2月  23 09:37 /etc/passwd   

① ② ③  ④   ⑤ ⑥   ⑦    ⑧    ⑨              ⑩

 權(quán)限解讀順序:⑩①⑥②⑦③④

① 文件類型

-文件

d目錄

l鏈接

② 所有者的權(quán)限

r = 4讀取

w = 2寫入

x = 1可執(zhí)行

-無

③ 所屬組的權(quán)限

r = 4讀取

w = 2寫入

x = 1可執(zhí)行

-無

④ 其他用戶的權(quán)限

r = 4讀取

w = 2寫入

x = 1可執(zhí)行

-無

⑤ 鏈接數(shù)

文件:鏈接數(shù)

目錄: 該目錄下有多少個子目錄(. ..)

⑥ 所有者

⑦ 所屬組

⑧ 文件大小

⑨ 文件創(chuàng)建時間

⑩ 文件/目錄名

3.更改文件歸屬

# chown  屬主:  文件/目錄更改文件/目錄的所有者

# chown  :屬組  文件/目錄更改文件/目錄的所屬組

# chown  屬主:屬組  文件/目錄更改文件/目錄的所有者和所屬組

-R遞歸

eg:

[root@ntd1711 ~]# rm -rf /tmp/*

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# mkdir /tmp/studir

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chown student /tmp/studir/

[root@ntd1711 ~]# id student

[root@ntd1711 ~]# useradd student

[root@ntd1711 ~]# id student

[root@ntd1711 ~]# chown student /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chown :users /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chown root:root /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

4. 更改文件/目錄權(quán)限

chmod命令

格式:chmod   [ugoa][+-=][rwx]   文檔路徑 ...

-R:遞歸修改(含所有子目錄及子目錄中的文檔)

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chmod g-rx,o-rx /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chmod u-w,g=rx /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

[root@ntd1711 ~]# chmod a=rwx /tmp/studir/

[root@ntd1711 ~]# ls -ld /tmp/studir

二、備份與恢復

1. 制作/釋放zip包

a.壓縮zip

格式:zip [-ry] 備份文件.zip 文檔路徑 ...

eg:

[root@ntd1711 ~]# ls -ld /boot/

[root@ntd1711 ~]# ls /opt/

[root@ntd1711 ~]# zip -ry /opt/boot_bak.zip /boot/

[root@ntd1711 ~]# ls /opt

b.解壓

格式:unzip 備份文件.zip [-d 目標文件夾]

格式:unzip 備份文件.zip

eg:

[root@ntd1711 ~]# ls /tmp/todir

[root@ntd1711 ~]# unzip -d /tmp/todir /opt/boot_bak.zip 

[root@ntd1711 ~]# ls /tmp/todir

2.制作/釋放.tar包

a.制作.tar包并壓縮

基本用法

格式:tar -zcPf 備份文件.tar.gz  文檔路徑 ...

格式:tar -jcPf 備份文件.tar.bz2 文檔路徑 ...

格式:tar -JcPf 備份文件.tar.xz  文檔路徑 ...

eg:

[root@ntd1711 ~]# ls -ld /var/log/

[root@ntd1711 ~]# du -sh /var/log/

[root@ntd1711 ~]# mkdir -p /tmp/day03

[root@ntd1711 ~]# tar -zcPf /tmp/day03/log.tar.gz  /var/log/

[root@ntd1711 ~]# tar -jcPf /tmp/day03/log.tar.bz2  /var/log/

[root@ntd1711 ~]# tar -JcPf /tmp/day03/log.tar.xz  /var/log/

[root@ntd1711 ~]# du -sh /tmp/day03/*

b.解壓縮.tar包

基本用法

格式:tar -xPf 備份文件.tar.gz

格式:tar -xf  備份文件.tar.bz2 

格式:tar -xf  備份文件.tar.xz  [-C 目標文件夾]

eg:

[root@ntd1711 ~]# cd /tmp/day03/

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# tar -xf log.tar.gz

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# rm -rf var

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# tar -xf log.tar.bz2

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# rm -rf var

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# tar -xf log.tar.xz

[root@ntd1711 day03]# ls

[root@ntd1711 day03]# rm -rf var

[root@ntd1711 day03]# ls

三、訪問光盤及ISO鏡像

1.掛載

mount 設備 掛載點(一定是目錄)

2.卸載

umount 設備

umount 掛載點

3.Linux下的光驅(qū)設備

/dev/sr0

/dev/cdrom

實驗:訪問光盤文件

1.放入光盤

把iso文件放入光驅(qū)

2.掛載

[root@ntd1711 ~]# ls /mnt/dvd

[root@ntd1711 ~]# mkdir -p /mnt/dvd

[root@ntd1711 ~]# ls /mnt/dvd/

[root@ntd1711 ~]# mount /dev/cdrom /mnt/dvd/

3.訪問光盤內(nèi)容

[root@ntd1711 ~]# ls /mnt/dvd/

4.卸載

[root@ntd1711 ~]# umount /mnt/dvd

[root@ntd1711 ~]# ls /mnt/dvd/

分享名稱:linux日常筆記3
轉(zhuǎn)載來于:http://muchs.cn/article10/jpeedo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設商城網(wǎng)站、Google、標簽優(yōu)化、App設計、網(wǎng)頁設計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設