常见问答整理

常见面试题

https://www.cnblogs.com/sunyllove/p/9578620.html

认证论坛

https://bbs.hh010.com/

ip拆分小工具 

http://www.17ce.com/site/http/201703_5f94d88b0a38fb156d8efbf596d5ea32.html

shell 100例

https://blog.csdn.net/yugemengjing/article/details/82469785

华为路由器配置

http://bbs.51cto.com/thread-1555655-1-1.html

$grep -5 'parttern' inputfile //打印匹配行的前后5行
 
$grep -C 5 'parttern' inputfile //打印匹配行的前后5行
 
$grep -A 5 'parttern' inputfile //打印匹配行的后5行
 
$grep -B 5 'parttern' inputfile //打印匹配行的前5行
 
grep -C 1 "error" tomcat/logs

1.
linux启动过程
int进程linux第一启动进程
读取/etc/inittab 配置文件
初始化系统 设置主机名 ip地址等
根据启动级别启动软件
登录界面
2.负载
w
utime
top
free -h
3.awk 和sed区别

awk 擅长取列 默认正则
sed 擅长取行 -r 支持正则

grep 过滤行 egrep 支持正则-o 只显示匹配的字符

4.查看主机配置
lscpu
cat /proc/cpuinfo
cat /proc/meminfo

5.统计目录大小
du -sh /*

修改文件打开最大数
vi /etc/security/limits.conf #在最后添加:
* soft nofile 1024000
* hard nofile 1024000

用户可以打开的最大进程数
vi /etc/security/limits.d/20-nproc.conf
改:
* soft nproc 10240
为:
* soft nproc 66666
* hard nproc 66666

日志默认文件位置
/var/log/message
6.http
404 no find

7.路由器
华为
8.mysql的端口 ssh
3306 22

9.在11月分内 每天的早上6点到12点 每隔2个小时执行
/usr/bin/httpd.sh

00 06,08,10,12 * 11 * /bin/sh /usr/bin/httpd.sh
10.查找大于100k的文件

find /usr/local/test-type f -size +100k |xargs mv -t /tmp

find /usr/local/test -type f -size +100k -exec mv {} /tmp

mv $(find /usr/local/test -type f -size +100k) /tmp

11.查看进程1022端口

netstat -anput | grep 10022

12 运维工程师的工作认识

数据安全
网站7*24
提升用户体验

13.查看某个文件下的目录数
[root@node62 ~]# find / -type d -maxdepth 1 |wc -l

[root@node62 ~]# tree -Ld 1 /

14
umask 022
最大权限减去022是文件的默认权限
15.排除a打包
tar czf /tmp/test.tar.gz /test --exclude=/test/a

16.进程打开的文件
[root@node62 ~]# lsof |grep sshd

17,查看rpm内的文件

rpm -ql test.rpm

18.软连接
mkdir /test/{a,b}
ln -vs /test/a /test/b

19.第一变量生效
[root@node62 ~]# test=2
[root@node62 ~]# echo test
test
[root@node62 ~]# echo $test
2

20.开机启动

vim /etc/init.d/testd
# chkconfig: 2345 99 99
hostanme

chkconfig --add testd
chkconfig testd on
chkconfig --list

21.shell下的命令
/usr/bin
/bin

22. ip 获取

[root@node62 ~]# ifconfig ens192 |sed -n '2p'|awk '{print $ 2}'

23.批量创建账号

https://www.cnblogs.com/hackerer/archive/2016/01/02/5085418.html

http://blog.51cto.com/13859027/2159456?source=dra #解析

 24.正则生成工具

http://tools.jb51.net/regex/create_reg

常用端口查询

25.批量修改文件后缀

[root@node62 bak]# rename .repo .repo.bak *.repo

 26. cpu 前十

# Linux 下 取进程占用 cpu 最高的前10个进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

# linux 下 取进程占用内存(MEM)最高的前10个进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
内存
[root@node62 ~]# ps -A --sort -rss -o comm,pmem,pcpu |uniq -c |head -10
cpu
[root@node62 ~]# ps -A --sort -%cpu -o comm,pmem,pcpu |uniq -c |head -10

[root@node62 ~]# ps -e aux|head -1
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

PID 进程ID
TTY 与进程关联的终端
TIME 进程使用CPU累计时间
CMD 执行文件的名称
VSZ 虚拟内存
RSS 常驻内存

 27 忽略大小替换

sed -i 's/b/d/Ig' b.txt

28.nginx排序

awk '{print $1}' /usr/local/nginx/logs/localhost.access.log | sort | uniq -c | sort -nr -k1 | head -n 10

29.添加20个用户

for i in `seq -w 1 20`
do
    user="user$i"
    password=$(cat /dev/urandom | head -1 | md5sum | head -c 1-5)
    useradd user$i
    echo "$user:$password" | passwd --stdin $user
    echo "$user-$password" >> userinfo.txt
done

忽略大小写参考 :https://blog.51cto.com/fantefei/1366824

参考连接:https://blog.csdn.net/weixin_33916256/article/details/86251662

57分钟

https://www.centos.bz/2019/01/%E6%90%AD%E5%BB%BA-keepalived-nginx-tomcat-%E7%9A%84%E9%AB%98%E5%8F%AF%E7%94%A8%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E6%9E%B6%E6%9E%84/

原文地址:https://www.cnblogs.com/zsl-find/p/10245875.html