linux日常笔记3
一、管理權(quán)限和歸屬
1.權(quán)限概述
文檔歸屬
所有者(u):擁有此文件/目錄的用戶-user
所屬組(g):擁有此文件/目錄的組-group
其他用戶(o):除所有者、所屬組以外的用戶-other
訪問(wèn)權(quán)限
讀取(r):允許查看內(nèi)容-read
寫入(w):允許修改內(nèi)容-write
可執(zhí)行(x):允許運(yùn)行和切換-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í)行
- 無(wú)
③ 所屬組的權(quán)限
r = 4 讀取
w = 2 寫入
x = 1 可執(zhí)行
- 無(wú)
④ 其他用戶的權(quán)限
r = 4 讀取
w = 2 寫入
x = 1 可執(zhí)行
- 無(wú)
⑤ 鏈接數(shù)
文件:鏈接數(shù)
目錄: 該目錄下有多少個(gè)子目錄(. ..)
⑥ 所有者
⑦ 所屬組
⑧ 文件大小
⑨ 文件創(chuàng)建時(shí)間
⑩ 文件/目錄名
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
二、備份與恢復(fù)
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 目標(biāo)文件夾]
格式: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 目標(biāo)文件夾]
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
三、訪問(wèn)光盤及ISO鏡像
1.掛載
mount 設(shè)備 掛載點(diǎn)(一定是目錄)
2.卸載
umount 設(shè)備
umount 掛載點(diǎn)
3.Linux下的光驅(qū)設(shè)備
/dev/sr0
/dev/cdrom
實(shí)驗(yàn):訪問(wèn)光盤文件
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.訪問(wèn)光盤內(nèi)容
[root@ntd1711 ~]# ls /mnt/dvd/
4.卸載
[root@ntd1711 ~]# umount /mnt/dvd
[root@ntd1711 ~]# ls /mnt/dvd/
轉(zhuǎn)載于:https://blog.51cto.com/11332405/2088134
總結(jié)
以上是生活随笔為你收集整理的linux日常笔记3的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 选择排序就这么简单
- 下一篇: 开源使得所有的软件卖成白菜价,但终将普惠