時間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評論(2)
六、用戶和組相關命令
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文件設置為可執(zhí)行,腳本類文件一定要這樣設置一個,否則得用bash file才能執(zhí)行
chmod 666 file 將文件file設置為可讀寫
chmod 750 file 將文件file設置為,所有者為完全權限,同組可以讀和執(zhí)行,其他無權限
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
-d
gnuzip? -f
例如:
# 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?
unzip?
例如:
# 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.sh
3、bzip2根式命令
功能:bzip2格式壓縮命令,
注意:生成的文件會把源文件覆蓋
bzip2??
bunzip2
例如:
# 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命令
功能:歸檔、壓縮等,比較重要,會經(jīng)常使用。
-cvf?
-xvf?
-zcvf?
-zxvf?
-zcvf?
-zxvf?
舉例:
# 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
八、網(wǎng)絡相關命令
1、ifconfig命令
功能:顯示修改網(wǎng)卡的信息
ifconfig? 顯示網(wǎng)絡信息
ifconfig eth0 顯示eth0網(wǎng)絡信息
修改網(wǎng)絡信息:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 設置網(wǎng)卡1的地址192.168.1.1,掩碼為255.255.255.0
ifconfig eth0:1 192.168.1.2 ?? 捆綁網(wǎng)卡1的第二個地址為192.168.1.2
ifconfig eth0:x 192.168.1.n ?? 捆綁網(wǎng)卡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
#p#副標題#e#
2、route命令
功能:顯示當前路由設置情況
route 顯示當前路由設置情況,比較慢一般不用。
route add -net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254? 添加靜態(tài)路由
route del -net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254? 添加靜態(tài)路由
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?? 255.255.0.0???&
關鍵詞標簽:Linux,shell命令
相關閱讀
熱門文章
安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程
Tomcat9.0如何安裝_Tomcat9.0環(huán)境變量配置方法
多種操作系統(tǒng)NTP客戶端配置
Linux操作系統(tǒng)修改IP
人氣排行 Linux下獲取CPUID、硬盤序列號與MAC地址 dmidecode命令查看內(nèi)存型號 linux tc實現(xiàn)ip流量限制 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 linux下解壓rar文件 lcx.exe、nc.exe、sc.exe入侵中的使用方法 Ubuntu linux 關機、重啟、注銷 命令 查看linux服務器硬盤IO讀寫負載