Change the hostname on a running system
(http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/)
On any Linux system you can change its hostname with the command ‘hostname‘ (surprised?)… Here are some quick usages of the command line hostname:
hostname
without any parameter it will output the current hostname of the system.
hostname --fqd
it will output the fully qualified domain name (or FQDN) of the system.
hostname NEW_NAME
will set the hostname of the system to NEW_NAME. This is active right away and will remain like that until the system will be rebooted (because at system boot it will set this from some particular file configurations – see bellow how to set this permanently). You will most probably need to exit the current shell in order to see the change in your shell prompt.
Or
- Open file /etc/sysconfig/network
- change hostname with your preferred hostname
- save the file and try to reboot to check if your hostname changed was sucessfull
Step-by-step enable remote desktop on linux using vnc
In this section, I’ll show how to configure VNC server on Redhat server and using VNC Viewer connect the server remotely from Windows XP.
- On Redhat server, login with your username that you want to enable remote access. In this example, I will use ‘admin’ user.

- Open Terminal, type ‘vncpasswd’. Type your password and verify password again. This command will use to set you password for remote access for the current user.

- Before next step, you need to logged on as root by type ’su root’.

- Edit the file /etc/sysconfig/vncservers by type ‘ vi /etc/sysconfig/vncservers’.
Note: If you are new to Linux, vi is an editor tool in command line mode on Linux.

- You’ll see text file as in the figure below. Next, I’ll edit on the highlight line.

- Uncomment on the highlight line. If you have more than one usernames that want to enable remote acces, you can change VNCSERVERS value in this format, “1:username1 2:username2 3:username3 ….”. In this example, I have only one user which is root so this line of mine is ‘VNCSERVERS = “1:admin”‘.

- Now save the file and exit. To save file, hold ESC + ‘:’ and type ‘wq’ to write and quit file.

- Next, log off the user if you are not user ‘root’ and log in as root. Enable VNC service by type ‘chkconfig vncserver on’. Then, start the VNC service by type ’service vncserver start’.

- If you have firewall enable on Redhat, be sure that your firewall configuration won’t block connection from remote computer by open port TCP 5901 for remote access. Open Applications -> System Settings -> Security Level. Add ‘5901:tcp’ on Other ports.
Note: VNC uses TCP protocol on port 5901.

- Now you can connect Redhat server from remote computer. On my Windows XP computer, open VNC Viewer on Windows XP, type IP Address of Redhat server with number as a username specify in step 6. In this example, I want to remote to Redhat server as ‘admin’ user which I assign as number 1 in step 6 (1:admin) and my Redhat server is 10.110.141.220. So I type ‘10.110.141.220:1′.
Note: You can download VNC Viewer for free at realvnc.com

- Type your password for ‘admin’ user which has been assign in step 2.

- Now you have connect to Redhat server remotely. But you’ll see that the interface looks different. You have to do a little thing more.

- On Redhat server, open terminal and type ‘vi /home/username/.vnc/xstartup’. In this example, I type ‘vi /home/admin/.vnc/xstartup’.
Note: If you going to enable remote access for user ‘root’, the file would be at ‘/root/.vnc/xstartup’.

- Uncomment these two lines and save the file.
Note: If you want to force to load Gnome or KDE Desktop on remote access, edit the last line from ‘twm &’ to ’startx &’ for Gnome and ’startkde &’ for KDE Desktop.

- Type ’service vncserver restart’ to apply changes.

- Reconnect using VNC viewer on remote computer again. Now you will see the desktop as you were log in at the server but now you’re remotely
.

Sharing Desktops Using VNC
Virtual Network Computing (VNC) consists of server and client software that enables
you to assume remote control of a full desktop display from one computer on another. In Fedora,
RHEL, and similar systems, you need the vnc package to access a remote desktop on
Chapter 13: Doing Remote System Administration
your display (client) and vnc-server to share a desktop from your computer (server).
To install those packages, type either (or both) of the following:
# yum install vnc
# yum install vnc-server
VNC clients and servers are available for, and interoperable with, many different operating
systems. VNC servers are available on Linux, Windows (32-bit), Mac OS X, and
Unix systems. VNC clients are offered on those, and many other types of systems
(including OS/2, PalmOS, and even as a Java application running in a web browser).
Setting Up the VNC Server
From your Linux desktop, we’ll assume you are using the default display (DISPLAY=:0)
as your local desktop. So we’ll set out to create independent displays accessible via
VNC. To start, open the vncservers file on the Linux system acting as your VNC
server (as root user) using any text editor:
# vi /etc/sysconfig/vncservers
In that file, create a display:user pair to identify a VNC desktop. These user accounts
must be valid user names for your system. Here are two different examples:
VNCSERVERS=”1:francois”
VNCSERVERS=”1:francois 2:chris”
Then as each user, run the vncpasswd command to create the password each of those
users will need to connect to their own desktops on the VNC server. In our example,
we run the following as the user francois:
$ vncpasswd
Password: *******
Verify: *******
Finally, you can start the VNC service (vncserver) as you would any other service in
Fedora and similar systems. Type the following as root user:
# chkconfig vncserver on
# service vncserver start
If you are using the iptables firewall built into your system, make sure you open the
port(s) for VNC. Each display runs on its own port. Display number N is accessed on
TCP port 5900+N. For example, display 1 is accessible on port 5901. Refer to Chapter 14
for more details on iptables.
Starting Up the VNC Client
With the VNC server running, you can connect to a desktop on that server from any
of the client systems mentioned earlier (Windows, Linux, Mac OSX, UNIX, and so
Chapter 13: Doing Remote System Administration
on). For example, assuming your VNC server is on a system named myserver, you
could type the following command to start that remote desktop from another Linux system:
$ vncviewer myserver:1 Connect as francois on display 1
$ vncviewer myserver:2 Connect as chris on display 2
You can also use tsclient to connect; for this example, you would just specify
myserver:1 as the computer and VNC as the protocol. By default, once you connect
via VNC, all you get is a very basic window manager (twm) and a terminal. To get the
full Fedora desktop next time the user logs in, you should edit your VNC xstartup file
on the VNC server. For example, log in as the user (in this example, francois or chris)
and type the following:
$ vi ~/.vnc/xstartup
When editing that file, remove the comment characters from two lines so they appear
as follows:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
On older versions of the VNC software, the file may not exist. So create it and add the
two lines above. After creating the file, set its permissions as follows:
# chmod 755 ~/.vnc/xstartup
Then, for the changes to take effect, you need to restart the VNC server. As root
user, type:
# service vncserver restart