Abstract: [Notes] CentOS finishing finishing commonly used commands (U ~ Z)
Sort out the commands related to the CentOS,
Basically use man to see would be more complete, following just a few simple and common combination.
Of course, will increase the number of related notes.
1. ulimit: control of system resources
1.1 ulimit -a:. Displays current system resource usage limits
1.2 ulimit -d block size: on-line process data segment size, the unit is ' KB '
1.3 ulimit -f File size: set ' shell ' to establish the maximum file size limit
1.4 ulimit -H quota size:. ' Hard limit ', set strict, not to exceed the value set
1.4 ulimit -l memory size: Setting lockable memory limit
. 1.5 ulimit -m memory size: set the upper limit of the resident program
1.6 ulimit -n file number: the maximum number of files
1.7 ulimit -S quota size:. ' Soft limit ', warning setting, the set value can be exceeded, if it exceeds a warning message,
Generally '-H' fit. For example: Soft set to 80, 100 is set to Hard, so the range of 80 to 100, can be more than 80, but a warning message.
1.8 The number of -u process ulimit:. The maximum number of single-user executable process
. 1.9 ulimit -v virtual memory: ' the shell ' can use virtual memory maximum limit
2. umask: set the new file permissions screen
a umask:. displays the default file permissions
b umask -S:. permission rights mask in words in the set
Note: The general competence for the complete authority (777) minus the shielding permission. Ex. 022 is shielded authority, the general authority for the 777-022 = 755
3. umount: unmount the file system
a umount / cdrom:. unloading the mounted directory ' cdrom '
. b umount -a: uninstall all defined in ' / etc / mtab the' file system
4. uname: Information Display System
a uname -a:. Show all news
b uname -i:. display hardware platform
c uname -m:. Display Hardware
d uname -n:. Displays the host name
e uname -o:. Display Operating System
f uname -p:. class display processor
g uname -r:. shows the version of the operating system kernel
h uname -s:. Displays the name of the operating system
i uname -v:. display system
5. uniq: Sort command, check, calculate, delete duplicate files appear in the ranks
Usage: uniq [-cdiu]
01. cat test1 | sort | uniq: Sort and remove duplicate ranks
02. cat test1 | sort | uniq -c: count the number of recurring
03. cat test1 | sort | uniq -d: display only ranks recurring
04. cat test1 | sort | uniq -i: ignore case
05. cat test1 | sort | uniq -u: show only ranks once
6. unset: remove variable settings
. A unset -f variables: only the function removes
. B unset -v variables: Only variables removed
7. unzip: Unzip the zip file
a unzip -l test.zip:. Display ' test.zip file' contained
b. unzip test.zip:解压缩‘test.zip’
c. unzip -t test.zip:检查‘test.zip’的正确性
d. unzip -u test.zip:更新已存在的文件,并将压缩档的其他文件解开
e. unzip -c test.zip:解压缩到标准输出,并将符做适当转换
注:参数‘-p’与‘-c’类似,但不会对符做转换
8. uptime:显示系统已经执行的时间
a. uptime:显示系统开机时间、使用时间/天数、目前线上使用者数、系统‘Load Average’。
9. useradd:新增账号
用法:useradd [ -u UID ] [ -g 初始群组 ] [ -G 次要群组 ] [ -mM ] [ -c 说明栏 ] [ -d 根目录绝对路径 ] [ -s shell ]
[ -efr ] username
01. useradd -u 1111 -d /tmp/ghoseliang -m ghoseliang:指定使用者的‘UID’为‘1111’及根目录为
‘/tmp/ghoseliang’
02. useradd -g test1 user1:新增账号并指定账号的初始群组
注:可在‘/etc/passwd’看到第四字段所属群组的‘GID’
03. useradd -G test2 user2:新增账号并指定该账号的次要群组
注:可在‘/etc/group’看到相关数据
04. useradd -M user3:强制不建立使用者账号根目录
05. useradd -e 2013-03-19 ghoseliang:指定账号的有效期限,保存在‘/etc/shadow’。
06. useradd -f 1 ghoseliang:限定密码过期多少天后,将该使用者账号停用
07. useradd -D:调用默认值或是直接查看‘/etc/default/useradd’
08. for i in $(seq 1 1 10); do useradd ghoseliang${i}; echo ghoseliang${i} | passwd --stdin
ghoseliang${i}; done:使用‘for’循环一次新增多个账号
注:有关‘for’循环简易应用,请参考最下方备注的‘04’
注1:‘/etc/login.defs’:默认账号基本设定
注2:‘/etc/skel/’:使用者根目录内容数据参考目录
注:有关‘/etc/passwd’、‘/etc/group’、‘/etc/shadow’请参考最下方备注的( 01 - 03 )
10. userdel:删除账号
用法:userdel [ -r ] username
01. userdel ghose:删除使用者账号,但不会删除该使用者目录
02. userdel -r ghoseliang:删除使用者账号并删除该使用者根目录下所有文件
03. for i in $(seq 1 1 10); do userdel -r ghoseliang${i}; done:使用‘for’循环一次删除多个账号
11. usermod:修改账号设定
用法:usermod [ -cdefgGlsuLU ] username
01. usermod -c "This is test" user1:后面接账号的说明,即‘/etc/passwd’第五栏的说明栏,可以加入一些账号
的说明
02. usermod -d /tmp/user2 [ -m ] user2:指定使用者登入时所进的目录,并给予对该目录的完全控制权,即修改
‘/etc/passwd’第六栏
注:参数‘-m’为旧目录会搬至新目录,若旧目录不存在则会新建一个
03. usermod -e 2013-05-30 ghoseliang:指定账号的有效期限,即‘/etc/shadow’第八字段
04. usermod -f 2 ghoseliang:限定密码过期多少天后将该使用者账号停用
注:‘0’为立刻停用,‘-1’为关闭此功能,默认为‘-1’
05. usermod -g test1 user2:更改使用者账号初始群组,即修改‘/etc/passwd’第四字段,亦是‘GID’字段
注:群组名称需存在。
06. usermod -G test3 user2:修改次要群组( 支持群组 ),即修改‘/etc/group’第四字段
07. usermod -l ghose user2:修改‘LoginName’
08. usermod -s /bin/csh ghoseliang:修改‘登入shell’,若空白,系统则采用‘默认shell’
09. usermod -u 502 ghose:修改使用者账号的‘UID’,即修改‘/etc/passwd’第三字段
注:除非使用‘-o’,为‘非唯一值’。数字不可为‘负值’。
10. usermod -L ghoseliang:冻结使用者密码,使其无法登入,即修改‘/etc/shadow’密码栏
11. usermod -U ghoseliang:解除冻结,即修改‘/etc/shadow’密码栏,将‘!’移除
注:有关‘/etc/passwd’、‘/etc/group’、‘/etc/shadow’请参考最下方备注的( 01 - 03 )
12. users:显示目前登入的账号资讯
13. vi:文书编辑器
参考网址:http://linux.vbird.org/linux_basic/0310vi.php
14. vim:文书编辑器,具程序编辑能力,可主动的以字体颜色辨别语法的正确性,
方便程序设计
参考网址:http://linux.vbird.org/linux_basic/0310vi.php
15. vmstat:显示虚拟内存的状态
a. vmstat -a:显示使用与非使用中的虚拟内存状态
b. vmstat -d:显示磁盘状态
c. vmstat -f:显示开机后fork的用量
d. vmstat -s:显示较完整的数据与统计
e. vmstat -S 单位:单位为k、K、m、M,分别以1000、1024、1000000、1048576 bytes为单位
16. w:显示目前登入的账号资讯
a. w -f ghoseliang:显示使用者从何处登入
b. w -h:不显示标题列
c. w -s:将账号资讯用较简洁的格式显示
注:‘USER’为登入的使用者;‘TTY’为终端机;‘FROM’为来源位址;‘LOGIN@’为登入的时间;
‘IDLE’为闲置的时间;‘JCPU’为对于同一个终端机下所有进程的执行时间;
‘PCPU’为‘WHAT’字段显示的进程所执行的时间;‘WHAT’为目前正在执行的工作。
17. wall:广播消息
a. wall 消息:传讯‘消息’给所有同意接受公开消息的终端机
18. watch:周期性的执行命令并以全屏幕输出
a. watch [命令]
b. watch -d w:标记与之前显示的差异部分
c. watch -n 5 w:每隔5秒执行一次命令
19. wc:计算文件的byte数、字数、列数
用法:wc [ -clLmw ] [ File ]
01. wc /etc/man.config:计算并列出文件中的‘行数’、‘字数(英文字母)’、‘符数’
02. wc -c /etc/man.config:列出文件的‘byte数’
03. wc -l /etc/man.config:计算并列出文件的‘行数’
04. wc -L /etc/man.config:计算并列出文件最长列的‘符数’
05. wc -m /etc/man.config:计算并列出文件的‘符数’
06. wc -w /etc/man.config:计算并列出文件的‘字数(英文字母)’
20. wget:从指定的网址下载文件
a. wget 文件下载位址
注:从man上查看有许多参数可运用,有兴趣者可自行尝试。
21. whereis:寻找指定的文件
a. whereis Filename
b. whereis -m Filename:寻找该文件的说明档
22. which:寻找指定的文件
23. who:显示目前登入的账号资讯
a. who -a:显示所有资讯
b. who -b:显示系统最近一次重新启动的时间
c. who -m:只列出自己登入的相关资讯
d. who -q:显示目前登入的使用者名称与总人数
e. who -r:显示目前的执行等级
f. who -t:显示最后一次修改时钟的时间
g. who -u:显示使用者已闲置的时间
24. write:传送消息给其他使用者
25. yum:套件更新管理
a. yum install 套件1 [套件2]...:安装套件
b. yum update [套件1] [套件2]...:更新套件,若不加套件,则会更新目前已安装的所有套件
c. yum remove 套件1 [套件2]...:移除套件
d. yum clean packages:清除暂存在‘/var/cache/yum/’下的套件
e. yum list:列出所有套件
f. yum list update:列出所有可以更新的套件
g. yum list installed:列出所有已安装的套件
h. yum check-update:检查可以更新的套件
i. yum info:列出所有套件的资讯
j. yum grouplist:列出所有群组套件
k. yum groupinstall 套件1 [套件2]...:安装群组套件
l. yum groupupdate 套件1 [套件2]...:更新群组套件
m. yum groupremove 套件1 [套件2]...:移除群组套件
n. yum groupinfo 套件1 [套件2]...:列出群组套件的资讯
26. zip:压缩为zip档
a. zip test.z /root/*:将‘/root/’下所有文件压缩为压缩档‘test.z’
b. zip -d test.z /root/test1:移除压缩档‘test.z’内的文件‘test1’
c. zip -m test2.z /root/Filename:将文件压缩后,删除原始文件
27. zipinfo:显示压缩档详细资讯
备注
1. /etc/passwd:使用者账号资讯,为7个字段并使用冒号‘:’隔开
01. 第一字段( User Name ):使用者账号名称
02. 第二字段( Password ):使用者密码,保存于‘/etc/shadow’
03. 第三字段( UID ):使用者号码( User ID Number )
04. 第四字段( GID ):使用者群组号码( Group ID Number )
05. 第五字段( Remark ):使用者资讯说明栏
06. 第六字段( Home Directory ):使用者根目录路径,即该使用者账号登入系统后默认登入目录
07. 第七字段( Shell ):使用者账号登入后第一个执行的进程
注:每个使用者账号会有一个唯一的识别码称为‘UID( User ID Number)’,并从序号500开始,有关使用者账号
资讯保存于‘/etc/passwd’、‘/etc/shadow’;有关使用者群组资讯保存于‘/etc/group’、
‘/etc/gshadow’。
2. /etc/group:使用者群组资讯,为4个字段并使用冒号‘:’隔开
01. 第一字段( Group ID ):群组名称,ex. ghoseliang
02. 第二字段( Password ):群组密码,保存于‘/etc/gshadow’
03. 第三字段( GID ):使用者群组号码( Group ID Number ),与‘/etc/passwd’的‘GID’字段相对应
04. 第四字段( Member ):群组成员,成员之间使用逗点( ,)隔开
注:每个使用者账号会有一个唯一的识别码称为‘UID( User ID Number)’,并从序号500开始,有关使用者账号
资讯保存于‘/etc/passwd’、‘/etc/shadow’;有关使用者群组资讯保存于‘/etc/group’、
‘/etc/gshadow’。
3. /etc/shadow:使用者密码资讯,为 9个字段并使用冒号‘:’隔开
01. 第一字段( User Name ):账号名称,与‘/etc/passwd’相对应
02. 第二字段( Password ):经过编码(加密)的密码
03. 第三字段( Last Password Change ):最近更动密码的日期
04. 第四字段( Minimum ):密码不可被更动的天数,在最近一次被更改后需要经过几天才可以再被变更。
05. 第五字段( Maximum ):密码需要重新变更的天数,命令在最近一次更改密码后,在多少天数内需要再次的变更
密码。
06. 第六字段( Warn ):密码需要变更期限前的警告天数
07. 第七字段( Inactive ):密码过期后的账号宽限时间,即密码失效日。密码过期时,仍可使用,不过系统会强制要
求必须重新设定密码才能登入继续使用。但若到了密码失效日,仍未更改密码,则无法使用该密码登入系统。
08. 第八字段( Expire ):账号失效日期
09. 第九字段( ):保留,看以后有无新功能加入
注:每个使用者账号会有一个唯一的识别码称为‘UID( User ID Number)’,并从序号500开始,有关使用者账号
资讯保存于‘/etc/passwd’、‘/etc/shadow’;有关使用者群组资讯保存于‘/etc/group’、
‘/etc/gshadow’。
4. ‘for’简易应用范例
01. for i in $(seq 1 1 10); do echo ${i}; done:‘for’循环中透过‘seq’来输出数字,初始值为‘1’,累加值为
‘1’(每次加‘1’),结束值为‘10’,利用‘echo’来输出每次‘seq’指定的‘i’值。
02. for i in $(seq -w 1 1 10); do echo ${i}; done:加入参数‘-w’来对齐数字
<......不定时更新、修改、增加中......>
原文:大专栏 【笔记整理】CentOS常用命令整理( U ~ Z )