六、使用者和組相關命令
1、groupadd命令
功能:添加組
groupadd test1 添加test1組
groupadd -g 1111 test2 添加test2組,組id為1111
2、useradd命令
功能:添加使用者
useradd user1 添加使用者user1,home為/home/user1,組為user1
useradd -g test1 -m -d /home/test1 test1 添加使用者test1,home為/home/test1,組為test1
user list 顯示已登陸的使用者列表
3、passwd命令
功能:更改使用者密碼
passwd user1 修改使用者user1的密碼
passwd -d root 將root使用者的密碼刪除
4、userdel命令
功能:刪除使用者
userdel user1 刪除user1使用者
5、chown命令
功能:改變檔案或目錄的所有者
chown user1 /dir 將/dir目錄設定為user1所有
chown -R user1.user1 /dir 將/dir目錄下所有檔案和目錄,設定為user1所有,組為user1。-R遞迴到下面的每個檔案和目錄
6、chgrp命令
功能:改變檔案或目錄的所有組
chgrp user1 /dir 將/dir目錄設定為user1所有
7、chmod命令
功能:改變使用者的許可權
chmod a+x file 將file檔案設定為可執行,指令碼類檔案一定要這樣設定一個,否則得用bash file才能執行
chmod 666 file 將檔案file設定為可讀寫
chmod 750 file 將檔案file設定為,所有者為完全許可權,同組可以讀和執行,其他無許可權
8、id命令
功能:顯示使用者的資訊,包括uid、gid等
# id zhoulj
uid=500(zhoulj) gid=500(zhoulj) groups=500(zhoulj)
9、finger命令
功能:顯示用的資訊
注意:debian下沒有該命令。
# finger zhoulj
Login: zhoulj Name:
Directory: /home/zhoulj Shell: /bin/bash
On since Sun May 21 07:59 (CST) on pts/0 from 192.168.1.4
No mail.
No Plan.
七、壓縮命令
1、gzip格式命令
功能:壓縮檔,gz格式的
注意:產生的檔案會把源檔案覆蓋
gzip -v <filename> 壓縮檔,並且顯示進度
-d <filename> 解壓縮
gnuzip -f <filename> 解壓縮
例如:
# gzip a.sh
#ll
-rwxr-xr-x 1 root root 71 12月 18 21:08 a.sh.gz
# gzip -d a.sh.gz
#ll
-rwxr-xr-x 1 root root 48 12月 18 21:08 a.sh
2、zip格式命令
功能:壓縮和解壓縮zip命令
zip <DSTfilename> <SRCfilename>
unzip <filename>
例如:
# zip a.sh.zip a.sh
adding: a.sh (stored 0%)
# ll
-rw-r–r– 1 root root 188 5月 21 10:37 a.sh.zip
# unzip a.sh.zip
Archive: a.sh.zip
replace a.sh? [y]es, [n]o, [A]ll, [N]one, [r]ename: r
new name: a1.sh
extracting: a1.sh
# ll
-rwxr-xr-x 1 root root 48 12月 18 21:08 a1.sh3、bzip2根式命令
功能:bzip2格式壓縮命令,
注意:產生的檔案會把源檔案覆蓋
bzip2 <filename>
bunzip2 <filename>
例如:
# bzip2 a.sh
# ll
-rwxr-xr-x 1 root root 85 12月 18 21:08 a.sh.bz2
# bunzip2 a.sh.bz2
# ll
-rwxr-xr-x 1 root root 48 12月 18 21:08 a.sh
4、tar命令
功能:歸檔、壓縮等,比較重要,會經常使用。
-cvf <DSTfilename.tar> <SRCfilename> 壓縮檔或目錄
-xvf <SRCfilename> 解壓縮檔案或目錄
-zcvf <DSTfilename> <SRCfilename> 壓縮檔或,格式tar.gz
-zxvf <DSTfilename> <SRCfilename> 解壓縮檔案或,格式tar.gz
-zcvf <DST.tgz> <SRCfilename> 壓縮檔或,格式tgz
-zxvf <DST.tgz> <SRCfilename> 解壓縮檔案或,格式tgz
舉例:
# tar cvf abc.tar *.sh
# tar xvf abc.tar
# tar czvf abc.tar.gz *.sh
# ll
-rw-r–r– 1 root root 20480 5月 21 10:50 abc.tar
-rw-r–r– 1 root root 1223 5月 21 10:53 abc.tar.gz
# tar xzvf abc.tar.gz
八、網路相關命令
1、ifconfig命令
功能:顯示修改網卡的資訊
ifconfig 顯示網路資訊
ifconfig eth0 顯示eth0網路資訊
修改網路資訊:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 設定網卡1的地址192.168.1.1,掩碼為255.255.255.0
ifconfig eth0:1 192.168.1.2 捆綁網卡1的第二個地址為192.168.1.2
ifconfig eth0:x 192.168.1.n 捆綁網卡1的第n個地址為192.168.1.n
例如:
# ifconfig eth0:1 192.168.1.11
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:06:9C:24
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4220 errors:0 dropped:0 overruns:0 frame:0
TX packets:3586 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:342493 (334.4 Kb) TX bytes:469020 (458.0 Kb)
Interrupt:9 Base address:0×1400
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:06:9C:24
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:9 Base address:0×1400
2、route命令
功能:顯示當前html" target=_blank>路由設定情況
route 顯示當前路由設定情況,比較慢一般不用。
route add -net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254 添加靜態路由
route del -net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254 添加靜態路由
route add default gw 192.168.1.1 metric1 設定192.168.1.1為預設的路由
route del default 將預設的路由刪除
舉例:
# route add -net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254
# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 192.168.1.254 &nb