转自:https://www.krizna.com/ubuntu/install-vnc-server-ubuntu-14-04/

VNC server is used to share graphical desktop which can be controlled from other computers . This guide is helpful to install VNC server on Ubuntu Desktop 14.04, Ubuntu server 14.04 and Ubuntu cloud 14.04 .
Basically ubuntu server and ubuntu cloud editions does not contains GUI, which needs to be installed before installing VNC server. Please note that server and cloud editions are carefully designed to utilize less hardware resources ( minimal environment ), installing GUI might leads to high hardware utilization.

Install gui on ubuntu server 14.04

Issue the below command to install GUI on server and cloud editions.
krizna@leela:~$ sudo apt-get install --no-install-recommends ubuntu-desktopUse –no-install-recommends key to keep GUI minimal. this will skip extra tools and apps and will install only basic desktop environment with few supported tools . Ubuntu desktop users can skip this command .

Install VNC server on ubuntu 14.04

Step 1 » Start installing below gnome packages which helps VNC to load properly . These packages are required for all editions including ubuntu desktop .
krizna@leela:~$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Step 2 » Now install vnc4server package.
krizna@leela:~$ sudo apt-get install vnc4server
Step 3 » Open /usr/bin/vncserver file and edit as follows . Before editing, make a backup copy.
krizna@leela:~$ sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
krizna@leela:~$ sudo nano /usr/bin/vncserverFind this line ( Line no:57 )
"# exec /etc/X11/xinit/xinitrcnn".and add these lines like below

1

2

3

4

5

6

"# exec /etc/X11/xinit/xinitrcnn".

"gnome-panel &n".

"gnome-settings-daemon &n".

"metacity &n".

"nautilus &n".

"gnome-terminal &n".

Step 4 » Now type the command vncserver to start VNC session. you will be prompted for creating new vnc password.
krizna@leela:~$ vncserver
You will require a password to access your desktops.
Password:******
Verify:******
xauth: file /home/boby/.Xauthority does not exist
New 'leela:1 (krizna)' desktop is leela:1
Creating default startup script /home/krizna/.vnc/xstartup
Starting applications specified in /home/krizna/.vnc/xstartup
Log file is /home/krizna/.vnc/leela:1.log

Step 5 » Now you can view your remote desktop using IP address and port ( Eg : 192.168.1.10:1 ).

That’s it, your VNC server is working.

VNC server as service

Just like centos and other flavours , you can run VNC server as service in ubuntu.
This is very helpful, as it automatically starts vnc sessions when restarting the server.
Step 6 » Create a file vncserver in /etc/init.d/ directory
krizna@leela:~$ sudo nano /etc/init.d/vncserverand add the below code .

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

#!/bin/bash

### BEGIN INIT INFO

# Provides:          VNCSERVER

# Required-Start:    $remote_fs $syslog

# Required-Stop:     $remote_fs $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start daemon at boot time

# Description:       Enable service provided by daemon.

### END INIT INFO

unset VNCSERVERARGS

VNCSERVERS=""

[ -f /etc/vncservers.conf ] && . /etc/vncservers.conf

prog=$"VNC server"

start() {

. /lib/lsb/init-functions

REQ_USER=$2

echo -n $"Starting $prog: "

ulimit -S -c 0 >/dev/null 2>&1

RETVAL=0

for display in ${VNCSERVERS}

do

export USER="${display##*:}"

if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then

echo -n "${display} "

unset BASH_ENV ENV

DISP="${display%%:*}"

export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"

su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"

fi

done

}

stop() {

. /lib/lsb/init-functions

REQ_USER=$2

echo -n $"Shutting down VNCServer: "

for display in ${VNCSERVERS}

do

export USER="${display##*:}"

if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then

echo -n "${display} "

unset BASH_ENV ENV

export USER="${display##*:}"

su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1

fi

done

echo -e "n"

echo "VNCServer Stopped"

}

case "$1" in

start)

start $@

;;

stop)

stop $@

;;

restart|reload)

stop $@

sleep 3

start $@

;;

condrestart)

if [ -f /var/lock/subsys/vncserver ]; then

stop $@

sleep 3

start $@

fi

;;

status)

status Xvnc

;;

*)

echo $"Usage: $0 {start|stop|restart|condrestart|status}"

exit 1

esac

Step 7 » Modify execute permission for the file.
krizna@leela:~$ sudo chmod +x /etc/init.d/vncserver
Step 8 » Create vncservers.conf file in /etc/ directory as stated in service code.
krizna@leela:~$ sudo nano /etc/vncservers.confand add the below lines for starting vnc session for the user krizna.

1

2

VNCSERVERS="1:krizna"

VNCSERVERARGS[1]="-geometry 1024x768"

For additional vnc users.
Login into the user
krizna@leela:~$ su - bobbyCreate VNC password by the below command . vncserver command ( step 4) is not required when starting as service .
bobby@leela:~$ vncpasswd
Password:
Verify:

Add user to the file.

1

2

3

VNCSERVERS="1:krizna 2:bobby"

