What would I do with a new CentOS server

add my own user

1
2
adduser USERNAME
passwd USERNAME

add user to sudoers

1
vim /etc/sudoers

add USERNAME ALL=(ALL) ALL just belowroot ALL=(ALL) ALL

switch user

1
su USERNAME

(if you’re in China) change the source

1
2
3
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

install build essencials

1
sudo yum -y groupinstall "Development Tools" # -y means 'yes'

install zsh and oh-my-zsh

1
2
sudo yum -y install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

in case drop out

1
vim /etc/ssh/sshd_config

find lines below:

1
2
ClientAliveInterval 0
ClientAliveCountMax 3

uncomment and change:

1
2
ClientAliveInterval 30
ClientAliveCountMax 86400

and restart the service:

1
service sshd restart

install nvm

1
2
3
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm install --lts
npm install -g yarn

install global node modules

1
yarn global add vue-cli @angular/cli typescript http-server gulp webpack

in China, you may change the source into Taobao’s

1
yarn config set registry https://registry.npm.taobao.org

when switch to other sh, I would

1
vim ~/.bashrc

in vim, add

1
export PATH=/home/dmf/.yarn/bin:$PATH

In case grub is down, and start with gurb rescue,

1
grub rescue>ls

for each listed below, try ls it.
for example, ls (hd0, msdos3) or ls (hd0, gpt5), until the output is not filesystem error

1
2
3
4
grub rescue >root=(hdx,msdosx)
grub rescue >prefix=(hdx,msdosx)/boot/grub
grub rescue >insmod normal
grub rescue >normal

then restart the computer
in terminal input

1
2
sudo grub-install /dev/sda
sudo grub-mkconfig -o /boot/grub/grub.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-`
.o+`
`ooo/
`+oooo:
`+oooooo:
-+oooooo+:
`/:-:++oooo+:
`/++++/+++++++:
`/++++++++++++++:
`/+++ooooooooooooo/`
./ooosssso++osssssso+`
.oossssso-````/ossssss+`
-osssssso. :ssssssso.
:osssssss/ osssso+++.
/ossssssss/ +ssssooo/-
`/ossssso+/:- -:/+osssso+-
`+sso+:-` `.-/+oso:
`++:. `-/+/
.` `/