加大文件描述符
文件最大打开数 默认1024
echo '* - nofile 65535' >> /etc/security/limits.conf
ssh安全优化
/etc/ssh/sshd_config
PermintRootLogin #不允许root用户远程登录
Port 6666 #变更ssh服务器远程连接端口
PasswordAuthenticatio #禁止使用密码直接远程登录
UseDNS #禁止ssh进行dns反向解析 影响效率
GSSAPIAuthentication #禁止GSS认证 减少连接时产生的延迟
Ubuntu无法scp传输文件
(1)修改配置文件
vim /etc/ssh/sshd_config
PermintRootLogin yes
(2)重启sshd服务
systemctl restart sshd
(3)配置root密码
使用passwd命令
修改默认的yum仓库
什么是yum:软件仓库(应用商城)
仓库地址:国外的官网地址 清华源 阿里源
阿里源:opsc.alibaba.com
centos操作系统:默认的为国外的仓库 下载速度慢 修改为国内的yum仓库
麒麟操作系统:默认不需要修改
目录 /etc/yum.repos.d
ubuntu操作系统:修改为国内的yum仓库
查看默认的仓库:apt-cache policy
第一步:编辑/etc/apt/sources.list
第二步:dG删除
第三步:进入编辑模式粘贴一下内容
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
第四步:生成软件本地缓存
apt update
第五步:查看是否配置成功
apt-cache policy 或者测试是否从阿里源下载
安装软件:
centos和麒麟 yum -y install xxx
ubuntu apt -y install xxx
安装epel扩展仓库:
uubuntu不用安装
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
在阿里源上
安装软件:
测试一下
麒麟:yum -y install lrzsz #装上才能和windows上传和下载
yum -y install cowsay sl #在扩展的epel仓库中 cow奶牛
[root@shang ~]# animalsay what
[root@shang ~]# cowsay "what"
总结:
centOS默认需要修改 而且需要安装拓展的epel
麒麟:不需要修改,安装拓展epel
unbuntu:需要修改阿里源,不需要安装拓展epel
关闭防火墙
作用:阻止非法流量进入系统
什么情况下开启防火墙
1、在有公网的服务器上
2、服务器上有服务器的情况下(NAT路由器)
什么情况下关闭
1、内网情况下关闭
2、测试服务器
3、流量大的情况下(网站访问问多)
unbuntu的防火墙:ufw
centos和麒麟的防火墙:firewalld
开启 systemctl start firewalld
关闭 sysytemctl stop firewalld
查看 sysytemctl status firewalld
麒麟步骤:
第一步:关闭
sysytemctl stop firewalld
第二步:禁止开机自启动
sysytemctl disable firewalld
ubuntu步骤
第一步:sysytemctl stop ufw
第二步:sysytemctl disable ufw /
关闭selinux
美国安全局开发 企业不用
centos默认开启
第一步:需要在系统中关闭 setenforce
第二步:修改配置文件 /etc/seliunx/config
将SELINUX=enforcing 修改为 SELINUX=disabled
麒麟 默认关闭 不需要更改
ubuntu 默认关闭 不需要修改
字符集优化
字符集:让字符串正常的在系统中显示
GBK 国标
UTF-8 万国码 默认
LANG=zh_CN.UTF-8 中文
LANG=en_US.UTF-8 英文
查看默认的字符集 echo $LANG
[root@shang ~]# echo $LANG
zh_CN.UTF-8
麒麟修改字符集:
第一步:编辑 vim /ect/locale.conf
第二步:修改 LANG=en_US.UTF-8
第三步:生效 source /etc/locale.conf
或者重新连接xshell
ubuntu修改字符集:
第一步:编辑 vim /etc/default/locale
第二步:修改 LANG=en_US.UTF-8
第三步:生效 source /etc/locale.conf
或者重新启动xshell
时间同步
时间分为两种:如果时间不对 麒麟软件无法安装 会影响业务
硬件时间 系统时间
时间:可以看的懂得
时间戳:看不懂需要转换
unbuntu 时间会默认同步 不需要修改
查看时间:date
2024年 07月 08日 星期一 11:50:27 CST
修改时间:date -s 时间
测试使用
查看硬件时间:clock
安装时间同步工具:ntpdate
yum -y install ntpdate
如果时间不准确 安装不了 需要手动修改
date -s 最近的时间
ntpdate 时间服务器
时间服务器:ntp1.aliyun.com
时间同步:ntpdate ntp1.aliyun.com
修改命令提示符
调试命令行
第一步写入/etc/profile
PS1='[\[\033[1;32m\]\u\[\033[1;37m\]@\[\033[1;36m\]\h\[\033[00m\]:\[\033[1;34m\]\W\[\033[00m\]]\$ '
第二步:重新连接xshell
改为有颜色的生效的
使用source /etc/profile 或重新连接xshell
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
Ubuntu写入/root/.bashrc
source .bashrc
安装常用命令
麒麟
yum -y install net-tools htop iftop lrzsz unzip telnet httpd-tools tcpdump
ubuntu
apt -y install net-tools tree lrzsz
lrzsz包含了两个命令
rz #将windows上的文件上传到linux
xshell 鼠标拖拽到linux
不能上传空文件 空文件会报错
rz -bye #格式化上传文件 防乱码
sz #将linux上的文件下载到windows
会输出到桌面
sz a.txt
rz进 sz出 可以用rzsz在windows和xshell之间互相传输
linux三种安装方式
linux三种软件安装方式
1.yum安装
特点:简单 快捷
类似于在手机的应用商城搜索到直接安装
可以自动解决依赖的问题
不能选择默认安装的位置
2.rpm安装 依赖类似于windows上的手游模拟器
特点:类似于windows先将软件下载下来,exe文件,双击安装
不能解决依赖问题 需要手动解决
默认的仓库没有软件 只能通过官网下载软件使用rpm进行安装
软件比较大 网络不好的情况下 使用rpm包本地安装
企业中没有外网的情况下
出现依赖 缺少依赖使用yum安装依赖
3.编译安装
自定义模块
自定义安装位置
centos和麒麟
语法结构:
yum -y install 包名称 #安装
参数选项 -y #表示自动yes
yum -y remove 包名称 #卸载
yum -y reinstall 包名称 #覆盖安装
yum clean all 包名称 #清空缓存
无法安装软件:
1、连接不上网
2、命令错误
3、包名错误 很多命令在其他名称的包里面
如果没有问题 清空缓存尝试
ubuntu操作系统安装软件
语法结构:
apt install #安装
dpkg -r #卸载
rpm安装:
语法结构:
rpm -ivh #安装
rpm -e #卸载 需要带着包的名字或者带着版本号 #或者使用yum卸载
参数选项:
-i install
-v 显示安装过程
-h 进度
-ivh一起使用即可
-qa 查看系统中所有安装的软件 是否安装 如果忘记单词 可以管道符grep过滤
-ql 查看软件包含的内容
第一步:下载rpm包
第二步:使用rpm安装
保存缓存包
vim /etc/yum.conf
keepcache=1
cachedir=/var/cache/yum
缓存包所在位置 /var/cache/yum