ubuntu20.04软件开机自启动
时间: 2023-09-03 13:15:33 浏览: 127
在Ubuntu 20.04中,你可以使用以下步骤来设置软件开机自启动:
1. 打开终端,使用以下命令安装“gnome-startup-applications”:
```
sudo apt-get install gnome-startup-applications
```
2. 安装完成后,启动“启动应用程序首选项”窗口,你可以使用以下命令启动:
```
gnome-session-properties
```
3. 点击“添加”按钮,输入应用程序的名称、命令和注释。例如,如果你想在开机时启动Firefox浏览器,则可以输入以下信息:
```
名称:Firefox
命令:firefox
注释:启动Firefox浏览器
```
4. 点击“添加”按钮后,你将在“启动应用程序首选项”窗口中看到新添加的应用程序。现在,重新启动计算机,应用程序将自动启动。
注意:在Ubuntu 20.04中,也可以将启动脚本放在“/etc/init.d/”或“/etc/rc.local”目录中来实现开机自启动。但是,这种方法已经不推荐使用了,因为Ubuntu 20.04使用了systemd来管理服务。
相关问题
ubuntu 20.04 vncserver 开机自启动
您可以按照以下步骤实现Ubuntu 20.04 VNC服务器开机自启动:
1. 在终端中输入命令:sudo nano /etc/systemd/system/vncserver@.service
2. 在文件中输入以下内容:
[Unit]
Description=VNC Server on %H
After=syslog.target network.target
[Service]
Type=forking
User=YOUR_USERNAME
Group=YOUR_USERNAME
WorkingDirectory=/home/YOUR_USERNAME
PIDFile=/home/YOUR_USERNAME/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver %i -geometry 1920x1080 -depth 24 -localhost
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
3. 将 YOUR_USERNAME 替换为您的实际用户名。
4. 保存并退出文件(CTRL+X,输入“Y”并按下Enter键)。
5. 在终端中输入以下命令以启用服务:sudo systemctl daemon-reload
6. 启用跟随开机自启:sudo systemctl enable vncserver@1.service
7. 重新启动计算机以确保服务已成功启动:sudo reboot
现在,VNC服务器应该在您的Ubuntu 20.04计算机开机时自动启动。
ubuntu 20.04设置开机自启动
Ubuntu 20.04的服务管理是基于systemd的,因此设置服务自启动最推荐的方法是创建一个systemd服务文件,配置好要执行的服务。具体步骤如下:
1. 创建一个.service文件,例如:sudo vim /etc/systemd/system/my_service.service
2. 在文件中添加以下内容:
```
[Unit]
Description=My Service
After=network.target
[Service]
ExecStart=/path/to/my_service
Restart=always
[Install]
WantedBy=multi-user.target
```
其中,Description是服务的描述,After指定服务启动的时间,ExecStart指定服务启动时要执行的命令,Restart指定服务异常退出时是否重启,WantedBy指定服务启动的级别。
3. 保存文件并退出,然后执行以下命令使服务生效:
```
sudo systemctl daemon-reload
sudo systemctl enable my_service.service
sudo systemctl start my_service.service
```
如果你想使用rc.local来设置开机自启动,可以按照以下步骤进行操作:
1. 创建rc.local文件:sudo vim /etc/rc.local
2. 在文件中添加要执行的命令,例如:
```
#!/bin/bash
/path/to/my_service &
exit 0
```
其中,&符号表示在后台运行,exit 0表示正常退出。
3. 保存文件并退出,然后执行以下命令使rc.local生效:
```
sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local.service
sudo systemctl start rc-local.service
```
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)