官网下载地址: https://wiki.centos.org/Download 找到 i386 Everything (ISO), Minimal (ISO), NetInstall (ISO) 选择 阿里云镜像 下载 http://mirrors.aliyun.com/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso
安装过程(以及之后运行中)只要操做鼠标就会弹出警告提示: 前面一大堆英文( 意思就是 : 是否 Capture ?) 注意记住切换提示: The host key is currently defined as Left ⌘.
老是会有 2 个鼠标箭头 若是其中实际有效的鼠标老是到不了顶部的 “Done”,说明图形化支持很差!须要重启服务器! 切记: Ubuntu Server上安装好 VisualBox 以后,必定要至少重启一次! CentOS 7 不分服务器版和桌面版! 在安装过程当中,会出现一个图形界面,用于设置时间、语言、安装目标磁盘、安装类型... *** 安装类型:缺省时最小化安装!固然就是服务器版了!
** 后续修改 ip 地址方式也是同样 ip a 看到个人网卡名字:enp0s3 ,可是没有分配 ip 虚拟机 : Network —Network setting —Bridget adapter 桥接方式也没有 ip地址! 若是不是 root 登陆,先 su 切换到 root cd /etc/sysconfig/network-scripts sudo vim ifcfg-enp0s3 到最后一行,修改成YES ONBOOT=YES 重启网卡服务 systemctl restart network.service ip a 返回结果: 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:63:e6:f5 brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.1.255 scope global noprefixroute dynamic enp0s3 valid_lft 3253sec preferred_lft 3253sec inet6 fe80::ba3f:1d96:dc67:fbf3/64 scope link noprefixroute valid_lft forever preferred_lft forever 操做到这里就能够离开虚拟机 ,直接以 root 用户身份 ssh 登陆! 能够先确认一下 sshd 是否安装、运行 ps -ef |grep sshd 如今能够 ssh 到这个 dhcp 分配的地址去远程操做了! ssh root@192.168.1.100 在 Ubuntu Server 下没有安装 dhcp 服务,因此,我仍是直接设置了静态地址 BOOTPROTO=static IPADDR=192.168.0.184 NETMASk="255.255.255.0" GATEWAY=192.168.0.1 DNS1=223.5.5.5 再次重启网卡服务 sudo systemctl restart network.service 这时候 ssh 连接可能就死在那里了,从新打开一个 ssh 终端 不放心的话, sudo reboot ssh root@192.168.1.184
1)、yum install vim 虽然我没有要求 update ,可是仍是看到他安装了一大堆东西 摘录一部分以下 ...... 正在安装: vim-enhanced x86_64 2:7.4.160-5.el7 base 1.0 M 为依赖而安装: gpm-libs x86_64 1.20.7-5.el7 base 32 k perl x86_64 4:5.16.3-293.el7 base 8.0 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Encode x86_64 2.51-7.el7 base 1.5 M ...... 主要是一大堆依赖所需的工具,大部分都是 perlXXX 2)、yum install wget 3)、如今使用的 root ssh 登陆,为了后续安全操做,先加入 dhbm 到 sudoer vi /etc/sudoers 找到而且按照这行增长一行 dhbm root ALL=(ALL) ALL dhbm ALL=(ALL) ALL 操做到这里就能够 exit ,从新以 dhbm 用户身份 ssh 登陆!
1)、参考 https://blog.csdn.net/Pipcie/article/details/80005006 2)、查看目前 源 列表 yum repolist 返回结果: 已加载插件:fastestmirror Determining fastest mirrors * base: mirrors.163.com * extras: mirrors.cn99.com * updates: mirrors.163.com base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/4): extras/7/x86_64/primary_db | 156 kB 00:00 (2/4): base/7/x86_64/group_gz | 166 kB 00:00 (3/4): base/7/x86_64/primary_db | 6.0 MB 00:03 (4/4): updates/7/x86_64/primary_db | 1.3 MB 00:03 源标识 源名称 状态 base/7/x86_64 CentOS-7 - Base 10,019 extras/7/x86_64 CentOS-7 - Extras 321 updates/7/x86_64 CentOS-7 - Updates 599 repolist: 10,939 3)、下载、加载 阿里云镜像源 sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo sudo yum clean all sudo yum makecache *** 若是发生:"Failed connect to mirrors.aliyuncs.com:80; 拒绝链接" *** 以上 3 条指令都要 sudo ,从新来过 再次查看 yum repolist 返回结果: 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 源标识 源名称 状态 base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 321 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 599 repolist: 10,939 4)、添加第三方EPEL源 (仍是选 阿里云) sudo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo sudo yum clean all sudo yum makecache 再次查看 yum repolist 返回结果: 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 源标识 源名称 状态 base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 12,746 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 321 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 599 repolist: 23,685 ** 注意:多出来一个epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64
sudo vim /etc/ssh/sshd_config 找到 PermitRootLogin 去掉这行的注释 # yes更改成no 从新加载 sshd 服务 sudo systemctl restart sshd 再次尝试 root ssh 远程登陆 ssh root@192.168.1.100 root@192.168.1.100's password: Permission denied, please try again. root@192.168.1.100's password:
yum install vim 时出现 Cannot find a valid baseurl for repo: base/7/x86_6 ping www.baidu.com 不通 参考: https://www.cnblogs.com/dadadechengzi/p/6670530.html 使用 nmcli 从新设置 DNS 地址 nmcli connection show nmcli con mod enp0s3 ipv4.dns "114.114.114.114" nmcli con up enp0s3 ping www.baidu.com 能够了! 先安装一下简单工具 yum install vim yum install wget
参考: https://blog.csdn.net/xuheng8600/article/details/79983927 查看当前的主机名称 (3 种名称!不知道都有什么做用?) hostnamectl --static hostnamectl --transient hostnamectl --pretty 重设主机名称 sudo hostnamectl set-hostname centos7-77 sudo hostnamectl set-hostname centos7-77 sudo hostnamectl set-hostname centos7-77 --pretty 修改 hosts sudo vim /etc/hosts # 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 # ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 centos7-77 ::1 centos7-77 替换::%s/77/71/g 直接查看名称已经改变 sudo reboot 才能看到显示改变了? 疑问:127.0.0.1 localhost... 须要注释掉吗?会不会不认识 localhost?待处理
命令是 timedatectlhtml
timedatectl --helplinux
查看当前时区 ** 直接 timedatectl ,没有 timedatectl get-timezone 命令vim
timedatectl 返回结果以下:centos
Local time: 五 2019-04-05 21:21:56 EDT Universal time: 六 2019-04-06 01:21:56 UTC RTC time: 六 2019-04-06 01:21:55 Time zone: America/New_York (EDT, -0400) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at 日 2019-03-10 01:59:59 EST 日 2019-03-10 03:00:00 EDT Next DST change: DST ends (the clock jumps one hour backwards) at 日 2019-11-03 01:59:59 EDT 日 2019-11-03 01:00:00 EST
timedatectl list-timezones |grep Asia 找到 Asia/Shanghai安全
timedatectl set-timezone "Asia/Shanghai" ** 若是提示错误:Failed to set time zone: Invalid time zone '“Asia/Shanghai”',去掉引号!bash
timedatectl set-timezone Asia/Shanghai服务器
验证一下 date 2019年 04月 06日 星期六 09:24:54 CSTdom
和本地时间对上了!ssh
查看版本信息位置 ll /etc/centos -rw-r--r--. 1 root root 38 11月 23 21:16 /etc/centos-release -rw-r--r--. 1 root root 51 11月 23 21:16 /etc/centos-release-upstreamtcp
查看版本信息 cat /etc/centos-release CentOS Linux release 7.6.1810 (Core)
查看内核版本 uname -r 3.10.0-957.el7.x86_64
查看 64位 仍是 32 位 getconf LONG_BIT 64
查看 SELinux sestatus SELinux status: disabled getenforce Disabled
临时关闭 setenforce 0
永久关闭 sudo vim /etc/selinux/config # by wzh 20190329 disable SELINUX SELINUX=disabled # SELINUX=enforcing
重启才能生效!
查看 SELinux sestatus SELinux status: disabled
参考 http://www.javashuo.com/article/p-ymojgcau-kt.html cp -a /etc/skel/. /home/登陆名
个人登陆帐户是 dhbm,因此
cp -a /etc/skel/. /home/dhbm 退出后,从新打开一个 Terminal,再进来就 ok!
查看防火墙状态 sudo systemctl status firewalld
sudo firewall-cmd --state running
防火墙基本命令 # 开启 service firewalld start # 重启 service firewalld restart # 关闭 sudo service firewalld stop # 查看防火墙规则 sudo firewall-cmd --list-all sudo firewall-cmd --state
开启 8080 端口 sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
重启防火墙 sudo systemctl restart firewalld.service
sudo firewall-cmd --reload
不知道为何,就把本身关在外面了 ssh 链接不上去了! sudo firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: enp0s3 sources: services: ssh dhcpv6-client ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
** 能够看到,ports 一个都没有!
** 干脆从新增长端口的时候,先加上 20,22 端口
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent sudo firewall-cmd --zone=public --add-port=22/tcp --permanent sudo firewall-cmd --zone=public --add-port=21/tcp --permanent sudo firewall-cmd --zone=public --add-port=20/tcp --permanent sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent sudo firewall-cmd --zone=public --add-port=4433/tcp --permanent
重启防火墙 sudo systemctl restart firewalld.service 从新查看防火墙规则 sudo firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: enp0s3 sources: services: ssh dhcpv6-client ports: 80/tcp 22/tcp 21/tcp 20/tcp 8080/tcp 4433/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: ** 如今能够安全的退出、从新 ssh 了