初始化

 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
yum update # 升级
yum grouplist | grep development
yum groupinstall "Development Tools" # 安装常用工具

# 添加用户
adduser deploy
passwd deploy
usermod -a -G wheel deploy

# ssh 登录
ssh-keygen
scp id_rsa.pub to vps

touch ~/.ssh/authorized_keys
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

chown -R deploy:deploy .ssh
chmod 700 .ssh
chmod 600 authorized_keys

# 禁用密码和root
vim /etc/ssh/sshd_config

PasswordAuthentication no
PermitRootLogin no

# 可能需要修改
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

sudo systemctl restart sshd.service

用户相关

1
2
3
4
5
6
7
8
# 修改用户
usermod -l NewUser -d /home/NewUser -m OldUser
# usermod -l alao -d /home/alao -m tom
groupmod -n NewUser OldName
#groupmod    -n   alao   tom

# 删除用户
user -r deploy

本机信息相关

查看信息

1
2
# 查看 CentOS 版本
cat /etc/redhat-release

更改信息

1
2
3
4
5
6
# 修改主机名
# /etc/hostname
sudo hostnamectl set-hostname <主机名>

# 修改时区
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

网络编辑

1
sudo nmtui edit

虚拟机相关

加第二张内网网卡时,去掉自动默认路由(类似的名字)。

环境

java

1
2
3
yum -y list java*
yum -y install java-1.8.0-openjdk*
# 可能只安装src即可

setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

For CentOS or Amazon AMI Linux, add these lines to /etc/environment (create it, if it doesn’t exist):

1
2
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

VIM

1
2
3
4
" 修改注释颜色
hi comment ctermfg=6 
" 显示行号
set nu