监控服务器性能的:
https://www.cnblogs.com/zy-plan/p/8617202.html

系统信息:
uname -a
more /etc/*release

CPU:
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
cat /proc/cpuinfo
getconf LONG_BIT 
cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

系统环境:
env
uptime

内存:
cat /proc/meminfo
free -m

硬盘:
df -h 
du -sh /root
fdisk -l 
swapon -s

网卡: 
ethtool ens192
route -n
lsof -i:22

进程:
ps -ef 
ps -aux
top
cat /proc/loadavg
除了前3个数字表示平均进程数量外,后面的1个分数,分母表示系统进程总数,分子表示正在运行的进程数;
最后一个数字表示最近运行的进程ID

用户:
w
id root

查看用户登录日志:
last 
查看系统所有用户:
cut -d: -f1 /etc/passwd



查看那个进程占用了xxx端口
lsof -i:xxx
查看进程号为xxx的进程在哪里
ps -ef|grep xxx

ps -aux

然后用kill杀掉

kill 3268

kill -9 $(ps -ef | grep peidalinux)

同步时间:

vi /etc/crontab

0 */60 * * * root hwclock --hctosys

0 */2 * * * root ntpdate us.pool.ntp.org;hwclock -w


%%%%%%%%%%%%%%%%%

DNS:

CentOS配置DNS:
vi  /etc/sysconfig/network-scripts

DNS1=202.96.209.5

重启网卡,然后在 /etc/resolv.conf就有了


DNS 解析:
vi /etc/host.conf 
 order hosts,bind
 multi on
vi /etc/hosts
 1.1.1.1 gate.devin.com gate
vi /etc/resolv.conf
 nameserver 202.96.20.5
 search localdomain

重新启动service的另外方法:
/etc/rc.d/init.d/network restart 


对于 ubuntu dns 的18.04后:

https://blog.csdn.net/orDream/article/details/89021118

dns-nameservers 202.38.64.1

%%%%%%%%%%%%%%%%%%%


VSFTPD:

yum install vsftpd

---

vi /etc/vsftpd/vsftpd.conf

groupadd test
  mkdir /tmp/test
useradd -G test –d /tmp/test –M usr1

passwd usr1

--

chmod 777 /tmp/

service vsftpd start


setenforce 0

service iptables stop

----------------------------------------------------------------------------------

./config 在配置时出现错误,是可以再解决问题后在重新配置的


编辑文件的方法:
nano /var/www/html/info.php
vi /var/www/html/info.php

rm -rf /var/spool/mail/用户名

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
系统安装前准备:
# more /var/log/messages    //检查有无系统级错误信息,没有系统error
           # dmesg     //检查硬件设备是否有错误信息,没看到error
           # ifconfig    //检查网卡设置是否正确,有ip即可
           # ntsysv     //关闭不需要的服务,<空格>选择,设置完成后重启系统
           # crontab –e
           加入:
                 */5 1 * * * ntpdate 210.72.145.44 > /dev/null 2>&1                  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
linux rpm 查找:
http://www.filewatcher.com/m/rrdtool-1.2.27-3.el5.i386.rpm.475404-0.html
http://rpm.pbone.net/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yum独立源的建立已经查找:
http://zhumeng8337797.blog.163.com/blog/static/100768914201182785336268/
搜索关键字: vi /etc/yum.repos.d/Dag.repo###定义第三方源

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
设置时间time clock:
http://www.t086.com/article/4386
 修改/etc/sysconfig/clock文件的内容为:
 修改/etc/sysconfig/clock文件的内容为:
 ZONE=”Asia/Shanghai”
 UTC=false
 ARC=false
date -s "2008-08-08 12:00:00"


Under Centos 7:
reference BY: 

https://blog.csdn.net/zeroking_vip/article/details/85317831

yum -y install ntp ntpdate
ntpdate cn.pool.ntp.org

hwclock --systohc

hwclock -w


**************************

复制命令

Copy 命令

cp –ar test/ newtest

但是在cp时没有进度条 非常麻烦,可以利用gcp的方法:

