{"id":38,"date":"2016-04-01T20:24:12","date_gmt":"2016-04-01T20:24:12","guid":{"rendered":"https:\/\/pure-media.info\/?p=38"},"modified":"2017-04-06T03:53:13","modified_gmt":"2017-04-06T03:53:13","slug":"how-to-install-vnc-server-on-ubuntu-14-04","status":"publish","type":"post","link":"https:\/\/pure-media.info\/index.php\/2016\/04\/01\/how-to-install-vnc-server-on-ubuntu-14-04\/","title":{"rendered":"How to install VNC Server on Ubuntu 14.04+"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/pure-media.info\/wp-content\/uploads\/2016\/04\/Ubuntu-Logo.png?ssl=1\" rel=\"attachment wp-att-39\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"39\" data-permalink=\"https:\/\/pure-media.info\/index.php\/2016\/04\/01\/how-to-install-vnc-server-on-ubuntu-14-04\/ubuntu-logo\/\" data-orig-file=\"https:\/\/i0.wp.com\/pure-media.info\/wp-content\/uploads\/2016\/04\/Ubuntu-Logo.png?fit=500%2C343&amp;ssl=1\" data-orig-size=\"500,343\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Ubuntu-Logo\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/pure-media.info\/wp-content\/uploads\/2016\/04\/Ubuntu-Logo.png?fit=300%2C206&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/pure-media.info\/wp-content\/uploads\/2016\/04\/Ubuntu-Logo.png?fit=500%2C343&amp;ssl=1\" class=\"aligncenter size-full wp-image-39\" src=\"https:\/\/i0.wp.com\/pure-media.info\/wp-content\/uploads\/2016\/04\/Ubuntu-Logo.png?resize=500%2C343&#038;ssl=1\" alt=\"Ubuntu-Logo\" width=\"500\" height=\"343\"><\/a><\/p>\n<p>This Guide will show you how to Install a GUI or Desktop on a Headless\/Server machine. This will work with ubuntu 14.04+<\/p>\n<p>As usual I always update my system before I install anything. It&rsquo;s a good practice to keep our servers\/machines secured also<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">apt-get update &amp;&amp; apt-get upgrade<\/code><\/p>\n<p>&nbsp;<\/p>\n<h3>Install GUI Desktop<\/h3>\n<p>I&rsquo;m using Ubuntu 14.04 64-bit Server for this tutorial so I will install a GUI of my choice, XFCE is always my favorite Desktop Environment. You can install other but for the shake of this tutorial I will just use XFCE.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">apt-get install xubuntu-desktop xfce4 firefox nano<\/code><\/p>\n<p>&nbsp;<\/p>\n<h3>Install VNC Server on Ubuntu 14.04<\/h3>\n<p>Installing VNC Server on Ubuntu 14.04 is simple, but configuration is a different&nbsp;story.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">apt-get install vnc4server<\/code><\/p>\n<p>&nbsp;<\/p>\n<h3>Configure VNC Server to work on Ubuntu<\/h3>\n<p><strong>Adding&nbsp;VNC User<\/strong><br \/>\nYou can always run your system with root, but it&rsquo;s not a good security practice. If you have a regular\/privileged user, you can skip this step. If you are using root, I strongly recommend you to create a regular\/privileged user and use this user rather than root. For the purpose of this tutorial, I&rsquo;m creating &ldquo;puremedia&rdquo; user, but you can choose whatever user\/username you want to use or even your exiting privileged user.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">adduser puremedia<\/code><\/p>\n<p>Lets let them add them to the sudo list to allow for installing and updating applications<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">adduser puremedia sudo<\/code><\/p>\n<p>Now lets login as that user to generate the default configuration for VNC<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">su&nbsp;puremedia<\/code><\/p>\n<p>Lets start VNCserver as this user<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">vncserver<\/code><\/p>\n<p>First time you startup vncserver, you will be asked to provide vnc&rsquo;s password to access to your VNC Server. This password can be the same as your user&rsquo;s password or different, it&rsquo;s up to you but I highly recommend you to set this password different to your user&rsquo;s password for better security measure.<\/p>\n<p>The next step is to turn off vncserver to modify the xstartup file (startup script) to make vncserver start with xfce4 (we installed xfce4 for this tutorial)<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">vncserver -kill :1<\/code><\/p>\n<p>Now lets edit the xstartup for vncserver<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">cd <\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">nano .vnc\/xstartup<\/code><\/p>\n<p>This is the original configuration file<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"atomic\" data-enlighter-title=\"Original Configuration \">#!\/bin\/sh\r\n \r\n# Uncomment the following two lines for normal desktop:\r\n# unset SESSION_MANAGER\r\n# exec \/etc\/X11\/xinit\/xinitrc\r\n \r\n[ -x \/etc\/vnc\/xstartup ] &amp;&amp; exec \/etc\/vnc\/xstartup\r\n[ -r $HOME\/.Xresources ] &amp;&amp; xrdb $HOME\/.Xresources\r\nxsetroot -solid grey\r\nvncconfig -iconic &amp;\r\nx-terminal-emulator -geometry 80x24+10+10 -ls -title \"$VNCDESKTOP Desktop\" &amp;\r\nx-window-manager &amp;<\/pre>\n<p>What you need to do is to uncomment two lines &ldquo;unset SESSION_MANAGER&rdquo; and &ldquo;exec \/etc\/X11\/xinit\/xinitrc&rdquo;, then add &ldquo;startxfce4 &amp;&rdquo; to the file. The modified xstartup file should look like this<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"atomic\" data-enlighter-title=\"Modified Configuration\">#!\/bin\/sh\r\n \r\n# Uncomment the following two lines for normal desktop:\r\nunset SESSION_MANAGER\r\nexec \/etc\/X11\/xinit\/xinitrc\r\n \r\nstartxfce4 &amp;\r\n \r\n[ -x \/etc\/vnc\/xstartup ] &amp;&amp; exec \/etc\/vnc\/xstartup\r\n[ -r $HOME\/.Xresources ] &amp;&amp; xrdb $HOME\/.Xresources\r\nxsetroot -solid grey\r\nvncconfig -iconic &amp;\r\nx-terminal-emulator -geometry 80x24+10+10 -ls -title \"$VNCDESKTOP Desktop\" &amp;\r\nx-window-manager &amp;<\/pre>\n<p>Save xstartup when you are done.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">CTRL + X<\/code><\/p>\n<h3>Create VNC Server statup script<\/h3>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo nano \/etc\/init.d\/vncserver<\/code><\/p>\n<p>Now add<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"atomic\">#!\/bin\/bash\r\n### BEGIN INIT INFO\r\n# Provides:          tightvncserver\r\n# Required-Start:    $syslog\r\n# Required-Stop:     $syslog\r\n# Default-Start:     2 3 4 5\r\n# Default-Stop:      0 1 6\r\n# Short-Description: vncserver\r\n#\r\n### END INIT INFO\r\n \r\nunset VNCSERVERARGS\r\nVNCSERVERS=\"\"\r\n[ -f \/etc\/vncserver\/vncservers.conf ] &amp;&amp; . \/etc\/vncserver\/vncservers.conf\r\nprog=$\"VNC server\"\r\nstart() {\r\n. \/lib\/lsb\/init-functions\r\nREQ_USER=$2\r\necho -n $\"Starting $prog: \"\r\nulimit -S -c 0 &gt;\/dev\/null 2&gt;&amp;1\r\nRETVAL=0\r\nfor display in ${VNCSERVERS}\r\ndo\r\nexport USER=\"${display##*:}\"\r\nif test -z \"${REQ_USER}\" -o \"${REQ_USER}\" == ${USER} ; then\r\necho -n \"${display} \"\r\nunset BASH_ENV ENV\r\nDISP=\"${display%%:*}\"\r\nexport VNCUSERARGS=\"${VNCSERVERARGS[${DISP}]}\"\r\nsu ${USER} -c \"cd ~${USER} &amp;&amp; [ -f .vnc\/passwd ] &amp;&amp; vncserver :${DISP} ${VNCUSERARGS}\"\r\nfi\r\ndone\r\n}\r\nstop() {\r\n. \/lib\/lsb\/init-functions\r\nREQ_USER=$2\r\necho -n $\"Shutting down VNCServer: \"\r\nfor display in ${VNCSERVERS}\r\ndo\r\nexport USER=\"${display##*:}\"\r\nif test -z \"${REQ_USER}\" -o \"${REQ_USER}\" == ${USER} ; then\r\necho -n \"${display} \"\r\nunset BASH_ENV ENV\r\nexport USER=\"${display##*:}\"\r\nsu ${USER} -c \"vncserver -kill :${display%%:*}\" &gt;\/dev\/null 2&gt;&amp;1\r\nfi\r\ndone\r\necho -e \"n\"\r\necho \"VNCServer Stopped\"\r\n}\r\ncase \"$1\" in\r\nstart)\r\nstart $@\r\n;;\r\nstop)\r\nstop $@\r\n;;\r\nrestart|reload)\r\nstop $@\r\nsleep 3\r\nstart $@\r\n;;\r\ncondrestart)\r\nif [ -f \/var\/lock\/subsys\/vncserver ]; then\r\nstop $@\r\nsleep 3\r\nstart $@\r\nfi\r\n;;\r\nstatus)\r\nstatus Xvnc\r\n;;\r\n*)\r\necho $\"Usage: $0 {start|stop|restart|condrestart|status}\"\r\nexit 1\r\nesac<\/pre>\n<p>Let enable this file to execute<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo chmod +x \/etc\/init.d\/vncserver<\/code><\/p>\n<h3>&nbsp;Create VNC Server configuration file<\/h3>\n<p>We are going to create vncservers.conf file in \/etc\/vncserver directory to set VNC&rsquo;s port, screen&nbsp;resolution for each user.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">mkdir -p \/etc\/vncserver <\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">nano \/etc\/vncserver\/vncservers.conf<\/code><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-theme=\"atomic\"># VNC port:user\r\n# 1 for port 1 and 5901, 2 for port 2 and 5902, 3 for port 3 and 5903, and so on\r\nVNCSERVERS=\"1:puremedia\"\r\n \r\n# VNC screen resolution\r\n#GEOMETRY=\"&lt;WIDTH&gt;x&lt;HEIGHT&gt;\"\r\nVNCSERVERARGS[1]=\"-geometry 1024x768\"\r\n \r\n# Color depth (choose 8, 16, or 32)\r\nDEPTH=\"32\"<\/pre>\n<p>Save again<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">CTRL + X<\/code><\/p>\n<h3>&nbsp;Set VNC to start on boot<\/h3>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">update-rc.d vncserver defaults 99<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Guide will show you how to Install a GUI or Desktop on a Headless\/Server machine. This will work with<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[85],"tags":[12,31,28,29,10,4,11,5,9,8,7,27,30],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-tech-tip","tag-create","tag-debian","tag-desktop","tag-gui","tag-install","tag-server","tag-setup","tag-ssh","tag-tahr","tag-trusty","tag-ubuntu","tag-vnc","tag-xfce"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/p7oBs4-C","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pure-media.info\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}