“Linux命令”的版本间的差异
来自qingwei personal wiki
(→替换文本里所有符合条件字符) |
|||
第19行: | 第19行: | ||
<source lang="shell"> | <source lang="shell"> | ||
sed -i 's/原来字符/替换字符/g' "替换的文件名" | sed -i 's/原来字符/替换字符/g' "替换的文件名" | ||
+ | </source> | ||
+ | |||
+ | == 用户管理 == | ||
+ | === 添加sudo权限用户 === | ||
+ | <source lang="shell"> | ||
+ | adduser username | ||
+ | passwd username | ||
+ | usermod -aG wheel username | ||
+ | |||
+ | # 修改文件 /etc/sudoers | ||
+ | ## Allow root to run any commands anywhere | ||
+ | root ALL=(ALL) ALL | ||
+ | qingwyan ALL=(ALL) ALL | ||
</source> | </source> |
2017年12月1日 (五) 09:52的版本
awk
打印第一行第二列
ps -ef | grep sshd | head -n1 | awk {'print $2'}
# example
[qingwyan@localhost smartphy114]$ ps -ef | grep sshd
root 1405 1 0 Nov23 ? 00:00:00 /usr/sbin/sshd -D
root 13092 1405 0 19:49 ? 00:00:00 sshd: qingwyan [priv]
qingwyan 13108 13092 0 19:49 ? 00:00:00 sshd: qingwyan@notty
qingwyan 16602 32280 0 21:07 pts/5 00:00:00 grep --color=auto sshd
root 20010 1405 0 Nov28 ? 00:00:02 sshd: root@pts/19
[qingwyan@localhost smartphy114]$ ps -ef | grep sshd | head -n1 | awk {'print $2'}
1405
sed
替换文本里所有符合条件字符
sed -i 's/原来字符/替换字符/g' "替换的文件名"
用户管理
添加sudo权限用户
adduser username
passwd username
usermod -aG wheel username
# 修改文件 /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
qingwyan ALL=(ALL) ALL