
In the world of Ubuntu, having remote access to your server can be incredibly useful. One common method of achieving this is by using a Virtual Network Computing (VNC) server. This article will provide a detailed guide on how to start a VNC server on boot in Ubuntu.
To start a VNC server on boot in Ubuntu, you can use methods such as using the init.d script, modifying the rc.local file, using cron, or utilizing systemd (for Ubuntu 15.04 or later). These methods allow you to automatically start a VNC server every time your Ubuntu system boots up, providing remote access to your server.
What is a VNC Server?
A VNC server is a program that shares a desktop with other computers over the internet. You can control a computer running a VNC server from anywhere in the world using a VNC client on another computer.
Prerequisites
Before we start, make sure you have the following:
- An Ubuntu server
- A user with sudo privileges
- A VNC server software installed (like x11vnc or TightVNC)
Method 1: Using the init.d script
The init.d directory contains a series of start/stop scripts for various services on your system. Here’s how to use it to start your VNC server on boot:
- Install the TightVNC server by running the following command in your terminal:
sudo apt-get install tightvncserver
- Set up the VNC server for the desired user by running
vncserver
and setting a password. - Modify the
~/.vnc/xstartup
file to specify the programs or session to launch when the VNC session starts. - Copy the provided script into
/etc/init.d/vncserver
and make it executable with the following command:
sudo chmod +x /etc/init.d/vncserver
- Connect to the server using a VNC client on port 590X, where X is the value of “DISPLAY” in the vncserver script.
Method 2: Using the rc.local file
The rc.local file is a script that runs on every boot of your Ubuntu system. Here’s how to use it to start your VNC server:
- Edit the
/etc/rc.local
file and add the command to start the VNC server before theexit 0
line. - Make sure the file has executable permissions by running the following command:
sudo chmod +x /etc/rc.local
Method 3: Using cron
Cron is a time-based job scheduler in Unix-like operating systems. Here’s how to use it to start your VNC server on boot:
- Open the crontab file by running the following command:
crontab -e
- Add the line
@reboot /usr/bin/vncserver :1
to the file. This command tells cron to run the vncserver command every time the system reboots. - Save and exit the crontab file.
Method 4: Using systemd (for Ubuntu 15.04 or later)
Systemd is a system and service manager for Linux. It’s the default init system for most Linux distributions, including Ubuntu 15.04 and later. Here’s how to use it to start your VNC server on boot:
- Create a service unit file under
/lib/systemd/system/x11vnc.service
with the appropriate commands to start the VNC server. - Reload the service with the following command:
sudo systemctl daemon-reload
- Enable the service to start on boot with the following command:
sudo systemctl enable x11vnc.service
Conclusion
Starting a VNC server on boot in Ubuntu can be achieved in a few different ways. Depending on your specific setup and version of Ubuntu, you might find one method more suitable than the others. Regardless of the method you choose, the end result is the same: you’ll have a VNC server that starts automatically every time your Ubuntu system boots up.
A VNC server allows remote access to a computer’s desktop, enabling users to control the computer from another device.
There are various VNC server software options available for Ubuntu, such as x11vnc and TightVNC.
Yes, sudo privileges are required to install and configure the VNC server software, as well as to modify system files.
You can modify the ~/.vnc/xstartup
file and specify the desired programs or session to launch when the VNC session starts.
Yes, you can edit the /etc/rc.local
file and add the command to start the VNC server before the exit 0
line.
Cron is a time-based job scheduler. You can use it to start a VNC server on boot by adding a command to the crontab file using the @reboot
directive.
Yes, if you are using Ubuntu 15.04 or later, you can create a service unit file and use systemd to start the VNC server on boot.