linux基本知識1
1.linux 基礎
2.linux c 語言(數據結構)
3.linux高級編程
4.ARM體系結構
5.sqlite/mysql數據庫
6.linux c++
7.QT 界面開發
8.nos 裸機接口驅動(s5pv210)
9.linux系統構建(uboot 內核編譯與裁剪 文件系統創建)
10.驅動開發(字符設備 塊設備 網絡設備)
linux 基礎
linux OS
unix--->linux
GPL:一般公共版權
linux是一個文件系統
linux系統組成:
a.系統內核
b.shell
c.application
linux系統內核組成部分:
1.MM(內存管理)
2.進程管理
3.進程調度
4.文件管理
5.設備與網絡接口
linu系統版本:
2.6.21
3.1.0-7.fc16.i686.PAE
3.1.0
3:內核版本
1.奇數 測試版本
偶數 髮型正式版本
21:對內核修改比較大的次數
linux系統:
fedora
redhat
ubuntu
磁盤分區:
a.主分區(c)
b.邏輯分區(d e f)
MBR:主引導記錄區(前512byte)
linux磁盤分區文件名
IDE
hda
hdb
s:(SCSI)
sda1 - c
sda5 - D
sda6 - E
sdb1/2
linux 系統引導方式:
1.GRUB
2.LILO
linux 內核分爲內核空間和用戶空間
用戶空間第一個啓動進程 init 進程
linux運行界面:
1.X server(類似於windows)
2.字符 (DOS)
linux運行模式:
1.0 init 0 關機
2.1 單用戶
3.2 多用戶不帶網絡(single)
4.3 完全多用戶帶網絡(一般用該模式)
5.4 預留
6.5 圖形界面(X server)
7.6 init 6 重啓
/etc/inittab (修改運行模式)
模式切換
圖形界面 -> 字符
[root@localhost etc]# init 3
字符 -> 圖形界面
[root@localhost etc]# startx
[root@localhost etc]# init 5
[yb@localhost /]$
[root@localhost /]#
linux根目錄:
bin:一般用戶可執行文件
sbin:系統管理員可執行文件
etc:系統配置文件
dev:設備映射文件
home:一般用戶主目錄(該用戶對系統設置文件)
root:root用戶主目錄
usr: usr/include:系統api函數頭文件,系統搜索頭文件默認目錄
usr/lib:庫文件目錄,系統搜索庫文件默認目錄
usr/local:用戶自己安裝其他程序文件
proc:系統實時運行映射目錄
mnt:掛載目錄(關在 U CDROM)
關在U盤:
1.vm---->removeable devices--->connect
2.fdisk -l //找到分配/dev/sdb1
3.掛載命令:
mount -t vfat /dev/sdb1 /mnt
4.cd /mnt
5.卸載 umount /mnt
6.vm---->removeable devices--->disconnect
boot:系統啓動運行目錄
linux命令格式
命令名 選項 參數
commandname options paras
ls
cd
文件命令
磁盤 分區 及其使用命令
df :磁盤使用情況
df -a //顯示所用磁盤信息
df --all
du:顯示目錄(子目錄)大小
man:幫助命令
man command
man du(q退出幫組界面)
如果man無法使用:
[root@localhost bin]#export PATH=$PATH:/usr/bin
du --help
fdisk 查看磁盤分區表
fdisk -l
顯示目錄所包含的文件或子目錄命令
ls(list)
[root@localhost home]# ls //顯示當前目錄信息
常用的選項:
-l:以表格列舉目錄信息
[root@localhost home]# ls -l
drwxrwxrwx. 2 root root 4096 Dec 17 11:24 windowshare
-a:顯示所喲文件或目錄包括隱藏文件或目錄
("."開頭的文件名 爲隱藏文件)
-i:顯示文件的節點號(系統自動分配給每一個文件或目錄,一定是唯一)
選項組合
ls -ali
[root@localhost yj]# ls -l /etc
// /etc:參數 查看etc目錄情況
分解信息:
drwxrwxrwx. 2 root root 4096 Dec 17 11:24 windowshare
d:文件類型
linux常見文件類型:
-:一般文件
d:目錄
b:塊設備文件
c:字符設備文件
s:套接字文件socket
l:鏈接文件
p:管道文件
rwxrwxrwx :對文件或目錄操作權限
rwx :文件目錄的所有者使用權限
rwx :文件目錄所有者同組其他成員使用權限
rwx :除開文件目錄所有者所在的組其他組成員使用權限
r:read
w:write
x:excute 執行
2:目錄或文件訪問入口數
root:目錄文件所有者
root:目錄文件所有者所在組名
4096:目錄文件大小
Dec 17 11:24 目錄文件創建日期
windowshare 目錄文件名
目錄切換
cd
絕對路徑:包含根目錄的路徑
相對路徑:不包含根目錄的路徑
[root@localhost yj]# cd shell
//相對切換,目標目錄是當前目錄子目錄
[root@localhost yj]# cd /etc
//絕對切換,目標目錄與當前目錄無任何關係
[root@localhost yj]# cd /home/windowshare //多級目錄切換
[root@localhost home]# cd yj/shell
[root@localhost home]# cd /home/windowshare
[root@localhost windowshare]# cd /tmp
特殊用法:
.:表示當前目錄
..:表示上一級目錄
~:用戶主目錄
/:根目錄
pwd 輸出當前目錄的絕對路徑值
cd .
cd ..
cd ~
cd /
cd ../.. 上一層目錄的上一層目錄
touch 創建文件
touch 文件名1 文件名2
touch a
touch b c
創建文件系統會按照默認權限授權
默認權限linux稱爲掩碼,可以umask命令查看
[yj@localhost ~]$ umask
0002
cat 讀取文件
cat 文件名
yj@localhost etc]$cat passwd//相對路徑
yj@localhost home]$ cat /etc/passwd//絕對路徑
head 讀取文件前n行
[yj@localhost home]$ head -10 /etc/passwd
tail讀物文件後n行
[yj@localhost home]$ tail -10 /etc/passwd
輸出包含指定關鍵字的行
[yj@localhost home]$ cat /etc/passwd | grep root//root爲關鍵字
分屏輸出(滿屏輸出)
[yj@localhost etc]$ cat passwd | more//回車輸出下一行,文本內容輸出完畢,自動結束
[yj@localhost etc]$ cat passwd | less//回車輸出下一行,文本內容輸出完畢,按"q"結束
mkdir 創建目錄
[yj@localhost ~]$ mkdir a
[root@localhost ~]# mkdir b c
[root@localhost ~]# mkdir /home/aa
[root@localhost ~]# ls /home
[root@localhost ~]# mkdir -p a1/a2//創建多級目錄
rmdir 刪除空目錄
[root@localhost ~]# rmdir c
[root@localhost ~]# rmdir c d
rm 刪除文件
[yj@localhost ~]$ rm a b c
[yj@localhost etc]$ rm /home/yj/a
rm刪除非空目錄
[root@localhost ~]# rm -r a//r:遞歸 ,先刪除子目錄,再刪除本目錄
[root@localhost ~]# rm -rf a1//-f:強制刪除
cp 複製文件或目錄
複製文件
cp 源文件 目標文件
[root@localhost ~]# cp /etc/passwd .
[root@localhost ~]# cp /etc/passwd /root
[root@localhost ~]# cp /etc/passwd /root/passwd1//複製並且重命名
複製目錄
[root@localhost ~]# cp -r aa /tmp
[root@localhost ~]# cp aa/* /tmp
[root@localhost tmp]# rm -f * //刪除目錄下的所有文件
[root@localhost tmp]# rm -rf * //刪除目錄下的所有文件和子目錄
[root@localhost aa]# cp -r * /tmp //複製當前目錄下的所有文件和子目錄
[root@localhost aa]# rm -f *.c //刪除.c文件
mv移動文件或目錄
mv 源文件 目標文件
移動文件
[root@localhost aa]# mv a /tmp
[root@localhost aa]# mv b e /tmp
[root@localhost aa]# mv /tmp/b ./b1
移動目錄
[root@localhost ~]# cd /tmp/aa
[root@localhost aa]# mkdir b2
[root@localhost tmp]# mv aa /root
//重命名操作
[root@localhost aa]# mv b1 b3
[root@localhost aa]# mv b2 b4
關機命令
init 0 只能是root用戶
shutdown -h now 只能是root用戶
halt
重啓命令
init 6 只能是root用戶
shutdown -r now 只能是root用戶
reboot
who 顯示所有用戶包括虛擬終端用戶和物理終端用戶
root tty1 2013-12-17 18:10 (:0)
root pts/0 2013-12-17 18:22 (:0.0)
root pts/1 2013-12-17 20:39 (:0.0)
whoami 物理終端用戶
wc 統計文檔中字符數 行數 單詞數
wc 文件名
wc a.txt
wc -c a.txt
wc -w a.txt
wc -l a.txt
grep 查找命令,輸出關鍵字所在行
cat a.txt | grep 關鍵字
cat /etc/passwd | grep root
whereis 查找,根據關鍵字在文件系統中搜索,輸出物理目錄
whereis ls
whereis man
find 當前目錄查找文件(文件名 文件大小 文件類型 文件目錄 文件創建時間 修改時間 訪問時間)
find -type 文件類型(d b c l p s f(-))
find -name filename
管道符號 "|"
commad1 | commad2 |commad3 | ......
前一個命令輸出作爲後一個命令輸入
cat /etc/passwd | grep root
cat /etc/passwd | grep root | grep operator
cat /etc/passwd | grep root | grep operator | wc
符號重定向
linux三個特殊文件操作符號值:
a.stdin 0 標準輸入
b.stdout 1 標準輸出
c.stderr 2 錯誤輸出
重定向符號:
輸出重定向符號
1.>
2.>>
command 1> 文件名 //默認爲標準輸出 command > 文件名
command 2> 文件名 //錯誤信息輸出到文件中
ls -l a.txt b.txt
ls -l a.txt b.txt > c.txt
ls -l a.txt b.txt 1> c.txt
ls -l a.txt b.txt 1> c.txt 2> d.txt
在寫之前先清空文件,如果文件不存在創建文件
ls -l a.txt b.txt
ls -l a.txt b.txt >> c.txt
ls -l a.txt b.txt 1>> c.txt
ls -l a.txt b.txt 1>> c.txt 2>> d.txt
把新內容追加到文件末尾
輸入重定向符號
3.<
4.<<
commad < filename 從文件讀取數據,給commad使用
wc < c.txt
cat << 結束符//cat << eof
輸入輸出符號一起使用:執行順序:從左到右
cat << eof > e.txt
鏈接文件
a.硬鏈接
b.軟鏈接(符號鏈接)
創建鏈接文件:
ln 源文件 鏈接文件
硬鏈接:
ln a.txt b.txt//實現對源文件物理備份,文件所有屬相完全一樣,源文件訪問入口數+1,如果刪除源文件,鏈接文件可以當作源文件使用
軟鏈接:
ln -s 源文件 鏈接文件
ln -s b.txt c.txt//類似於window快捷方式文件,鏈接屬相與源文件完全不一樣,大小比源文件要小很多,可以使用鏈接文件(源文件必須要存在)
echo 回顯輸出函數
echo "adfsfdsfdsf"
echo sdfsdfdsfds
修改文件或目錄訪問權限
chmod 權限 文件名/目錄名
rw-r--r--
all:rw-r--r--
user:rw-
grpup:r--r
other:r--
對所有者&&同組其他用戶&&其它組用戶增加權限
chmod a+r/w/x|rw/rx/wx|rwx b.txt
對所有者&&同組其他用戶&&其它組用戶減少權限
chmod a-r/w/x|rw/rx/wx|rwx b.txt
chmod a=r/w/x|rw/rx/wx|rwx b.txt
對所有者增加權限
chmod u+r/w/x|rw/rx/wx|rwx b.txt
對所有者減少權限
chmod u-r/w/x|rw/rx/wx|rwx b.txt
chmod u=r/w/x|rw/rx/wx|rwx b.txt
對同組其他用戶增加權限
chmod g+r/w/x|rw/rx/wx|rwx b.txt
對同組其他用戶減少權限
chmod g-r/w/x|rw/rx/wx|rwx b.txt
chmod g=r/w/x|rw/rx/wx|rwx b.txt
對其它組用戶增加權限
chmod o+r/w/x|rw/rx/wx|rwx b.txt
對其它組用戶減少權限
chmod o-r/w/x|rw/rx/wx|rwx b.txt
chmod o=r/w/x|rw/rx/wx|rwx b.txt
八進制數字表示法
r=read=4
w=write=2
x=execute=1
-=0 無權限
765:7=4+2+1=rwx
6=4+2=rw-
5=4+1=r-x
chmod 654 b.txt
chmod 321 b.txt
如果創建文件,文件模式:mode&~umask
mode:456
unask:022// umask 0
result:454 // mode & (~umask)
遞歸授權
[root@localhost yj]# chmod 765 a -R
[root@localhost yj]# chmod -R 765 a
改變文件創建者
chown 用戶名 文件名
[root@localhost yj]# chown yj a.txt
[root@localhost yj]# chown test a.txt//錯誤,test用必須存在
改變文件所屬組
chgrp 組名 文件名
[root@localhost yj]# chgrp yj a.txt
練習:
1.利用rename命令改變文件名
2.linux c 語言(數據結構)
3.linux高級編程
4.ARM體系結構
5.sqlite/mysql數據庫
6.linux c++
7.QT 界面開發
8.nos 裸機接口驅動(s5pv210)
9.linux系統構建(uboot 內核編譯與裁剪 文件系統創建)
10.驅動開發(字符設備 塊設備 網絡設備)
linux 基礎
linux OS
unix--->linux
GPL:一般公共版權
linux是一個文件系統
linux系統組成:
a.系統內核
b.shell
c.application
linux系統內核組成部分:
1.MM(內存管理)
2.進程管理
3.進程調度
4.文件管理
5.設備與網絡接口
linu系統版本:
2.6.21
3.1.0-7.fc16.i686.PAE
3.1.0
3:內核版本
1.奇數 測試版本
偶數 髮型正式版本
21:對內核修改比較大的次數
linux系統:
fedora
redhat
ubuntu
磁盤分區:
a.主分區(c)
b.邏輯分區(d e f)
MBR:主引導記錄區(前512byte)
linux磁盤分區文件名
IDE
hda
hdb
s:(SCSI)
sda1 - c
sda5 - D
sda6 - E
sdb1/2
linux 系統引導方式:
1.GRUB
2.LILO
linux 內核分爲內核空間和用戶空間
用戶空間第一個啓動進程 init 進程
linux運行界面:
1.X server(類似於windows)
2.字符 (DOS)
linux運行模式:
1.0 init 0 關機
2.1 單用戶
3.2 多用戶不帶網絡(single)
4.3 完全多用戶帶網絡(一般用該模式)
5.4 預留
6.5 圖形界面(X server)
7.6 init 6 重啓
/etc/inittab (修改運行模式)
模式切換
圖形界面 -> 字符
[root@localhost etc]# init 3
字符 -> 圖形界面
[root@localhost etc]# startx
[root@localhost etc]# init 5
[yb@localhost /]$
[root@localhost /]#
linux根目錄:
bin:一般用戶可執行文件
sbin:系統管理員可執行文件
etc:系統配置文件
dev:設備映射文件
home:一般用戶主目錄(該用戶對系統設置文件)
root:root用戶主目錄
usr: usr/include:系統api函數頭文件,系統搜索頭文件默認目錄
usr/lib:庫文件目錄,系統搜索庫文件默認目錄
usr/local:用戶自己安裝其他程序文件
proc:系統實時運行映射目錄
mnt:掛載目錄(關在 U CDROM)
關在U盤:
1.vm---->removeable devices--->connect
2.fdisk -l //找到分配/dev/sdb1
3.掛載命令:
mount -t vfat /dev/sdb1 /mnt
4.cd /mnt
5.卸載 umount /mnt
6.vm---->removeable devices--->disconnect
boot:系統啓動運行目錄
linux命令格式
命令名 選項 參數
commandname options paras
ls
cd
文件命令
磁盤 分區 及其使用命令
df :磁盤使用情況
df -a //顯示所用磁盤信息
df --all
du:顯示目錄(子目錄)大小
man:幫助命令
man command
man du(q退出幫組界面)
如果man無法使用:
[root@localhost bin]#export PATH=$PATH:/usr/bin
du --help
fdisk 查看磁盤分區表
fdisk -l
顯示目錄所包含的文件或子目錄命令
ls(list)
[root@localhost home]# ls //顯示當前目錄信息
常用的選項:
-l:以表格列舉目錄信息
[root@localhost home]# ls -l
drwxrwxrwx. 2 root root 4096 Dec 17 11:24 windowshare
-a:顯示所喲文件或目錄包括隱藏文件或目錄
("."開頭的文件名 爲隱藏文件)
-i:顯示文件的節點號(系統自動分配給每一個文件或目錄,一定是唯一)
選項組合
ls -ali
[root@localhost yj]# ls -l /etc
// /etc:參數 查看etc目錄情況
分解信息:
drwxrwxrwx. 2 root root 4096 Dec 17 11:24 windowshare
d:文件類型
linux常見文件類型:
-:一般文件
d:目錄
b:塊設備文件
c:字符設備文件
s:套接字文件socket
l:鏈接文件
p:管道文件
rwxrwxrwx :對文件或目錄操作權限
rwx :文件目錄的所有者使用權限
rwx :文件目錄所有者同組其他成員使用權限
rwx :除開文件目錄所有者所在的組其他組成員使用權限
r:read
w:write
x:excute 執行
2:目錄或文件訪問入口數
root:目錄文件所有者
root:目錄文件所有者所在組名
4096:目錄文件大小
Dec 17 11:24 目錄文件創建日期
windowshare 目錄文件名
目錄切換
cd
絕對路徑:包含根目錄的路徑
相對路徑:不包含根目錄的路徑
[root@localhost yj]# cd shell
//相對切換,目標目錄是當前目錄子目錄
[root@localhost yj]# cd /etc
//絕對切換,目標目錄與當前目錄無任何關係
[root@localhost yj]# cd /home/windowshare //多級目錄切換
[root@localhost home]# cd yj/shell
[root@localhost home]# cd /home/windowshare
[root@localhost windowshare]# cd /tmp
特殊用法:
.:表示當前目錄
..:表示上一級目錄
~:用戶主目錄
/:根目錄
pwd 輸出當前目錄的絕對路徑值
cd .
cd ..
cd ~
cd /
cd ../.. 上一層目錄的上一層目錄
touch 創建文件
touch 文件名1 文件名2
touch a
touch b c
創建文件系統會按照默認權限授權
默認權限linux稱爲掩碼,可以umask命令查看
[yj@localhost ~]$ umask
0002
cat 讀取文件
cat 文件名
yj@localhost etc]$cat passwd//相對路徑
yj@localhost home]$ cat /etc/passwd//絕對路徑
head 讀取文件前n行
[yj@localhost home]$ head -10 /etc/passwd
tail讀物文件後n行
[yj@localhost home]$ tail -10 /etc/passwd
輸出包含指定關鍵字的行
[yj@localhost home]$ cat /etc/passwd | grep root//root爲關鍵字
分屏輸出(滿屏輸出)
[yj@localhost etc]$ cat passwd | more//回車輸出下一行,文本內容輸出完畢,自動結束
[yj@localhost etc]$ cat passwd | less//回車輸出下一行,文本內容輸出完畢,按"q"結束
mkdir 創建目錄
[yj@localhost ~]$ mkdir a
[root@localhost ~]# mkdir b c
[root@localhost ~]# mkdir /home/aa
[root@localhost ~]# ls /home
[root@localhost ~]# mkdir -p a1/a2//創建多級目錄
rmdir 刪除空目錄
[root@localhost ~]# rmdir c
[root@localhost ~]# rmdir c d
rm 刪除文件
[yj@localhost ~]$ rm a b c
[yj@localhost etc]$ rm /home/yj/a
rm刪除非空目錄
[root@localhost ~]# rm -r a//r:遞歸 ,先刪除子目錄,再刪除本目錄
[root@localhost ~]# rm -rf a1//-f:強制刪除
cp 複製文件或目錄
複製文件
cp 源文件 目標文件
[root@localhost ~]# cp /etc/passwd .
[root@localhost ~]# cp /etc/passwd /root
[root@localhost ~]# cp /etc/passwd /root/passwd1//複製並且重命名
複製目錄
[root@localhost ~]# cp -r aa /tmp
[root@localhost ~]# cp aa/* /tmp
[root@localhost tmp]# rm -f * //刪除目錄下的所有文件
[root@localhost tmp]# rm -rf * //刪除目錄下的所有文件和子目錄
[root@localhost aa]# cp -r * /tmp //複製當前目錄下的所有文件和子目錄
[root@localhost aa]# rm -f *.c //刪除.c文件
mv移動文件或目錄
mv 源文件 目標文件
移動文件
[root@localhost aa]# mv a /tmp
[root@localhost aa]# mv b e /tmp
[root@localhost aa]# mv /tmp/b ./b1
移動目錄
[root@localhost ~]# cd /tmp/aa
[root@localhost aa]# mkdir b2
[root@localhost tmp]# mv aa /root
//重命名操作
[root@localhost aa]# mv b1 b3
[root@localhost aa]# mv b2 b4
關機命令
init 0 只能是root用戶
shutdown -h now 只能是root用戶
halt
重啓命令
init 6 只能是root用戶
shutdown -r now 只能是root用戶
reboot
who 顯示所有用戶包括虛擬終端用戶和物理終端用戶
root tty1 2013-12-17 18:10 (:0)
root pts/0 2013-12-17 18:22 (:0.0)
root pts/1 2013-12-17 20:39 (:0.0)
whoami 物理終端用戶
wc 統計文檔中字符數 行數 單詞數
wc 文件名
wc a.txt
wc -c a.txt
wc -w a.txt
wc -l a.txt
grep 查找命令,輸出關鍵字所在行
cat a.txt | grep 關鍵字
cat /etc/passwd | grep root
whereis 查找,根據關鍵字在文件系統中搜索,輸出物理目錄
whereis ls
whereis man
find 當前目錄查找文件(文件名 文件大小 文件類型 文件目錄 文件創建時間 修改時間 訪問時間)
find -type 文件類型(d b c l p s f(-))
find -name filename
管道符號 "|"
commad1 | commad2 |commad3 | ......
前一個命令輸出作爲後一個命令輸入
cat /etc/passwd | grep root
cat /etc/passwd | grep root | grep operator
cat /etc/passwd | grep root | grep operator | wc
符號重定向
linux三個特殊文件操作符號值:
a.stdin 0 標準輸入
b.stdout 1 標準輸出
c.stderr 2 錯誤輸出
重定向符號:
輸出重定向符號
1.>
2.>>
command 1> 文件名 //默認爲標準輸出 command > 文件名
command 2> 文件名 //錯誤信息輸出到文件中
ls -l a.txt b.txt
ls -l a.txt b.txt > c.txt
ls -l a.txt b.txt 1> c.txt
ls -l a.txt b.txt 1> c.txt 2> d.txt
在寫之前先清空文件,如果文件不存在創建文件
ls -l a.txt b.txt
ls -l a.txt b.txt >> c.txt
ls -l a.txt b.txt 1>> c.txt
ls -l a.txt b.txt 1>> c.txt 2>> d.txt
把新內容追加到文件末尾
輸入重定向符號
3.<
4.<<
commad < filename 從文件讀取數據,給commad使用
wc < c.txt
cat << 結束符//cat << eof
輸入輸出符號一起使用:執行順序:從左到右
cat << eof > e.txt
鏈接文件
a.硬鏈接
b.軟鏈接(符號鏈接)
創建鏈接文件:
ln 源文件 鏈接文件
硬鏈接:
ln a.txt b.txt//實現對源文件物理備份,文件所有屬相完全一樣,源文件訪問入口數+1,如果刪除源文件,鏈接文件可以當作源文件使用
軟鏈接:
ln -s 源文件 鏈接文件
ln -s b.txt c.txt//類似於window快捷方式文件,鏈接屬相與源文件完全不一樣,大小比源文件要小很多,可以使用鏈接文件(源文件必須要存在)
echo 回顯輸出函數
echo "adfsfdsfdsf"
echo sdfsdfdsfds
修改文件或目錄訪問權限
chmod 權限 文件名/目錄名
rw-r--r--
all:rw-r--r--
user:rw-
grpup:r--r
other:r--
對所有者&&同組其他用戶&&其它組用戶增加權限
chmod a+r/w/x|rw/rx/wx|rwx b.txt
對所有者&&同組其他用戶&&其它組用戶減少權限
chmod a-r/w/x|rw/rx/wx|rwx b.txt
chmod a=r/w/x|rw/rx/wx|rwx b.txt
對所有者增加權限
chmod u+r/w/x|rw/rx/wx|rwx b.txt
對所有者減少權限
chmod u-r/w/x|rw/rx/wx|rwx b.txt
chmod u=r/w/x|rw/rx/wx|rwx b.txt
對同組其他用戶增加權限
chmod g+r/w/x|rw/rx/wx|rwx b.txt
對同組其他用戶減少權限
chmod g-r/w/x|rw/rx/wx|rwx b.txt
chmod g=r/w/x|rw/rx/wx|rwx b.txt
對其它組用戶增加權限
chmod o+r/w/x|rw/rx/wx|rwx b.txt
對其它組用戶減少權限
chmod o-r/w/x|rw/rx/wx|rwx b.txt
chmod o=r/w/x|rw/rx/wx|rwx b.txt
八進制數字表示法
r=read=4
w=write=2
x=execute=1
-=0 無權限
765:7=4+2+1=rwx
6=4+2=rw-
5=4+1=r-x
chmod 654 b.txt
chmod 321 b.txt
如果創建文件,文件模式:mode&~umask
mode:456
unask:022// umask 0
result:454 // mode & (~umask)
遞歸授權
[root@localhost yj]# chmod 765 a -R
[root@localhost yj]# chmod -R 765 a
改變文件創建者
chown 用戶名 文件名
[root@localhost yj]# chown yj a.txt
[root@localhost yj]# chown test a.txt//錯誤,test用必須存在
改變文件所屬組
chgrp 組名 文件名
[root@localhost yj]# chgrp yj a.txt
練習:
1.利用rename命令改變文件名
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.