Linux 如何推出一个;苏多……”;启动时自动执行命令?

Linux 如何推出一个;苏多……”;启动时自动执行命令?,linux,ubuntu,Linux,Ubuntu,我使用bluez将ubuntu与键盘和鼠标连接起来,但每次我必须重新启动计算机时,我必须在另一个键盘(USB键盘)上输入: 否则,我不能使用蓝牙设备 我想摆脱其他键盘和代码行;您知道如何在启动时自动运行此语句吗 谢谢您可以创建一个Systemd服务,在启动时运行您的命令 将此单元文件放入/etc/systemd/system中,并将其命名为“enable bluetooth.service” 然后使用systemctl enable bluetooth 您现在可以重新启动,或者只需使用syste

我使用bluez将ubuntu与键盘和鼠标连接起来,但每次我必须重新启动计算机时,我必须在另一个键盘(USB键盘)上输入:

否则,我不能使用蓝牙设备

我想摆脱其他键盘和代码行;您知道如何在启动时自动运行此语句吗


谢谢

您可以创建一个Systemd服务,在启动时运行您的命令

将此单元文件放入
/etc/systemd/system
中,并将其命名为“enable bluetooth.service”

然后使用
systemctl enable bluetooth


您现在可以重新启动,或者只需使用
systemctl start enable bluetooth

尝试一下。我已经有了ubuntu 14.04,用于此目的的好程序是update rc.d(我必须将bash文件放入/etc/init.d,然后输入“sudo update rc.d bluetooth.sh defaults”)。

,谢谢,但它不适合我:请看一下我的答案。这只适用于基于systemd的Ubuntu版本。很抱歉
sudo hciconfig hci0 up
[Unit]
Description=Enable Bluetooth

[Service]
Type=oneshot
ExecStart=hciconfig hci0 up

[Install]
WantedBy=multi-user.target