Rocky_linux模板机
1001 字
5 分钟
Rocky_linux模板机

Rocky_linux模板机
[TOC]
LAN区段

eth0


英文

- 图片是中文的 —> 选的时候选==英文==安装

时间nft

网络



[root@Rocky ~]# cd /etc/NetworkManager/system-connections/[root@Rocky system-connections]# lseth0.nmconnection eth1.nmconnection[root@Rocky system-connections]# cat eth0.nmconnection[connection]id=eth0uuid=030f55ac-9e82-3307-947c-9564675ea467type=ethernetinterface-name=eth0
[ethernet]
[ipv4]address1=10.0.0.100/24dns=223.6.6.6;gateway=10.0.0.2method=manual...[root@Rocky system-connections]# cat eth1.nmconnection[connection]id=eth1uuid=cb82b7c4-5ad8-3992-82ae-04010465e009type=ethernetinterface-name=eth1
[ethernet]
[ipv4]address1=192.168.88.100/24method=manual....==========================================
#!/bin/bash#author: jiuzhao#先输入主机名---》然后是IP地址!
[ $# -ne 2 ] && { echo "Usage: $0 <hostname> <new_ip>" echo "Example: $0 web01 192.168.1.200" exit 1}
# 新主机名new_hostname=$1
# 修改主机名hostnamectl set-hostname $new_hostname
# 获取IP地址的最后一段# 例如192.168.1.200获取200,因为两个网卡都要进行修改ip=$(hostname -I | awk '{print $1}' | awk -F. '{print $NF}')# $NF最后一列# -F. 以.为分隔符new_ip=$(echo $2 | awk -F. '{print $NF}')# $2是我们刚才输入进去的IP地址
# 修改IP(假设使用ifcfg-eth0)sed -i "s#10.0.0.$ip#10.0.0.$new_ip#g" /etc/NetworkManager/system-connections/eth0.nmconnectionsed -i "s#192.168.88.$ip#192.168.88.$new_ip#g" /etc/NetworkManager/system-connections/eth1.nmconnection
nmcli con reloadnmcli con up eth0nmcli con up eth1# 重启网络systemctl restart NetworkManager
echo "hostname changed to $new_hostname IP changed to $2 "ROOT账户

Shell脚本
#!/bin/bash# author=Jiuzhao
cd /etc/yum.repos.d/ls | xargs -i cat {} > /server/repo/Rocky.repo# 把原来的源都写到一个文件中cd -
# yum仓库优化sed -e 's|^mirrorlist=|#mirrorlist=|g' \ -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.tuna.tsinghua.edu.cn/rocky|g' \ -i.bak \ /etc/yum.repos.d/rocky*.repodnf clean alldnf makecachednf install epel-release -y# 扩展仓库dnf makecachednf install -y vim-enhanced tree wget bash-completion lrzsz zip tar net-tools sysstat iotop htop unzip nmap-ncat nmap telnet bc psmisc httpd-tools bind-utils openssh-clients expect cowsay sl# 安装必要的软件
# PS1变量echo 'PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \W\[\e[0m\]]\\$ "' >> /etc/profilesource /etc/profile
# ssh优化cat >>/etc/ssh/sshd_config<<EOFUseDNS no#相当于网络命令的-n选项,这个就是说不解析为主机名,直接成IP地址.GSSAPIAuthentication no#关闭GSS认证.EOFsystemctl restart sshd
# 防火墙&&SElinuxsed -i 's#enforcing#disabled#g' /etc/selinux/config# 重启生效systemctl disable --now firewalld &> /dev/null
# 文件描述符echo "* - nofile 65535" >> /etc/security/limits.conf
# 其他优化> /etc/issue && > /etc/issue.netcat > /etc/motd << 'EOF' (@) * (@) * (@) : * (@) * (@) * .; (@) * (@) * (@) * (@) * ; * ; (@) * ; * : ;\ \ \ \| / / /; \\ \ Y/ / / `_\ |/ _' ' / \\Y// \ ( ,-}={-, ) \_//((\_/ //))(\ (/ )) (/EOF
reboot# 重启生效配置yum仓库优化
'国内的默认仓库!'sed -e 's|^mirrorlist=|#mirrorlist=|g' \ -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.tuna.tsinghua.edu.cn/rocky|g' \ -i.bak \ /etc/yum.repos.d/rocky*.repo
dnf clean alldnf makecacheroot@Rocky:~# cd /etc/yum.repos.d/root@Rocky:/etc/yum.repos.d# ll总计 40-rw-r--r--. 1 root root 5535 4月 1日 20:46 rocky-addons.repo-rw-r--r--. 1 root root 5490 11月 5日 08:00 rocky-addons.repo.bak-rw-r--r--. 1 root root 1177 4月 1日 20:46 rocky-devel.repo-rw-r--r--. 1 root root 1168 11月 5日 08:00 rocky-devel.repo.bak-rw-r--r--. 1 root root 2411 4月 1日 20:46 rocky-extras.repo-rw-r--r--. 1 root root 2393 11月 5日 08:00 rocky-extras.repo.bak-rw-r--r--. 1 root root 3453 4月 1日 20:46 rocky.repo-rw-r--r--. 1 root root 3426 11月 5日 08:00 rocky.repo.bakroot@Rocky:/etc/yum.repos.d# ls | grep .bak$ | xargs rm -rfroot@Rocky:/etc/yum.repos.d# ll总计 20-rw-r--r--. 1 root root 5535 4月 1日 20:46 rocky-addons.repo-rw-r--r--. 1 root root 1177 4月 1日 20:46 rocky-devel.repo-rw-r--r--. 1 root root 2411 4月 1日 20:46 rocky-extras.repo-rw-r--r--. 1 root root 3453 4月 1日 20:46 rocky.repo====================================='epel扩展仓库!'dnf install epel-release -y已安装: epel-release-10-7.el10_1.noarch完毕!root@Rocky:/etc/yum.repos.d# ll总计 28-rw-r--r--. 1 root root 1612 11月19日 08:00 epel.repo-rw-r--r--. 1 root root 1714 11月19日 08:00 epel-testing.reporoot@Rocky:/etc/yum.repos.d# dnf makecache=====================================安装完epel扩展仓库后,立马下个小火车玩!!root@Rocky:/etc/yum.repos.d# yum -y install sl已安装: sl-5.02-1.el10_1.x86_64完毕!
root@Rocky:~# mkdir -p /soft# 存放常用软件root@Rocky:~# mkdir -p /server/tmp# 存放临时目录root@Rocky:~# mkdir -p /server/sh# 存放脚本root@Rocky:/server/tmp# ll总计 44-rw-r--r--. 1 root root 43144 4月 1日 21:02 cowsay-3.04-4.el7.noarch.rpmroot@Rocky:/server/tmp# rpm -ih cowsay-3.04-4.el7.noarch.rpm'奶牛说!啊哈哈哈!'root@Rocky:/server/tmp# cowsay "哈哈哈" _____< 哈哈哈 > ----- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||root@Rocky:/server/tmp# animalsay "呵呵哒"# 动物说! _____< 呵呵哒 > ----- ===================================== [root@Rocky ~]# dnf -y install lrzsz # 有了这个就可以rz上传,sz下载了!!改为英文
[root@Rocky ~]# echo $LANGzh_CN.UTF-8[root@Rocky ~]# vim /etc/locale.confLANG="en_US.UTF-8"
# 重启生效![root@Rocky ~]# lllllll-bash: lllllll: command not found防火墙&&SElinux
[root@Rocky ~]# vim /etc/selinux/config[root@Rocky ~]# grep -i disabled /etc/selinux/config | tail -1SELINUX=disabled[root@Rocky ~]# systemctl disable firewalldRemoved '/etc/systemd/system/multi-user.target.wants/firewalld.service'.Removed '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'.[root@Rocky ~]# systemctl stop firewalld'重启系统生效!'[root@Rocky ~]# getenforceDisabled[root@Rocky ~]# systemctl is-active firewalldinactive[root@Rocky ~]# systemctl is-enabled firewallddisabled文件描述符
[root@Rocky ~]# ulimit -n1024[root@Rocky ~]# echo "* - nofile 65535" >> /etc/security/limits.conf[root@Rocky ~]# tail -1 /etc/security/limits.conf* - nofile 65535[root@Rocky ~]# reboot# 重启系统生效[root@Rocky ~]# ulimit -n65535文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!



