{"id":520,"date":"2019-06-01T10:59:36","date_gmt":"2019-06-01T10:59:36","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/24x7serversupport-blog\/?p=520"},"modified":"2019-06-01T10:59:36","modified_gmt":"2019-06-01T10:59:36","slug":"install-vnc-server-on-ubuntu-18","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/","title":{"rendered":"How to Install and Configure VNC on Ubuntu 18.04"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"installing-desktop-environment\"><a href=\"https:\/\/linuxize.com\/post\/how-to-install-and-configure-vnc-on-ubuntu-18-04\/#installing-desktop-environment\">Installing Desktop Environment<\/a><\/h2>\n\n\n\n<p>Most servers don\u2019t have a desktop environment installed, so we\u2019ll start by installing a lightweight desktop environment.<\/p>\n\n\n\n<p>There are several desktop environments (DE) available in Ubuntu repositories. In this tutorial we\u2019ll be installing\u00a0<a href=\"https:\/\/xfce.org\/\">Xfce<\/a>. It is fast, stable and lightweight desktop environment, which makes it ideal for usage on a remote server.<\/p>\n\n\n\n<p>First update your system with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>sudo apt update &amp;&amp; sudo apt upgrade<\/code> <\/pre>\n\n\n\n<p> Then, type the following command to install Xfce on your server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils<\/code>\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-vnc-server\"><a href=\"https:\/\/linuxize.com\/post\/how-to-install-and-configure-vnc-on-ubuntu-18-04\/#installing-vnc-server\">Installing VNC Server<\/a><\/h2>\n\n\n\n<p>There are also several different VNC servers available in Ubuntu repositories such as&nbsp;<a href=\"https:\/\/www.tightvnc.com\/\">TightVNC<\/a>,&nbsp;<a href=\"http:\/\/tigervnc.org\/\">TigerVNC<\/a>&nbsp;and&nbsp;<a href=\"http:\/\/www.karlrunge.com\/x11vnc\/\">x11vnc<\/a>. Each VNC server has different strengths and weaknesses in terms of speed and security.<\/p>\n\n\n\n<p>We\u2019ll be installing TigerVNC, which is actively maintained high-performance VNC server.<\/p>\n\n\n\n<p>Type the following command to install TigerVNC on your Ubuntu server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code>sudo apt install tigervnc-standalone-server tigervnc-common<\/code><\/pre>\n\n\n\n<p> Now that the VNC server is installed the next step is to run the\u00a0<code>vncserver<\/code>\u00a0command which will create the initial configuration and set up the password. Do not use sudo when running the following command: <\/p>\n\n\n\n<p>vncserver<\/p>\n\n\n\n<p> You will be prompted to enter and confirm the password and whether to set it as a view-only password. If you choose to set up a view-only password the user will not be able to interact with the VNC instance with the mouse and the keyboard. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">You will require a password to access your desktops.\n Password:\n Verify:\n Would you like to enter a view-only password (y\/n)? n\n \/usr\/bin\/xauth:  file \/home\/linuxize\/.Xauthority does not exist\n New 'server2.linuxize.com:1 (linuxize)' desktop at :1 on machine server2.linuxize.com\n Starting applications specified in \/etc\/X11\/Xvnc-session\n Log file is \/home\/linuxize\/.vnc\/server2.linuxize.com:1.log\n Use xtigervncviewer -SecurityTypes VncAuth -passwd \/home\/linuxize\/.vnc\/passwd :1 to connect to the VNC server.<\/pre>\n\n\n\n<p>The first time the&nbsp;<code>vncserver<\/code>&nbsp;command is run, it will create and store the password file in the&nbsp;<code>~\/.vnc<\/code>&nbsp;directory which will be created if not present.<\/p>\n\n\n\n<p>Note the&nbsp;<code>:1<\/code>&nbsp;after the&nbsp;<a href=\"https:\/\/linuxize.com\/post\/how-to-change-hostname-on-ubuntu-18-04\/\">hostname<\/a>&nbsp;in the output above. This indicates the display port number on which the vnc server is running. In our case, the server is running on TCP port&nbsp;<code>5901<\/code>&nbsp;(5900+1). If you create a second instance with&nbsp;<code>vncserver<\/code>&nbsp;it will run on the next free port i.e&nbsp;<code>:2<\/code>&nbsp;that means that the server is running on port&nbsp;<code>5902<\/code>&nbsp;(5900+2).<\/p>\n\n\n\n<p>What is important to remember is that when working with VNC servers,\u00a0<code>:X<\/code>\u00a0is a display port that refers to\u00a0<code>5900+X<\/code>.<\/p>\n\n\n\n<p> Before continuing with the next step, first stop the VNC instance using the\u00a0<code>vncserver<\/code>command with a\u00a0<code>-kill<\/code>\u00a0option and the server number as an argument. In our case the server is running in port 5901 (<code>:1<\/code>), so we\u2019ll stop it with: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vncserver -kill :1<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Killing Xtigervnc process ID 7264\u2026 success!<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring-vnc-server\"><a href=\"https:\/\/linuxize.com\/post\/how-to-install-and-configure-vnc-on-ubuntu-18-04\/#configuring-vnc-server\">Configuring VNC Server<\/a><\/h2>\n\n\n\n<p> Now that we have both Xfce and TigerVNC installed on our server we need to configure TigerVNC to use Xfce. To do so create the following file: <\/p>\n\n\n\n<p>nano ~\/.vnc\/xstartup<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">!\/bin\/sh\n unset SESSION_MANAGER\n unset DBUS_SESSION_BUS_ADDRESS\n exec startxfce4 <\/pre>\n\n\n\n<p>Save and close the file. The commands above will be automatically executed whenever you start or restart the TigerVNC server.<\/p>\n\n\n\n<p>The\u00a0<code>~\/.vnc\/xstartup<\/code>\u00a0file also needs to have execute permissions. Run the following command to make sure permissions are correct:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chmod u+x ~\/.vnc\/xstartup<\/pre>\n\n\n\n<p> If you need to pass\u00a0<a href=\"http:\/\/tigervnc.org\/doc\/vncserver.html\">addition options<\/a>\u00a0to the VNC server you can create a file named\u00a0<code>config<\/code>and add one option per line. Here is an example: <\/p>\n\n\n\n<p>geometry=1920&#215;1084<br \/> dpi=96<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-a-systemd-unit-file\"><a href=\"https:\/\/linuxize.com\/post\/how-to-install-and-configure-vnc-on-ubuntu-18-04\/#creating-a-systemd-unit-file\">Creating a Systemd unit file<\/a><\/h2>\n\n\n\n<p> We\u2019ll create a systemd unit file which will enable us to easily start, stop, and restart the VNC service as needed, same as any other systemd service. <\/p>\n\n\n\n<p> Open your text editor and copy and paste the following configuration into it. Make sure to change the username in line 7 to match your username. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/systemd\/system\/vncserver@.service<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[Unit]\n Description=Remote desktop service (VNC)\n After=syslog.target network.target\n [Service]\n Type=simple\n User=linuxize\n PAMName=login\n PIDFile=\/home\/%u\/.vnc\/%H%i.pid\n ExecStartPre=\/bin\/sh -c '\/usr\/bin\/vncserver -kill :%i > \/dev\/null 2>&amp;1 || :'\n ExecStart=\/usr\/bin\/vncserver :%i -geometry 1440x900 -alwaysshared -fg\n ExecStop=\/usr\/bin\/vncserver -kill :%i\n [Install]\n WantedBy=multi-user.target<\/pre>\n\n\n\n<p>Save and close the file.<\/p>\n\n\n\n<p>Notify systemd that we created a new unit file with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl daemon-reload<\/pre>\n\n\n\n<p>The next step is to enable the unit file with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl enable vncserver@1.service<\/pre>\n\n\n\n<p>The number&nbsp;<code>1<\/code>&nbsp;after the&nbsp;<code>@<\/code>&nbsp;sign defines the display port on which the VNC service will run. This means that the VNC server will listen on port&nbsp;<code>5901<\/code>, as we discussed in the previous section.<\/p>\n\n\n\n<p>Start the VNC service by executing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl start vncserver@1.service<\/pre>\n\n\n\n<p>Verify that the service is successfully started with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl status vncserver@1.service<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\u25cf vncserver@1.service - Remote desktop service (VNC)\n    Loaded: loaded (\/etc\/systemd\/system\/vncserver@.service; indirect; vendor preset: enabled)\n    Active: active (running) since Thu 2018-08-16 19:05:54 UTC; 4s ago\n   Process: 9893 ExecStartPre=\/bin\/sh -c \/usr\/bin\/vncserver -kill :1 > \/dev\/null 2>&amp;1 || : (code=exited, status=0\/SUCCESS)\n  Main PID: 9900 (vncserver)\n     Tasks: 0 (limit: 507)\n    CGroup: \/system.slice\/system-vncserver.slice\/vncserver@1.service\n            \u2023 9900 \/usr\/bin\/perl \/usr\/bin\/vncserver :1 -geometry 1440x900 -alwaysshared -fg<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"connecting-to-vnc-server\"><a href=\"https:\/\/linuxize.com\/post\/how-to-install-and-configure-vnc-on-ubuntu-18-04\/#connecting-to-vnc-server\">Connecting to VNC server<\/a><\/h2>\n\n\n\n<p>VNC is not an encrypted protocol and can be subject to packet sniffing. The recommended approach is to create an SSH tunnel that will securely forwards traffic from your local machine on port 5901 to the server on the same port.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing Desktop Environment Most servers don\u2019t have a desktop environment installed, so we\u2019ll start by installing a lightweight desktop environment. There are several desktop environments (DE) available in Ubuntu repositories. In this tutorial we\u2019ll be installing\u00a0Xfce. It is fast, stable and lightweight desktop environment, which makes it ideal for usage on a remote server. First [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[83,134,135],"class_list":["post-520","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ubuntu","tag-ubuntu-18","tag-vnc"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog<\/title>\n<meta name=\"description\" content=\"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-01T10:59:36+00:00\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/\",\"name\":\"How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"datePublished\":\"2019-06-01T10:59:36+00:00\",\"dateModified\":\"2019-06-01T10:59:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"description\":\"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18\",\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install and Configure VNC on Ubuntu 18.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog","description":"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/","og_locale":"en_US","og_type":"article","og_title":"How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog","og_description":"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18","og_url":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/","og_site_name":"24x7serversupport Blog","article_published_time":"2019-06-01T10:59:36+00:00","author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/","url":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/","name":"How to Install and Configure VNC on Ubuntu 18.04 | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"datePublished":"2019-06-01T10:59:36+00:00","dateModified":"2019-06-01T10:59:36+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"description":"How to install VNC server on Ubuntu 18, Commands to install VNC server on Ubuntu 18, Steps to install VNC server on Ubuntu 18","breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/install-vnc-server-on-ubuntu-18\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install and Configure VNC on Ubuntu 18.04"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=520"}],"version-history":[{"count":0,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/520\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}