首页 > 技术文章 > 问题笔记-不定时更新

wangjie20200529 2021-01-12 13:39 原文

1. su - web出现-bash-4.2$
原因是在useradd添加普通用户时,有时会丢失家目录下的环境变量文件:
.bashrc
.bash_profile
解决问题:
cp /etc/skel/.bashrc /home/web/
cp /etc/skel/.bash_profile /home/web/
2. bash: ip command not found
系统:centos7
问题:bash: ip command not found
解决办法: yum -y install initscripts
3. vim高亮显示
echo "export EDITOR=vim" >>/etc/profile.d/env.sh
source /etc/profile.d/env.sh
4. 批量修改不同目录下相同文件名
find /web/migration/fileStore/fs/ -name 'data.mp4' -exec rename "data.mp4" "data" {} ;
5. 每行后面加序号
find /web/shell -maxdepth 1 -type f -name "install"|awk -F "/" '{print $4}'|awk '{print $0" "FNR}'
6. 每行前面加序号
find /web/shell -maxdepth 1 -type f -name "install
"|awk -F "/" '{print $4}'|cat -n
find /web/shell -maxdepth 1 -type f -name "install*"|awk -F "/" '{print $4}'|awk '{ print FNR " " $0}'
7. 禁止普通用户直接登录服务器
vim /etc/ssh/sshd_config
新增一行
DenyUsers web
重启ssh服务
service sshd restart
8. 禁止root用户直接登录服务器
vim /etc/ssh/sshd_config
PermitRootLogin no
重启ssh服务
service sshd restart

推荐阅读