https://linux.cn/thread/11868/1/1/

gcp -rv ./ ./ 

装gcp的命令的方法:

https://www.cnblogs.com/dakewei/p/7500503.html

sudo apt-get install gcp -y

yum -y install gcp

***********************


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

查找命令:
updatedb
find / -name snmp

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
快速启动命令:
service nagios restart && service httpd restart && service snmpd restart

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
linux常用rpm zip包下载:
http://rpm.pbone.net/
http://mirrors.163.com/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
查询OS:
cat /etc/issue
uname -a

日志信息:
/var/log
/etc/syslog.conf

查询设备信息:
dmesg
lspci
dmesg

设备模块信息:
modinfo bnx2
lsmod | grep bonding
http://www.cnblogs.com/mydomain/archive/2013/04/16/3023323.html
在centos 6.3中没有了modprobe.conf 和 modules.conf文件取代的是在/etc/modprobe.d/dist.conf
echo 0 > /sys/class/net/bond0/bonding/mode

rpm包安装卸载:
rpm -ivh lifekeeper
rpm -e lifekeeper

安装软件后,有对应的模块可以查看:
lsmod | grep lifekeeper

卸载模块和对应的依存模块:
rmmod bnx2
rmmod bnx2x

从新加载模块:
insmod bnx2
有些是:modprobe bnx2x
具体的案例:
http://www.cnblogs.com/mydomain/archive/2013/04/16/3023323.html
modprobe -r vmxnet (去除模块)
modprobe mybridge
service network restart

查看软件安装的目录:
rpm -ql lifekeeper
fcitx 安装到 /opt/fcitx

查看安装软件注册的服务:
chkconfig --list | grep lifekeeper | more
ps -aux | grep lifekeeper
Service NetworkManager stop
Chkconfig NetowrkManager off
chkconfig --level 235 httpd on

查看软件对应的模块:
lsmod | gerep lifekeeper

查询设备比如网卡的状态:
mii-tool eth0


 
安装桌面环境:
yum groupinstall -y   "Desktop"   "Desktop Platform"   "Desktop Platform Development"  "Fonts"  "General Purpose Desktop"  "Graphical Administration Tools"  "Graphics Creation Tools"  "Input Methods"  "X Window System"  "Chinese Support [zh]" "Internet Browser"

网卡通过DHCP获取IP:
dhclient eth0

升级系统:
yum -y upgrade
yum卸载命令:
yum -y remove sendmail

yum search php-

查看进程是否存在:
ps -ef | grep LifeKeeper
netstat -ano | grep 5901

netstat -apn | grep tcp


格式化硬盘:
首先是我们的能查看到这个硬盘通过fdisk -l 命令 和 df   -h
df -hl

然后通过mkfs.ext3 /dev/sdb1
最后挂在 mount -t ext3 /data
分区命令:
fdisk /dev/hdb

查看当前文件夹大小
du -sh
du -h

Liunx中启动脚本放置:
vi /etc/fstab
vi /etc/fc.local
vi /etc/inittab
echo '/etc/init.d/zabbix_agentd_ctl start &' >>/etc/rc.local
创建快键方式

#ln -s /etc/init.d/zabbix_server_ctl /usr/bin/zabbix_server_ctl
启动Server和Agentd(可以通过start stop restart操作)
#zabbix_agentd_ctl start
#zabbix_server_ctl start


查询CentOs的版本:
lsb_release -a
uanme -a
cat /etc/issue
lsb_release -a


system-config-network

进程检查:
ps -ef | grep
lsof -i | grep rpc

查询网卡速率:
ethtool eth0

Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –help输出详细的选项列表。

其中--prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share,比较凌乱

修改hostname:
vi /etc/sysconfig/network
init 6

Centos 7 以后: 

hostnamectl set-hostname centos7 


Host 连接:
vi /etc/hosts.allow

SQL service:
service mysqld start

shell> mysqladmin -u root password "newpwd"
mysqladmin -u用户名 -p旧密码 password 新密码


解压命令:
tar -jxvf msmtp-1.4.31.tar.bz2

