Linux 筆記

目的(前言?)

2016年7月畢業到如今,特不順利,老是半途而廢,損失不少時間和金錢。清單數量上二百了,障礙了。(請原諒我寫做水平,但我還在努力。)javascript

書名:跟老男孩學Linux運維 Shell編程實戰

1.書的難點

2.軟件上解決的筆記

2-1.個人本本 個人臺式 服務器所需的準備

VMware Workstations 15 Pro

難點:對vmware網絡模式沒弄懂。
想法:看下來自亦是美網絡,橋接設置。
clipboard.pnghtml

clipboard.png

clipboard.png

遠程工具:SecureCRT、Xshell、Putty(沒用過)

SecureCRT設置

clipboard.png

clipboard.png

clipboard.png

clipboard.png

3.整理舊筆記

3-1.yum mysql

[20:10:58][root@#localhost ~]# rpm -qa|grep mariadb
[20:10:59]mariadb-libs-5.5.52-1.el7.x86_64 #查找,刪掉
[20:11:07][root@#localhost ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
[20:11:19][root@#localhost ~]# rpm -qa|grep mysql
[20:14:32][root@#localhost ~]# mkdir /data
[20:22:32][root@#localhost ~]# wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
[20:23:15][root@#localhost ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm 
[20:24:13][root@#localhost ~]# yum install mysql-server -y  
  
[20:29:12][root@#localhost ~]# cat /etc/my.cnf #默認
[20:29:12]# For advice on how to change settings please see
[20:29:12]# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[20:29:12]
[20:29:12][mysqld]
[20:29:12]#
[20:29:12]# Remove leading # and set to the amount of RAM for the most important data
[20:29:12]# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
[20:29:12]# innodb_buffer_pool_size = 128M
[20:29:12]#
[20:29:12]# Remove leading # to turn on a very important data integrity option: logging
[20:29:12]# changes to the binary log between backups.
[20:29:12]# log_bin
[20:29:12]#
[20:29:12]# Remove leading # to set options mainly useful for reporting servers.
[20:29:12]# The server defaults are faster for transactions and fast SELECTs.
[20:29:12]# Adjust sizes as needed, experiment to find the optimal values.
[20:29:12]# join_buffer_size = 128M
[20:29:12]# sort_buffer_size = 2M
[20:29:12]# read_rnd_buffer_size = 2M
[20:29:12]datadir=/var/lib/mysql
[20:29:12]socket=/var/lib/mysql/mysql.sock
[20:29:12]
[20:29:12]# Disabling symbolic-links is recommended to prevent assorted security risks
[20:29:12]symbolic-links=0
[20:29:12]
[20:29:12]log-error=/var/log/mysqld.log
[20:29:12]pid-file=/var/run/mysqld/mysqld.pid

[20:30:41][root@#localhost ~]# service mysqld status #記法:系統在前,服務在後。systemctl status xxx service xxx status

[20:30:52][root@#localhost ~]# service mysqld start
[20:31:23][root@#localhost ~]# grep "password" /var/log/mysqld.log
[20:31:23]2019-03-21T12:31:07.638261Z 1 [Note] A temporary password is generated for root@localhost: QChl.QsN9IrY
[20:31:40][root@#localhost ~]# mysql -uroot -p
[20:32:09]Enter password: 
[20:32:57]mysql> alter user 'root'@'localhost' identified by 'you_password'; #字母大小寫,數字,符號都要!也能夠設置取消複雜要求。
[20:33:13]mysql> quit;
[20:33:30][root@#localhost ~]# service mysqld restart
[20:33:58][root@#localhost ~]# mysql -uroot -p       
[20:34:04]Enter password: 
[20:34:04]Welcome to the MySQL monitor.  Commands end with ; or \g.
[20:34:04]Your MySQL connection id is 2
[20:34:04]Server version: 5.7.25 MySQL Community Server (GPL)
[20:34:04]
[20:34:04]Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
[20:34:04]
[20:34:04]Oracle is a registered trademark of Oracle Corporation and/or its
[20:34:04]affiliates. Other names may be trademarks of their respective
[20:34:04]owners.
[20:34:04]
[20:34:04]Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
[20:34:04]
[20:34:12]mysql> show databases;
[20:34:12]+--------------------+
[20:34:12]| Database           |
[20:34:12]+--------------------+
[20:34:12]| information_schema |
[20:34:12]| mysql              |
[20:34:12]| performance_schema |
[20:34:12]| sys                |
[20:34:12]+--------------------+
[20:34:12]4 rows in set (0.00 sec)
[20:34:12]
[20:34:18]mysql> quit;
[20:34:18]Bye  #注意:上面標點符號不許,csdn保存後,符號有變化!!!

3-2.rm -rf /var/run/yum.pid

[15:04:08][root@localhost ~]# yum install gcc gcc-c++ kernel-devel ncurses-devel bison cmake
[15:04:08]Loaded plugins: fastestmirror, langpacks
[15:04:08]Existing lock /var/run/yum.pid: another copy is running as pid 4258.
[15:04:08]Another app is currently holding the yum lock; waiting for it to exit...
[15:04:08]  The other application is: PackageKit
[15:04:08]    Memory : 197 M RSS (1.5 GB VSZ)
[15:04:08]    Started: Thu Mar 21 14:54:14 2019 - 09:55 ago
[15:04:08]    State  : Sleeping, pid: 4258
[15:04:10]Another app is currently holding the yum lock; waiting for it to exit...
[15:04:10]  The other application is: PackageKit
[15:04:10]    Memory : 197 M RSS (1.5 GB VSZ)
[15:04:10]    Started: Thu Mar 21 14:54:14 2019 - 09:57 ago
[15:04:10]    State  : Sleeping, pid: 4258
[15:04:11]^C
[15:04:11]Exiting on user cancel.
[15:05:01][root@localhost ~]# rm -rf /var/run/yum.pid 
[15:05:02][root@localhost ~]# yum install gcc gcc-c++ kernel-devel ncurses-devel bison cmake

3-3.vim hostname

[10:50:49][root@localhost ~]# hostname
[10:50:49]localhost.localdomain
[10:50:57][root@localhost ~]# cat /etc/hostname
[10:50:57]localhost.localdomain
[10:51:13][root@localhost ~]# vi /etc/hostname
[10:51:52][root@localhost ~]# cat /etc/hostname
[10:51:52]localhost
[10:51:52][root@localhost ~]# reboot

疑問:
[root@bogon ~],這也許是默認,但裝系統的時候,輸入hostname後,結果仍是bogon,一直計劃再裝一次,仍是沒裝上,就是除了默認和不輸入bogon,再試試。java

3-4.selinux

[10:52:40][root@localhost ~]# vi /etc/selinux/config
[11:05:25][root@localhost ~]# cat /etc/selinux/config
[11:05:25]
[11:05:25]# This file controls the state of SELinux on the system.
[11:05:25]# SELINUX= can take one of these three values:
[11:05:25]#     enforcing - SELinux security policy is enforced. #安全策略被強制執行
[11:05:25]#     permissive - SELinux prints warnings instead of enforcing. #打印警告而不是強制執行
[11:05:25]#     disabled - No SELinux policy is loaded. #沒有加載SELinux策略
[11:05:25]SELINUX=disabled
[11:05:25]# SELINUXTYPE= can take one of three two values:
[11:05:25]#     targeted - Targeted processes are protected, #有針對性的過程受到保護
[11:05:25]#     minimum - Modification of targeted policy. Only selected processes are protected.  #目標政策的最小修改。只有選定的進程受到保護。
[11:05:25]#     mls - Multi Level Security protection. #多級安全保護。
[11:05:25]SELINUXTYPE=targeted 
[11:05:25]
[10:54:03][root@localhost ~]# reboot
[11:06:54][root@localhost ~]# /usr/sbin/sestatus   # 或者 sestatus
[11:06:54]SELinux status:                 disabled
[11:07:01][root@localhost ~]# getenforce  #
[11:07:01]Disabled

[15:46:31][root@localhost ~]# setenforce 0 | 1 # 1:啓用,Enforcing;0:關閉,Permissive。
[15:46:31]usage:  setenforce [ Enforcing | Permissive | 1 | 0 ] #

3-5.查看 CentOS 版本信息

[08:48:03][root@#localhost ~]# cat /etc/redhat-release 
[08:48:03]CentOS Linux release 7.3.1611 (Core)

4.重置root用戶密碼

查看Linux版本
[root@linuxprobe ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)node

rd.break方式更改root密碼mysql

重啓Linux系統主機並出現引導界面時,按下e鍵進入內核編輯界面。linux

輸入rd.break,位置就在fi下面,Ctrl+X。約30秒後,進入緊急求援模式。c++

mount -o remount,rw /sysroot
chroot /sysroot
passwd  # passwd root
touch /.autorelabel
exit
reboot

init方式修改root密碼sql

按下e鍵進入內核編輯界面shell

輸入init=/bin/sh,位置就在fi下面,Ctrl+X。編程

mount -o remount,rw /
passwd root
touch /.autorelabel
exec /sbin/init # exec/sbin/reboot
# exit ?
# reboot ?

CentOS 6.X

相關文章
相關標籤/搜索