运维笔记:购买vps服务器后,在Linux最初需要做的几件事
nanshan 2024-12-22 19:56 56 浏览 0 评论
本人系统为CentOS 8
可通过 命令 cat /etc/redhat-release 查看自己的系统版本
[root@EasygoingEssential-VM /]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
命令 uname -a 可以查看内核版本
[root@EasygoingEssential-VM /]# uname -a
Linux EasygoingEssential-VM 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
1:更改root原始密码
命令输入 passwd 用户名(不输用户名,表示当前用户),输入两遍密码
[root@EasygoingEssential-VM ~]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2: 安装bash-completion Tab补齐
按Tab建没法补齐命令,所以需要自己安装bash-completion
命令输入 yum -y install bash-completion
[root@EasygoingEssential-VM /]# yum -y install bash-completion
重新登录生效
3: 安装第三方源epel-release,和国内yum源
自己安装的是阿里yum源
1),备份原有源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2),下载阿里源
本人系统版本为CentOS-8,所以下载
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
如果其他版本如CentOS-7,则
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
显示如下:
[root@EasygoingEssential-VM ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
--2021-06-15 09:17:20-- https://mirrors.aliyun.com/repo/Centos-8.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 47.246.22.232, 47.246.22.233, 47.246.22.234, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|47.246.22.232|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2595 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
/etc/yum.repos.d/CentO 100%[===========================>] 2.53K --.-KB/s in 0s
2021-06-15 09:17:22 (15.1 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2595/2595]
最后清除系统所有的yum缓存
yum clean all
生成yum缓存
yum makecache
安装完成!!!!!1
如果没有wget 命令,会提示 -bash: wget: command not found
同样先安装 yum -y install wget即可;
3:安装epel-release
命令:
yum install -y epel-release
显示如下:
[root@EasygoingEssential-VM ~]# yum install -y epel-release
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - Base - mirrors.aliyun.com 897 kB/s | 2.6 MB 00:02
CentOS-8 - Extras - mirrors.aliyun.com 3.0 kB/s | 9.6 kB 00:03
....
....
Installed:
epel-release-8-8.el8.noarch
Complete!
[root@EasygoingEssential-VM ~]#
安装成功!!!
yum repolist enabled 可查看可用的yum源
yum repolist all 显示所有yum源
显示如下:
[root@EasygoingEssential-VM ~]# yum repolist enabled
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Last metadata expiration check: 0:00:18 ago on Tue 15 Jun 2021 09:36:37 AM EDT.
repo id repo name status
AppStream CentOS-8 - AppStream 5,289
base CentOS-8 - Base - mirrors.aliyun.com 1,744
*epel Extra Packages for Enterprise Linux 8 - x86_64 7,437
*epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64 0
extras CentOS-8 - Extras - mirrors.aliyun.com 34
4:更改ssh端口或者禁用root远程登陆
禁用root前,需要创建一个普通用户及远程登陆密码
useradd slan 创建一个为slan的用户
passwd slan 设置用户slan的密码
显示:
[root@EasygoingEssential-VM ~]# useradd slan
[root@EasygoingEssential-VM ~]# passwd slan
Changing password for user test.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@EasygoingEssential-VM ~]#
然后编辑ssh配置文件
vi /etc/ssh/sshd_config
将Port 22 改为 Port 9527(1到65535之间,且没有被占用),并删掉前面的# 注释符
PermitRootLogin yes 改为 PermitRootLogin no 禁用root远程登陆
大概配置文件如下:
Port 9527
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
```
```xml
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
完成,保存重启ssh服务生效。
注: 更改端口一定要关闭防火墙,否则无法用新端口连接ssh.或者自己设置防火墙放行
systemctl stop firewalld.service 关闭防火墙
systemctl disable firewalld.service关闭开机启动
[root@EasygoingEssential-VM ~]# systemctl stop firewalld.service
[root@EasygoingEssential-VM ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
以后ssh登录用创建的slan普通用户登录,登录后可用`su - `切换root用户。
5:更改终端命令行颜色(可选)
更改终端命令行颜色,为了更加直观方便以后观看及查看命令。
更改
vi /etc/profile 此文件对所有用户有效,如果只对当前用户有效,则vi .bashrc
在最后面加上
PS1='[\[\e[32m\]\u\[\e[0m\]\[\e[35m\]@\[\e[0m\]\[\e[33m\]\h\[\e[0m\]\[\e[36m\] \W\[\e[0m\]]\$ '
最后
source /etc/profile 更新文件,可以看到命令行颜色已变化。
相关推荐
- 0722-6.2.0-如何在RedHat7.2使用rpm安装CDH(无CM)
-
文档编写目的在前面的文档中,介绍了在有CM和无CM两种情况下使用rpm方式安装CDH5.10.0,本文档将介绍如何在无CM的情况下使用rpm方式安装CDH6.2.0,与之前安装C5进行对比。环境介绍:...
- ARM64 平台基于 openEuler + iSula 环境部署 Kubernetes
-
为什么要在arm64平台上部署Kubernetes,而且还是鲲鹏920的架构。说来话长。。。此处省略5000字。介绍下系统信息;o架构:鲲鹏920(Kunpeng920)oOS:ope...
- 生产环境starrocks 3.1存算一体集群部署
-
集群规划FE:节点主要负责元数据管理、客户端连接管理、查询计划和查询调度。>3节点。BE:节点负责数据存储和SQL执行。>3节点。CN:无存储功能能的BE。环境准备CPU检查JDK...
- 在CentOS上添加swap虚拟内存并设置优先级
-
现如今很多云服务器都会自己配置好虚拟内存,当然也有很多没有配置虚拟内存的,虚拟内存可以让我们的低配服务器使用更多的内存,可以减少很多硬件成本,比如我们运行很多服务的时候,内存常常会满,当配置了虚拟内存...
- 国产深度(deepin)操作系统优化指南
-
1.升级内核随着deepin版本的更新,会自动升级系统内核,但是我们依旧可以通过命令行手动升级内核,以获取更好的性能和更多的硬件支持。具体操作:-添加PPAs使用以下命令添加PPAs:```...
- postgresql-15.4 多节点主从(读写分离)
-
1、下载软件[root@TX-CN-PostgreSQL01-252software]#wgethttps://ftp.postgresql.org/pub/source/v15.4/postg...
- Docker 容器 Java 服务内存与 GC 优化实施方案
-
一、设置Docker容器内存限制(生产环境建议)1.查看宿主机可用内存bashfree-h#示例输出(假设宿主机剩余16GB可用内存)#Mem:64G...
- 虚拟内存设置、解决linux内存不够问题
-
虚拟内存设置(解决linux内存不够情况)背景介绍 Memory指机器物理内存,读写速度低于CPU一个量级,但是高于磁盘不止一个量级。所以,程序和数据如果在内存的话,会有非常快的读写速度。但是,内存...
- Elasticsearch性能调优(5):服务器配置选择
-
在选择elasticsearch服务器时,要尽可能地选择与当前业务量相匹配的服务器。如果服务器配置太低,则意味着需要更多的节点来满足需求,一个集群的节点太多时会增加集群管理的成本。如果服务器配置太高,...
- Es如何落地
-
一、配置准备节点类型CPU内存硬盘网络机器数操作系统data节点16C64G2000G本地SSD所有es同一可用区3(ecs)Centos7master节点2C8G200G云SSD所有es同一可用区...
- 针对Linux内存管理知识学习总结
-
现在的服务器大部分都是运行在Linux上面的,所以,作为一个程序员有必要简单地了解一下系统是如何运行的。对于内存部分需要知道:地址映射内存管理的方式缺页异常先来看一些基本的知识,在进程看来,内存分为内...
- MySQL进阶之性能优化
-
概述MySQL的性能优化,包括了服务器硬件优化、操作系统的优化、MySQL数据库配置优化、数据库表设计的优化、SQL语句优化等5个方面的优化。在进行优化之前,需要先掌握性能分析的思路和方法,找出问题,...
- Linux Cgroups(Control Groups)原理
-
LinuxCgroups(ControlGroups)是内核提供的资源分配、限制和监控机制,通过层级化进程分组实现资源的精细化控制。以下从核心原理、操作示例和版本演进三方面详细分析:一、核心原理与...
- linux 常用性能优化参数及理解
-
1.优化内核相关参数配置文件/etc/sysctl.conf配置方法直接将参数添加进文件每条一行.sysctl-a可以查看默认配置sysctl-p执行并检测是否有错误例如设置错了参数:[roo...
- 如何在 Linux 中使用 Sysctl 命令?
-
sysctl是一个用于配置和查询Linux内核参数的命令行工具。它通过与/proc/sys虚拟文件系统交互,允许用户在运行时动态修改内核参数。这些参数控制着系统的各种行为,包括网络设置、文件...
你 发表评论:
欢迎- 一周热门
- 最近发表
- 标签列表
-
- linux 查询端口号 (58)
- docker映射容器目录到宿主机 (66)
- 杀端口 (60)
- yum更换阿里源 (62)
- internet explorer 增强的安全配置已启用 (65)
- linux自动挂载 (56)
- 禁用selinux (55)
- sysv-rc-conf (69)
- ubuntu防火墙状态查看 (64)
- windows server 2022激活密钥 (56)
- 无法与服务器建立安全连接是什么意思 (74)
- 443/80端口被占用怎么解决 (56)
- ping无法访问目标主机怎么解决 (58)
- fdatasync (59)
- 405 not allowed (56)
- 免备案虚拟主机zxhost (55)
- linux根据pid查看进程 (60)
- dhcp工具 (62)
- mysql 1045 (57)
- 宝塔远程工具 (56)
- ssh服务器拒绝了密码 请再试一次 (56)
- ubuntu卸载docker (56)
- linux查看nginx状态 (63)
- tomcat 乱码 (76)
- 2008r2激活序列号 (65)