关闭selinux:
setenforce 0
vi /etc/selinux/config(也有人说是/etc/sysconfig/selinux文件,其实两个之间是链接关系,随便改其中一个,另一个也改了)
SELINUX=disable 禁用SeLinux
SELINUX=enforcing 启用SeLinux

将用户加入组:
useradd -g lingdao lingdao

linux下的service的目录:
cd /etc/init.d/

zabbix 删除客户端的服务:
zabbix_agentd.exe -d

配置Linux LAMP环境:
https://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-centos-6.2-lamp
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7


查询服务的状态:
lostat :10051



##################################

CentOS 自动更新服务

https://jingyan.baidu.com/article/455a99504c9588a166277897.html

yum update -y

yum install yum-cron -y

vi  /etc/yum/yum-cron.conf 

     update_cmd = security

     update_messages = yes

     download_updates = yes

     apply_updates = yes


systemctl start yum-cron

systemctl enable yum-cron



##############################

logging message: 

journalctl -u ssh.service


#################################

to debug:

/usr/sbin/sshd -d


######2019-11-22 SMB Mount ####

挂载windows 或是 QNAP NAS上的share folder:

可以参考: https://blog.csdn.net/u012561510/article/details/77204180

但是正确的方式:

mount -t cifs -o vers=2.0,user=cindyxiao,password=XXXXX //172.30.142.19/ /mnt/smb/

以前没有成功的原因去查看了对应的日志:

tail -100 /var/log/message 

CIFS VFS: Dialect not supported by server. Consider specifying vers=1.0 or vers=2.0 on mount for accessing older servers

所以添加上 vers=2.0 就可以了,意思是默认centos去挂载时用的smb2.1以上的版本,但是 NAS上确实用的2.0,版本不统一造成错误。

smbclient -L //172.30.142.19 -U cindyzhang

##########################


https://www.cnblogs.com/yunweis/p/8021584.html

fdisk -l

 fdisk /dev/sdb

mkfs.ext4 /dev/sdb1

mkdir /data

mount /dev/sdb1 /data 


echo "/dev/sdb1 /data ext4 defaults 0 0" >> /etc/fstab

df -h 

查看


############### Centos Apache PHP Mysql or mariadb ##########

[root@localhost ~]# yum -y install httpd

Loaded plugins: fastestmirror, langpacks

Existing lock /var/run/yum.pid: another copy is running as pid 17034.

Another app is currently holding the yum lock; waiting for it to exit...

  The other application is: PackageKit

    Memory : 178 M RSS (521 MB VSZ)

    Started: Tue Mar 31 10:13:25 2020 - 55:00 ago

    State  : Sleeping, pid: 17034

Another app is currently holding the yum lock; waiting for it to exit...

  The other application is: PackageKit

    Memory : 178 M RSS (521 MB VSZ)

    Started: Tue Mar 31 10:13:25 2020 - 55:02 ago

    State  : Sleeping, pid: 17034



kill -s 9 17034

ps aux | grep yum 


rm -f /var/run/yum.pid

%%%%% Https Apache Parts: %%%%%%


PHP Apahce Mysql centos 7:

https://blog.csdn.net/baibaigao/article/details/89406201


 yum -y install httpd

systemctl start httpd

systemctl stop firewalld

touch /var/www/html/index.html

vim /var/www/html/index.html

systemctl restart httpd


%%%%%%%%%%%%%% PHP Parts: %%%%%%%%%%

yum -y install php

mv index.html index.php

php phpinfo(); 

?>

systemctl restart httpd

%%%%%%%%%%%%% Mysql Parts: %%%%%%%%%

yum list installed | grep mysql

yum -y remove mysql-libs.x86_64

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

yum -y localinstall mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

systemctl start mysql

systemctl status mysql


mysql 

use  mysql;

update user set host ='%' where user ='root';

update user set password=password('Cctv1234') where user='root' and host=‘*’;

flush privileges;



hostnamectl set-hostname webtest86 

systemctl enable httpd

systemctl enable mysqld

systemctl disable firewalld