VNCSERVERARGS[1]="-geometry 1024x768"

VNCSERVERARGS[2]="-geometry 1024x768"

Now user krizna can be accessed using serverip:1 ( 192.168.1.10:1 )and bobby using serverip:2 ( 192.168.1.10:2 ).
Step 9 » Issue the below command to add vncserver service to default runlevels.
krizna@leela:~$ sudo update-rc.d vncserver defaults
Step 10 » Now start/restart the service.
krizna@leela:~$ sudo /etc/init.d/vncserver start[or]
krizna@leela:~$ sudo /etc/init.d/vncserver restart

All the best.

Also see :
» Enable remote desktop ubuntu 16.04

【转】How to install VNC server on ubuntu 14.04相关推荐

  1. [原创]安全系列之端口敲门服务(Port Knocking for Ubuntu 14.04 Server)

    Port Knocking for Ubuntu 14.04 Server OS:ubuntu 14.04 server 原理简单分析: 端口敲门服务,即:knockd服务.该服务通过动态的添加ipt ...

  2. 如何在Ubuntu 14.04上使用NSD——一套仅权威DNS服务器

    提供:ZStack云计算 系列教程 本教程为DNS管理介绍系列七篇中的第七篇. 内容介绍 即使对于经验丰富的管理员而言,设置一套DNS服务器以支持域名仍是一项相当复杂的任务.DNS区管理极为重要,然而 ...

  3. 在Ubuntu 14.04和CentOS上安装boost1.55二进制包

    centos: yum install boost boost-devel boost-doc Ubuntu 14.04 sudo apt-get install libboost-dev libbo ...

  4. Ubuntu 14.04 64位安装32位兼容包

    问题描述 我的操作系统是64bit版的Ubuntu 14.04,很多32bit的软件无法安装使用,因此希望通过安装32位兼容包解决. 安装过程 在Ubuntu 13.10之前,可以通过安装 ia32- ...

  5. Ubuntu 14.04 下安装Skype聊天工具

    Ubuntu 14.04对语音啦视频等支持还是不太好,而且我们常用的通讯工具是QQ,官方给出的Linux For QQ版本在Ubuntu中显得那样脆弱,而且功能也少,所以还是需要一款可以视频聊天的工具 ...

  6. Ubuntu 14.04 设置VNC

    Ubuntu 14.04设置VNC 1.  安装vncserver # apt-get install vnc4server 2.安装gnome # apt-get install gnome-pan ...

  7. linux 内核 3.3.8,Linux内核编译 Ubuntu 14.04.3 server 升级至3.19.8

    读书笔记:,原书第3版,陈莉君 康华 译 第2章:从内核出发 2.3节:编译内核 实验: ======================================================= ...

  8. Ubuntu 14.04 搭建 L2TP Server

    搭建环境:Ubuntu 14.04 安装环境包 打开终端,输入命令 sudo apt-get install xl2tp 下载并安装xl2tpd. 若已安装,可输入 apt-get update 进行 ...

  9. ubuntu 14.04安装vnc客户端

    我的环境 电脑:thinkpad x240 操作系统:ubuntu 14.04 内核版本:3.13.0-43-generic 安装vnc客户端如下 cmss@cmss-X240~$ sudo apt- ...

最新文章

  1. Python告诉你这些旅游景点好玩、便宜、人又少!
  2. 生活问题 | 对华为畅玩手机5X进行升级
  3. 优化CSS在网页中的加载方式
  4. 【转自lzplzp】pair project总结
  5. php解析xml数据格式,PHP解析xml格式数据工具类实例分享
  6. 华为MSTP负载均衡配置示例
  7. .Net 1.1 到 .Net 2.0 开发日志
  8. python标准库——datetime模块
  9. nginx 反向代理及负载均衡
  10. PDF文件转换成excel文件的三种方法
  11. hud android,HUD | F-Droid - Free and Open Source Android App Repository
  12. FPGA学习网站推荐
  13. android辅助功能截屏,Android 截屏的三种方法
  14. python中的snip用法_Ubuntu系统中安装SNIP
  15. matlab曲线拟合
  16. 复现、修复和排查Spring RCE 0day
  17. ota升级 rk3399_Android7.1.2系统OTA升级
  18. c语言数学作业及答案,2004年9月全国计算机等级考试二级C语言笔试试题及答案...
  19. 优化性能问题的一般方法
  20. 如何使用“MRT”恶意软件删除工具

热门文章

  1. Java获取本地ip方法_Java获取本地IP方法详解
  2. docker安装mysql5.6,安装redis3.2
  3. Linux学习——echo和read命令用法
  4. QML官方系列教程——QML Applications
  5. 原生JS实现淡入淡出效果(fadeIn/fadeOut/fadeTo)
  6. 动态规划——矩阵中的最短路径长度
  7. html 常用字符,html 常用特殊字符
  8. html将excel数据自动导入到网页,如何把excel表中的数据自动输入到网页中
  9. thinkphp mysql 中文_耗时5天解决thinkphp连接mysql中文乱码的问题
  10. B. File List