Advanced linux command

Linux can not access the Internet troubleshooting process

1. Check if you can access the Internet

 ping.baidu.com

2. Verify whether DNS domain name resolution domain name ------------ "ip address

   ping 223.5.5.5

3. Gateway - Verify that your network configuration (NIC virtual machine vmwarexxx) is not a problem

  [root@bigdata ~]# ping 10.0.0.2
  PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
  64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=0.206 ms
  64 bytes from 10.0.0.2: icmp_seq=2 ttl=128 time=0.170 ms

  --- 10.0.0.2 ping statistics ---
  2 packets transmitted, 2 received, 0% packet loss, time 1000ms
  rtt min/avg/max/mdev = 0.170/0.188/0.206/0.018 ms

 

Use CentOS7.4 CD image

 

 

 

put the disc in the drive

Check that the CD is inserted into the CD-ROM drive

 

1. Insert the CD into the system

2. Use CD-ROM in Linux

[root@oldboyedu-s8 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@oldboyedu-s8 ~]# #mount 给/dev/cdrom 创建一个入口 /mnt 
[root@oldboyedu-s8 ~]# cd /mnt/
[root@oldboyedu-s8 mnt]# ls -l
total 664
-rw-rw-r--. 3 root root 14 Sep 5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Sep 5 2017 EFI
-rw-rw-r--. 3 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 3 root root 18009 Dec 10 2015 GPL
drwxr-xr-x. 3 root root 2048 Sep 5 2017 images
drwxr-xr-x. 2 root root 2048 Sep 5 2017 isolinux
drwxr-xr-x. 2 root root 2048 Sep 5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 Sep 5 2017 Packages
drwxr-xr-x. 2 root root 4096 Sep 5 2017 repodata
-rw-rw-r--. 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Sep 6 2017 TRANS.TBL

 

================ yum source =======================

yum install from CD

yum install

Compile and install trilogy

./configure       make       make  install

add yum source

1、https://mirrors.aliyum.com/

go to this site

Add common yum sources:
epel source
yum install wget -y
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum repolist
yum install sl cowsay -y

 

The difference between installing software under linux

Install the software manually

 

Check if the prompt software is installed

[root @ oldboyedu-s8 ~] # rpm -qa bash-completion
bash-completion-2.1-6.el7.noarch

 

firewall

 

 

#Query firewall status
systemctl status firewalld.service

#Currently running firewall---temporary
systemctl stop firewalld.service

#让防火墙不会开机自启动 --- 永久
systemctl disable firewalld.service

#systemctl is-active firewalld.service
#is-active 是否正在运行 是否健在
#systemctl is-enabled firewalld.service
#is-enabled 是否开机自启动
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]# systemctl is-active firewalld.service
unknown
[root@oldboyedu-s8 ~]# systemctl is-active crond.service
active
[root@oldboyedu-s8 ~]# systemctl is-enabled firewalld.service
disabled


[root@oldboyedu-s8 ~]# systemctl start firewalld.service    #启动防火墙
[root@oldboyedu-s8 ~]# systemctl is-active firewalld.service
active
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]# systemctl enable firewalld.service
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
[root@oldboyedu-s8 ~]# systemctl is-enabled firewalld.service
enabled

 

crond定时任务

检查crond状态
[root@oldboyedu-s8 ~]# rpm -qa cronie
cronie-1.4.11-17.el7.x86_64
[root@oldboyedu-s8 ~]# systemctl is-active crond.service
active
[root@oldboyedu-s8 ~]# systemctl is-enabled crond.service
enabled

#定时任务管理命令
[root@oldboyedu-s8 ~]# crontab -l
no crontab for root

[root@oldboyedu-s8 ~]# crontab -e
#oldboyedu.com

#-e edit
#-l list

 

 

定时任务格式


每天的早上8:30到学校上车(go to school)
30 08 * * * go to school

每天的晚上12点整回家自己开车(go to bed)
00 00 * * * go to bed


如何修改系统时间
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:13:53 CST 2018
[root@oldboyedu-s8 ~]# date -s "20180101 01:01:01"
Mon Jan 1 01:01:01 CST 2018
[root@oldboyedu-s8 ~]# date
Mon Jan 1 01:01:05 CST 2018

 

