Software & AppsOperating SystemLinux

Starting VNC Server on Boot in Ubuntu

Ubuntu 9

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.

Quick Answer

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:

  1. Install the TightVNC server by running the following command in your terminal:
sudo apt-get install tightvncserver
  1. Set up the VNC server for the desired user by running vncserver and setting a password.
  2. Modify the ~/.vnc/xstartup file to specify the programs or session to launch when the VNC session starts.
  3. Copy the provided script into /etc/init.d/vncserver and make it executable with the following command:
sudo chmod +x /etc/init.d/vncserver
  1. 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:

  1. Edit the /etc/rc.local file and add the command to start the VNC server before the exit 0 line.
  2. 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:

  1. Open the crontab file by running the following command:
crontab -e
  1. 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.
  2. 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:

  1. Create a service unit file under /lib/systemd/system/x11vnc.service with the appropriate commands to start the VNC server.
  2. Reload the service with the following command:
sudo systemctl daemon-reload
  1. 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.

What is the purpose of a VNC server?

A VNC server allows remote access to a computer’s desktop, enabling users to control the computer from another device.

Which VNC server software can I use on Ubuntu?

There are various VNC server software options available for Ubuntu, such as x11vnc and TightVNC.

Do I need sudo privileges to start a VNC server on boot?

Yes, sudo privileges are required to install and configure the VNC server software, as well as to modify system files.

How do I specify the programs or session to launch when the VNC session starts?

You can modify the ~/.vnc/xstartup file and specify the desired programs or session to launch when the VNC session starts.

Can I use the rc.local file to start a VNC server on boot in Ubuntu?

Yes, you can edit the /etc/rc.local file and add the command to start the VNC server before the exit 0 line.

What is cron and how can I use it to start a VNC server on boot?

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.

Can I use systemd to start a VNC server on boot in Ubuntu?

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.

Leave a Comment

Your email address will not be published. Required fields are marked *