centos 开启VNC
2016-04-02 10:43
519 查看
安装软件包(有yum源安装的,不采用源码安装)
安装成功后,配置如下:
修改配置文件:
vim ~/.vnc/xstartup (最后两行)
vim /etc/sysconfig/vncservers (最后两行)
vi /etc/sysconfig/iptables (配置防火墙)
启动服务
关闭vnc
连接
yum -y install vnc vnc-server
安装成功后,配置如下:
[root@localhost ~]# vncserver #设置 VNC密码,输入:(在某用户下输入则登陆用户就是它,如果su imiss切换到imiss用户,输入vncserver则启动的是另一个桌面,同样要设置密码,以后在该账户下启动的vncserver登陆就需要在此用户下设置的密码了。) You will require a password to access your desktops. Password: Password must be at least 6 characters - try again Password: Verify: xauth: creating new authority file /root/.Xauthority New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1 Creating default startup script /root/.vnc/xstartup Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/localhost.localdomain:1.log [root@localhost ~]# vncpasswd Password: Password must be at least 6 characters - try again Password: Verify: [root@localhost ~]#
修改配置文件:
vim ~/.vnc/xstartup (最后两行)
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & gnome-session &
vim /etc/sysconfig/vncservers (最后两行)
# VNCSERVERS="2:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost" VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 800x600"
vi /etc/sysconfig/iptables (配置防火墙)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5903 -j ACCEPT #VNC server 监听的端口从 5900 开始,display:1 的监听 5901,display:2 监听 5902,以此类推。CentOS 的防火墙缺省是不允许连接这些端口的,所以需要使用下面的步骤打开防火墙(需要 root 权限):
[root@localhost ~]# service iptables restart iptables: Setting chains to policy ACCEPT: nat mangle filte[ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ]
启动服务
[root@localhost ~]# chkconfig vncserver on [root@localhost ~]# service vncserver start Starting VNC server: 2:root New 'localhost.localdomain:2 (root)' desktop is localhost.localdomain:2 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/localhost.localdomain:2.log [ OK ] [root@localhost ~]#
关闭vnc
vncserver -kill :2 #注意kill后面要有一个空格
连接
相关文章推荐
- Centos 32位兼容库安装
- Linux系统编程——进程间通信:命名管道(FIFO)
- Linux常考指令(更新中)
- xclip 操作Linux剪切板
- Linux SD卡驱动开发(四) —— SD 控制器之真正的硬件操作
- Linux initramfs
- 关于Linux 下kill 与 pause的一些小思考
- (OK) install—batman-adv—batctl—CentOS7
- (OK) 运行cBPM—CentOS7
- (OK) CentOS7—mp4—avi—视频播放—SMPlayer
- Linux SD卡驱动开发(三) —— SD 卡驱动分析CORE篇
- ECS Centos7 安装MATE Desktop图形化桌面
- Linux内核分析之六——进程的描述与进程的创建
- linux——单网卡配置双(多)ip
- Linux中使用SecureCRT上传、下载文件命令sz与rz用法实例
- tar.xz解压缩
- linux socket c : send data when socket close—SIGPIPE, Broken pipe
- (OK) Linux epoll模型—socket epoll server client chat—pthread
- Linux学习心得
- who|sort实现