Monday, July 28, 2014

How to configure VNC server in Ubuntu 12.04

Install Gnome basic desktop.

sudo apt-get install gnome-core
 
when prompted type Y and then press Enter. This will install the gnome desktop components.
Reboot
 
sudo reboot now -h

To keep the desktop and login window from opening in Ubuntu everytime it starts we want to mask out the few lines which start the service.
 
sudo vim /etc/init/gdm.conf

The first few lines of the script should look like this once you've edited it:
 
# gdm - GNOME Display Manager
#
# The display manager service manages the X servers running on the
# system, providing login and auto-login services

description "GNOME Display Manager"
author "William Jon McCann <mccann@jhu.edu>"

#start on ((filesystem
# and runlevel [!06]
# and started dbus
# and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
# or stopped udev-fallback-graphics))
# or runlevel PREVLEVEL=S)

stop on runlevel [016]

emits login-session-start

esc :wq to save the changes or :q! to start over. Now the desktop and login won't start in Ubuntu.

NOTE: This only installs a basic desktop, if you want to be able to use programs from your virtual desktop, network manager, media players, office, etc, they will need to be installed after vnc server is installed.

Reboot
 
sudo reboot now -h

We need to install VNC server to be able to interact with the gnome components for the desktop.
 
sudo apt-get install vnc4server

When prompted type Y and press Enter. This will install VNC Server which is required for running a virtual desktop on another machine.

Next type:
 
vncserver

You'll then be prompted to create and verify a new password.
We now need to kill the session we just created and make change the startup script for VNCServer to make it work properly.

So, type the following command to kill the session:
 
vncserver -kill :1

Now type the following command to open up the file we need to edit:
 
sudo vim .vnc/xstartup

Change it to look like this:
 
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
gnome-session --session=gnome-classic &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 1280x1024+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &

 When you're done editing the file press the Esc key once and type :wq
This should save the changes and bring you back to the command line. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.

Next type the following command to create the VNC Session once more:
 
vncserver -geometry 1366x750

Now you can access the ubuntu box using:

ubuntubox.example.com:1

Cheers

Thursday, July 24, 2014

How to change Local Time zone and configure NTP



If you want to set time yourself try the following command:

date 07241503

where 07 is month, 24 is date, 15 is hour and 03 is minute.

Or if you want to use NTP server, use the following command to synchronize:

ntpdate  0.centos.pool.ntp.org

If ntp server is taking wrong time because of wrong time zone, then you can easily check timezone.

service ntpd stop

cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime 


ntpdate  0.centos.pool.ntp.org


service ntpd start

chkconfig ntpd on

:)


Thanks,
(The above is tested on CentOS 6.5 - Suitable for CentOS 5,6,6.x and RHEL5,6,6.x)