云服务器 CentOS 使用前准备工作
1. 修改开机密码
直接在提供商的云控制台处理, 不赘述
2. ssh key 配置实现免密登录
将已有的 id_rsa
文件放到本地 ~/.ssh
下, id_rsa.pub
放到阿里云, 不赘述
本地的 ssh key 有可能权限过大, 导致用 ssh 登录服务器时出现报错
~
▶ ssh root@xxx.xxx.xxx.xxx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/xxx/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/xxx/.ssh/id_rsa": bad permissions
root@xxx.xxx.xxx.xxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
查看权限为 644, 改为 600 即可
~/.ssh
▶ ll
total 64
-rw-r--r--@ 1 xxx staff 1.8K 11 2 09:59 id_rsa
~/.ssh
▶ chmod 600 ./id_rsa
~/.ssh
▶ ll
total 64
-rw-------@ 1 xxx staff 1.8K 11 2 09:59 id_rsa
~/.ssh
▶ ssh root@xxx.xxx.xxx.xxx
Last login: Mon Nov 2 15:05:12 2020 from xxx.xxx.xxx.xxx
Welcome to Alibaba Cloud Elastic Compute Service !
[root@xxx ~]#
3.了解服务器基本信息
描述 | 命令 |
---|---|
查看系统基础信息 | uname -a |
查看系统版本 | cat /etc/redhat-release / lsb_release -a / cat /proc/version |
查看cpu信息 | cat /proc/cpuinfo |
查看系统内存及交换分区使用情况 | free -m |
查看分区使用情况 | df -h |
查看系统运行时间,用户数,负载情况 | uptime |
查看活动用户 | w |
查看用户登录日志 | last |
查看用户计划任务 | crontab -l |
查看系统服务状态 | chkconfig --list /systemctl list-unit-files |
4. 软件安装相关
描述 | 命令 |
---|---|
列出所有可更新的软件清单 | yum check-update |
安装所有更新软件 | yum update |
仅安装指定的软件 | yum install <package_name> |
仅更新指定的软件 | yum update <package_name> |
列出所有可安裝的软件清单 | yum list |
查看yum安装的软件 | yum list installed |
查看rpm安装的软件 | rpm -qa |
查看deb安装的软件 | dpkg -l |
查看pip安装的所有包 | pip list |
如果要看的软件是以源码包自己编译安装的,例如.tar.gz或者tar.bz2形式的,这个只能看可执行文件是否存在了。
如果是以root用户安装的,可执行程序通常都在/sbin:/usr/bin目录下
5. 安装 zsh 系列工具
安装 zsh
sudo yum install zsh -y
安装 Oh My Zsh
参考文档 : https://github.com/ohmyzsh/ohmyzsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
在国内网络执行此命令时会出现报错
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl: (7) Failed connect to raw.githubusercontent.com:443; 拒绝连接shell
通常由域名污染引起, 改 host 可解决, 步骤记录 :
- 通过 https://www.ipaddress.com/ 查询
raw.githubusercontent.com
的真实 IP ( 此处查得为199.232.68.133
) - 修改
/etc/hosts
文件, 添加199.232.68.133 raw.githubusercontent.com
, 可使用下列命令 :
sed -i '$a\199.232.68.133 raw.githubusercontent.com' /etc/hosts
- 安装
syntax highlighting
插件 ( https://github.com/zsh-users/zsh-syntax-highlighting )
执行下列克隆命令后将zsh-syntax-highlighting
添加到~/.zshrc
的plugin {}
块中
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- 安装
autosuggestions
插件 ( https://github.com/zsh-users/zsh-autosuggestions )
执行下列克隆命令后将zsh-autosuggestions
添加到~/.zshrc
的plugin {}
块中
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- 安装
autojump
插件 ( https://github.com/wting/autojump )
- 克隆项目到本地
git clone git://github.com/wting/autojump.git
- 到
autojump
目录下执行./install.py
- 根据提示将下列命令写入
~/.zshrc
[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u
或者使用 sed 命令
sed -i '$a\[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u' ~/.zshrc
至此几个基本的生产力工具和插件安装完成
6. 安装万能的 docker
sudo yum install -y docker
安装过程中出现一行不影响安装进行的 log, 留记录, 日后遇到相关问题再说
setsebool: SELinux is disabled.
启动 docker 服务
systemctl start docker
7. 换源
换源的原因是 git 版本太旧
yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
yum update
评论
其他文章