让系统自动同步时间
yum install ntpdate -y         #ntpdate 更新时间
[root@oldboyedu-s8 ~]# ntpdate ntp1.aliyun.com        #用ntpdate连接阿里云
26 Apr 12:19:53 ntpdate[18819]: step time server 182.92.12.11 offset 9976502.795919 sec
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:20:24 CST 2018


#显示命令的绝对路径
[root@oldboyedu-s8 ~]# which ntpdate
/usr/sbin/ntpdate
[root@oldboyedu-s8 ~]# find / -type f -name "ntpdate"
/etc/sysconfig/ntpdate
/usr/sbin/ntpdate

 

每2分钟同步一次系统时间

###1.命令行测试
[root@oldboyedu-s8 ~]# /usr/sbin/ntpdate ntp1.aliyun.com
26 Apr 12:28:11 ntpdate[19018]: adjust time server 182.92.12.11 offset 0.000723 sec

###2.命令写入定时任务
[root@oldboyedu-s8 ~]# crontab -l
#sync time
*/2 * * * * /usr/sbin/ntpdate ntp1.aliyun.com

###3.进行检查与测试
[root@oldboyedu-s8 ~]# date -s "20190101"
Tue Jan 1 00:00:00 CST 2019
[root@oldboyedu-s8 ~]# date
Tue Jan 1 00:00:01 CST 2019
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:31:25 CST 2018

 

部署nginx

1#下载nginx 

wget http://nginx.org/download/nginx-1.12.2.tar.gz

yum install pcre-devel openssl-devel -y    #pcre-devel 正则的扩展   openssl-devel  https的扩展

#编译安装三部曲 : ./configure    make     make install

tar xf nginx-1.12.2.tar.gz
cd nginx-1.12.2

./configure --prefix=/application/nginx-1.12.2 --with-http_stub_status_module --with-http_ssl_module   

解释:

  /configure --prefix=/application/nginx-1.12.2    #安装路径

   #with-http_stub_status_module --  模块状态  添加监控状态配置

   #with-http_ssl_module          #网站如果用https的话必须把这个写上,加密的
make               #编译
make install      #安装

故障1:
error: the HTTP rewrite module requires the PCRE library.
yum install pcre-devel -y


[root@oldboyedu-s8 nginx-1.12.2]# ll /application/nginx-1.12.2/
total 4
drwxr-xr-x. 2 root root 4096 Apr 26 15:55 conf #configure nginx配置文件
drwxr-xr-x. 2 root root 40 Apr 26 15:55 html #站点目录 网站根目录
drwxr-xr-x. 2 root root 6 Apr 26 15:55 logs #日志
drwxr-xr-x. 2 root root 19 Apr 26 15:55 sbin #nginx管理命令

 

 

#检查语法
/application/nginx-1.12.2/sbin/nginx -t

#启动nginx
/application/nginx-1.12.2/sbin/nginx

 

#重启nginx
/application/nginx-1.12.2/sbin/nginx -s reload

 

 

#nginx配置说明

nginx.conf #nginx配置文件
nginx.conf.default #

#对比两个文件区别
diff conf/nginx.conf conf/nginx.conf.default

egrep -v "#|^$" /application/nginx-1.12.2/conf/nginx.conf.default >/application/nginx-1.12.2/conf/nginx.conf


1 worker_processes 1;
2 events {
3 worker_connections 1024;
4 }
5 http {
6 include mime.types; #媒体类型
7 default_type application/octet-stream;
8 sendfile on; #开启高效的传输模式
9 keepalive_timeout 65; #超时时间
10 server { #一个server相当于是一个网站 虚拟主机
11 listen 80; #监听的端口
12 server_name www.etiantian.org; #网站名字 域名
13 location / {
14 root html; #根 站点的根目录
15 index index.html index.htm; #首页文件
16 }
21 }
22 }

 

娱乐一下

 

下载上图的东西,下图就开始娱乐

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324894792&siteId=291194637