Setting up VNC for Ubuntu 16.04 LTS

Hi Experts,

My server is Ubuntu 16.04 LTS.
I am following the steps of to set up the VNC server.
However, I fail in the last step like below. Can you please help me with this VNC configuration.

hsu@hcavfb11:~$ sudo systemctl status vncserver@1
● vncserver@1.service - Start TightVNC server at startup
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2017-11-24 10:31:34 JST; 18min ago

Nov 24 10:31:34 hcavfb11 systemd[1]: Starting Start TightVNC server at startup...
Nov 24 10:31:34 hcavfb11 systemd[1]: vncserver@1.service: Control process exited, code=exited status=217
Nov 24 10:31:34 hcavfb11 systemd[1]: Failed to start Start TightVNC server at startup.
Nov 24 10:31:34 hcavfb11 systemd[1]: vncserver@1.service: Unit entered failed state.
Nov 24 10:31:34 hcavfb11 systemd[1]: vncserver@1.service: Failed with result 'exit-code'.

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pallavi GodseSr. Digital Marketing ExecutiveCommented:
The last step is creating a VNC Service File as below -

Set up the VNC server as a systemd service. This will make it possible to start, stop, and restart it as needed, like any other systemd service.

First, create a new unit file called

Open in new window

using your favorite text editor:

sudo nano /etc/systemd/system/vncserver@.service

Open in new window

Copy and paste the following into it. Be sure to change the value of User and the username in the value of PIDFILE to match your username.

Description=Start TightVNC server at startup

ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i


Open in new window

Save and close the file.

Next, make the system aware of the new unit file.

 $   sudo systemctl daemon-reload

Open in new window

Enable the unit file.

  $  sudo systemctl enable vncserver@1.service

Open in new window

Stop the current instance of the VNC server if it's still running.

$   vncserver -kill :1

Open in new window

Then start it as you would start any other systemd service.
 $   sudo systemctl start vncserver@1

Open in new window

You can verify that it started with this command:

$  sudo systemctl status vncserver@1

Open in new window

If it started correctly, the output should look like this:


vncserver@1.service - TightVNC server on Ubuntu 16.04
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-04-25 03:21:34 EDT; 6s ago
  Process: 2924 ExecStop=/usr/bin/vncserver -kill :%i (code=exited, status=0/SUCCESS)


 systemd[1]: Starting TightVNC server on Ubuntu 16.04...
 systemd[2938]: pam_unix(login:session): session opened for user finid by (uid=0)
 systemd[2949]: pam_unix(login:session): session opened for user finid by (uid=0)
 systemd[1]: Started TightVNC server on Ubuntu 16.04.

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rmtogetherAuthor Commented:
thank you so much for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.