桌面系统
为了方便虚拟机下使用 Ubuntu ,结合自身使用经验,给出以下几个命令:
systemd-analyze
systemd-analyze blame
sudo systemctl disable xxx.service
sudo systemctl mask xxx.service
systemctl list-unit-files
熟悉的话不用看了
开机优化
开机时间统计
systemd-analyze
显示开机启动项的时间
systemd-analyze blame
systemd-analyze blame 结果如下
可以看到前面的时间,后面的是服务名,并且是按照时间的倒序排列。接下来找到排名前10的服务名,杀死???
去谷歌这这些服务名,搞清楚是否能干掉。
如果能,将用到下面两个命令:
sudo systemctl disable xxx.service
sudo systemctl mask xxx.service
disable 和 mask 的区别:可以用 man systemctl 来查看。
This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care.
什么意思呢?
一般禁止用 disable 就行了。
查看ubuntu所有的服务
systemctl list-unit-files
这里就看到所有的开机自启项,左边是服务名称,右边是状态,enabled是开机启动,disabled是开机不启动,mask 是彻底被干掉了。
更换源
简单
1.备份 source.list 文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bkp
2.编辑 sources.list
不管是 gedit,nano 还是 vi,都行,将 sources.list 清空,然后将你要添加的源(阿里?网易163?清华?Whatever)甩到里面。
3.更新生效
apt-get update ; apt-get upgrade -y
执行错误的话就再执行该命令一次。
更简单
想想你用的是什么,是 Linux 啊!在 Linux 下修改设置,没有一个.sh
解决不了的事情。搜索下“一键更换Linux软件源脚本”,懒得搜索的话,下面给了链接。顺带一嘴:看了下脚本的内容,其实对我们自己来说,就是将一个将文件清空,然后写入,自己动手可以将其简化一下。之后你发现,你还可以配置.vimrc
、.bahrc
、.tmux.conf
等等,然后将安装和配置都写在一个shell
脚本中。世界变得不再复制和黏贴。
VPS
更改 SSH 端口号
修改SSH配置文件
vi /etc/ssh/sshd_config
将原来的 22 换成 其他的就行了。
重启生效
service sshd restart
创建新用户
将下面的两个hehe换成你的用户名
useradd -s /bin/bash -m hehe ; passwd hehe
输入密码两次完成创建。
接下来给用户添加 sudo 命令的使用权限
首先查看是否安装sudo
visudo
没有就安装
apt-get install sudo -y
然后写入
echo -e "\nhehe ALL=(ALL) ALL\n" >> /etc/sudoers
这句意思是:允许用户 hehe 执行 sudo 命令 (需要输入密码)
检查是否写入成功
cat /etc/sudoers
酸酸乳
(必须 )
有肥宅快乐水还要啥自行车?——本山耀司
参考链接:
SuperUpdate.sh 一键更换Linux软件源脚本