post:万场目前计划的一部分Ubuntu Server技巧。
This commit is contained in:
49
source/_posts/ubuntu-tips.md
Normal file
49
source/_posts/ubuntu-tips.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: Ubuntu Server技巧合集
|
||||
tags:
|
||||
- Ubuntu
|
||||
- Linux
|
||||
- 操作技巧
|
||||
- 常用命令
|
||||
categories:
|
||||
- - DevOps
|
||||
- 系统管理
|
||||
update: 2021-05-10 22:57:09
|
||||
date: 2021-05-09 23:28:00
|
||||
---
|
||||
|
||||
## 安装X Server
|
||||
|
||||
Ubuntu Server默认是没有安装X Server的,这也就是说,在默认情况下Ubuntu Server是不能运行任何图形程序的。如果要在Ubuntu Server上运行图形程序,那么只需要安装一套X Server就可以了。
|
||||
|
||||
从网络上能够搜到的大部分资料,都是采用命令`sudo apt install ubuntu-desktop`来安装X Server的。诚然,这样是可以在Ubuntu Server上安装X Server,但是因为是安装了整个的桌面组件,所以也会安装浏览器、Office等并不需要在Server系统上使用的内容。
|
||||
|
||||
所以只安装X Server的办法,就是安装`xorg`,这样安装的是最小版的X11服务。要安装`xorg`,可以执行以下命令。
|
||||
|
||||
```bash
|
||||
sudo apt install xorg openbox
|
||||
```
|
||||
|
||||
## 让Ubuntu Server启动到命令行
|
||||
|
||||
在为Ubuntu Server安装了X server以后,再次启动Ubuntu Server会自动进入到等待登录的图形界面上,如果不需要这个界面,可以使用以下命令来使Ubuntu启动到命令行界面。
|
||||
|
||||
```bash
|
||||
sudo systemctl set-default multi-user.target
|
||||
```
|
||||
|
||||
执行完这个命令以后不要忘记使用`sudo reboot`重启机器以使配置生效,并检验命令效果。
|
||||
|
||||
## 阻止Ubuntu进入休眠
|
||||
|
||||
想要阻止Ubuntu进入休眠状态,可以将用于控制休眠的服务屏蔽掉,于是可以使用以下命令。
|
||||
|
||||
```bash
|
||||
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
|
||||
```
|
||||
|
||||
当这条命令执行成功以后,可以使用以下命令来查看当前系统的休眠状态。
|
||||
|
||||
```bash
|
||||
systemctl status sleep.target
|
||||
```
|
Reference in New Issue
Block a user