Linux common knowledge and fault handling 1, modify the current system language
For example, the current language is en_US. UTF-8, because the environment needs to be modified to ZH_CN. UTF-8, first switch to root, append a line of content.
echo ‘export LANG="zh_CN.UTF-8"‘ >> ~/.bashrc
Re-login to view language changes
echo $LANG
2, the Linux system in the root directory or the newly mounted disk directory has a called Lost+found, what is its role?
如果你运行fsck命令(文件系统检查和修复命令),它也许会找到一些数据碎片,这些文件碎片在硬盘中并没有引用。特别的,fsck也许能找到看起来是完整的文件,但是在系统中没有名字-一个inode但是不对应文件名。这个数据仍然占用硬盘空间,但是并不能通过正常方式访问。 lost+found目录的文件通常是未链接的文件(名字以及被删除),这些文件还被一些进程使用(数据没有删除),在系统突然关机时(内核panic或突然断电)出现。这些文件系统会删除的,你不需要担心。当因为软件或硬件出现错误,导致文件系统不一致,也有可能把有问题的文件放入到lost+found目录。它提供了恢复丢失文件的一种方法。
If you accidentally delete the Lost+found directory without using the mkdir command to create the Lost+found directory, you should use the Mklost+found command to create the Lost+found directory:
$ cd /$ sudo mklost+found
3. CentOS Time Synchronization
crontab -e0 1 * * * /usr/sbin/ntpdate asia.pool.ntp.org
4. New Disk Mount
mkfs.xfs /dev/vdbmkdir -p /wwwecho "/dev/vdb /www xfs defaults 0 0" >> /etc/fstabmount -a
5. mysql Port forwarding
#mysql数据库端口转发########################以下在rinetd服务机器操作##########################添加rinetd配置 echo "0.0.0.0 3307 172.26.82.95 3306" >> /etc/rinetd.conf#重启服务ps -ef|grep rinetdkill -9 ${rinetd_pid}rinetd#添加iptables规则vim /etc/sysconfig/iptables-A INPUT -s 111.200.218.67/32 -p tcp -m state --state NEW -m tcp --dport 3307 -j ACCEPT#重启iptablessystemctl restart iptables#查看规则iptables -L#在本地用mysql工具连接测试成功。
6, the server prohibits root login and prohibit password login.
sed -i "s/PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config && service sshd restart &&grep PasswordAuthentication /etc/ssh/sshd_config
7, Vimdiff common operation
Open vertically:
vimdiff abc.txt abc-a.txt
Open horizontally:
vimdiff -o abc.txt abc-a.txt
]c means jumping to the next different place.
[C means jumping to the last different place
Toggle Window
ctrl + w + w 左右切换 或者上下切换
8, CENTOS7 installation iptables
##关闭firewall###停止firewall systemctl stop firewall.service#禁止firewall开机启动##systemctl disable firewall.service##安装iptables防火墙###安装iptables yum install iptables-services#编辑防火墙文件 vi /etc/sysconfig/iptables 添加80和3306端口 -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT#重启防火墙使配置文件生效 systemctl restart iptables.service#设置iptables防火墙为开机启动项 systemctl enable iptables.service###关闭SELINUX###vi /etc/selinux/config #注释以下配置 SELINUX=enforcing SELINUXTYPE=targeted#增加以下配置SELINUX=disabled#使配置立即生效 setenforce 0
9, Judge a network segment online IP
for i in {1..254};do ping -q -i 0.01 -c 3 192.168.15.$i &> /dev/null && echo 192.168.16.$i is alive; done
10, zabbix3.0.14 detection in the Graphic text display box
原因很简单,图形显示用的字体是dejavu,不支持中文。怎么办?先理清逻辑。zabbix配置文件(/usr/share/zabbix/include/defines.inc.php)里,定义的字体叫做graphfont.ttf,然后一路软链接到DejaVuSans.ttf,如下:/usr/share/zabbix/graphfont.ttf -> /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf那么,修改掉最后一层软连接的目标字体就可以了。执行类似下面的命令就可以了。yum install google-noto-sans-simplified-chinese-fonts.noarch -ymv /etc/alternatives/zabbix-web-font /etc/alternatives/zabbix-web-font_bak ln -s /usr/share/fonts/google-noto/NotoSansSC-Regular.otf /etc/alternatives/zabbix-web-font
Linux common knowledge and fault handling