Linux安装初始化

Linux 各种命名规范

1、文件名不能包括反斜线字符 “/” “NUL(空)”,其它字符均可。
2、主机名不支持下划线字符 “_”,可使用字母、数字、横线组合,部分软件对主机名有特殊要求。

命令帮助

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@tencent ~]# which  ls 
alias ls='ls --color=auto'
/usr/bin/ls

[root@tencent ~]# type trap
trap is a shell builtin
[root@tencent ~]# help trap

[root@tencent ~]# type vim
vim is /usr/bin/vim
[root@tencent ~]# vim --help / -h
[root@tencent ~]# man vim

[root@tencent ~]# whatis ls
ls (1) - list directory contents
ls (1p) - list directory contents

Rocky Linux 安装后必需所做的初始化操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#关闭SELinux 
sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config

#关闭防火墙
systemctl disable --now firewalld

#支持光盘,/misc/cd对应就是光盘内容
yum -y install autofs
systemctl enable --now autofs

#配置yum 仓库
#系统源(改为阿里源并备份)
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-i.bak \
/etc/yum.repos.d/Rocky*.repo
yum makecache
yum list

#EPEL源(Rocky8/CentOS8)
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

#修改网卡名称
[root@rocky8 ~]#sed -ri '/GRUB_CMDLINE_LINUX=/s#(.*)"$#\1 net.ifnames=0"#' /etc/default/grub
[root@rocky8 ~]#grub2-mkconfig -o /boot/grub2/grub.cfg
[root@rocky8 ~]#reboot
#配置网卡地址:
[root@rocky ~]# mv /etc/sysconfig/network-scripts/ifcfg-xxxxx ifcfg-xxxxx.bak
[root@rocky ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=10.0.0.129
PERFIX=24
GATEWAY=10.0.0.2
DNS1=223.5.5.5
DNS2=180.76.76.76
[root@rocky ~]# nmcli connection reload
[root@rocky ~]# nmcli connection up eth0

#最小化安装系统后,建议安装常用软件
yum -y install autofs vim vim-enhanced tcpdump autofs chrony lrzsz tree telnet ftp lftp bash-completion net-tools postfix wget bzip2 zip unzip xz lsof mlocate man-pages rsync gcc autoconf gcc-c++ iotop nfs-utils openssl-devel pcre-devel systemd-devel tmux dos2unix redhat-lsb-core

Ubuntu开启root远程登录功能

1
2
3
4
sudo -i
passwd root
sed -i '/PermitRootLogin/c PermitRootLogin yes' /etc/ssh/sshd_config
systemctl restart sshd

网络检查命令

1
2
3
4
5
监听端口:ss   -ntlp
监听端口:losf -i :port
IP地址:ip a
网关: route -n
DNS: cat /etc/resolv.conf

CentOS6设置主机名

1
2
[root@x-z ~]# vim /etc/sysconfig/network
[root@x-z ~]# hostname x-z.top

CentOS7设置主机名

1
[root@x-z ~]# hostnamectl set-hostname x-z.top


Linux安装初始化
https://www.xcjyc.top/2022/11/06/Linux初始化操作/
作者
XCJYC
发布于
2022年11月6日
许可协议