ps:在腾讯云买了一个最便宜的服务器,在万网买了域名,就等身份证下来开始备案了。将鼓捣的内容记录在此,方便查阅
服务器版本:centos 7.2
1.修改默认的hostname,这里改为
vim /etc/hostname
网上搜到上述指令,然而并没有生效,继续搜索,执行以下指令
hostnamectl set-hostname <hostname>
然后执行如下指令刷新,显示修改成功
su -
2.挂载云盘
[root@catchtouch /]# df -h #查看当前硬盘
[root@catchtouch /]# fdisk -l
得知数据盘名称为vdb
[root@catchtouch /]# mkdir /mydata #建立mydata目录,将数据盘挂载到此处
[root@catchtouch /]# fdisk /dev/vdb #硬盘分区
[root@catchtouch /]# mkfs.ext3 /dev/vdb1 #格式化分区
[root@catchtouch /]# mount /dev/vdb /mydata #挂载到mydata,注意,这是临时挂载
[root@catchtouch /]# echo '/dev/vdb1 /mydata ext3 defaults 0 0' >> /etc/fstab #设置开机自动挂载
在此执行df -h
挂载成功
3.分配一个常用的登录用户,用户组,毕竟不轻易祭出root神器。。。
创建worker用户,并赋予sudo权限
[root@catchtouch ~]# adduser worker #添加用户 worker [root@catchtouch ~]# passwd worker #为添加的worker用户设置密码 Changing password for user worker. New password: Retype new password: passwd: all authentication tokens updated successfully. #密码修改成功 #为worker添加sudo权限 [root@catchtouch ~]# ls -l /etc/sudoers 查看sudoers文件权限,发现只读 -r--r-----. 1 root root 4188 Jul 7 2015 /etc/sudoers [root@catchtouch ~]# chmod -v u+w /etc/sudoers #添加写权限 mode of '/etc/sudoers' changed from 0440 (r--r-----) to 0640 (rw-r-----) [root@catchtouch ~]# ls -l /etc/sudoers #此时已经拥有写权限 -rw-r-----. 1 root root 4188 Jul 7 2015 /etc/sudoers [root@catchtouch ~]# vim /etc/sudoers #在最后一行添加worker ALL=(ALL) ALL ,然后保存修改 [root@catchtouch ~]# chmod -v u-w /etc/sudoers #去除刚刚添加的写权限
至此用户以及sudo权限添加完成