如何在启动时自动运行命令?

Ric*_*nop 0 linux ubuntu

我需要在启动时自动挂载一个共享文件夹,这样我就不必每次都手动将此行写入 xterm:

sudo mount -t vboxsf share ~/host
Run Code Online (Sandbox Code Playgroud)

我已经这样做了:

sudo crontab -e
Run Code Online (Sandbox Code Playgroud)

并在文件末尾添加:

@reboot /home/richard/mounthost
Run Code Online (Sandbox Code Playgroud)

文件 /home/richard/mounthost 包含:

sudo mount -t vboxsf share ~/host
Run Code Online (Sandbox Code Playgroud)

但它不起作用。有什么帮助吗?

我正在使用 Ubuntu 10.10

小智 5

要在启动时安装,您应该将其添加到/etc/fstab. 看看这里: