Monday, September 08, 2008

Configuring Your Linux Hostname

First, check your hostname to see if it's configured correctly.

uname -n
hostname -a

hostname -s

hostname -d

hostname -f

hostname

If the above isn't correct, follow these steps:


Configure /etc/hosts

Add any static IPs on as follows:

127.0.0.1       localhost
192.168.0.4 mybox.example.com mybox


Setting the hostname using 'hostname'

You can run the following command after updating your /etc/hosts:

hostname mybox.example.com


Checking /etc/hostaname

You can also check to see if that worked by looking at /etc/hostname and you should see

mybox.example.com

I found all this good stuff at cpqlinux.

It is also possible that you may need to reconfigure httpd.conf in /etc/apache2/httpd.conf such that it reads

ServerName yourservername

Tuesday, August 26, 2008

Using terminal screen sharing with Unix Screen

Screen can be used to share a screen between two users-

screen -R screen-test

That opens a screen, now allow multiuser access in the screen session via the command CTRL-A :multiuser on (all 'screen' commands start with the screen escape sequence, CTRL-A).

CTRL-A
:multiuser on

Next, the host must grant permission to the remote user to access the screen session using the command CTRL-A :acladd user_name where user_name is the remote user's login ID.

CTRL-A
:acladd username

The remote user can now connect to the hosts 'screen' session. The syntax to connect to another user's screen session is screen -x host_username/sessionname.

screen -x username/screen-test

Thanks to Ubuntu Community.

Sunday, August 24, 2008

Dealing with Processes using ps

To find a process containing X, use:

$ ps -ef | grep 'X'

To terminate said process, the first column is the PID.

$ sudo kill -9 PID

This can be used to kill user sessions on SSH

How to bind additional IPs in Debian / Ubuntu Linux

So you're looking to add an additional IP addresses to a network interface that already has an IP address bound to it? Here's how: (source: NixCraft Article)

Let us assume that your eth0 IP address is 192.168.1.1. You need to create alias or binding using eth0:0, eth0:1...eth0:N devices. You need to add range of IP's in /etc/network/interfaces config file under Debian/Ubuntu Linux. First make a backup of existing file:

$ cp /etc/network/interfaces /root/working.interfaces

Now open file using nano text editor:

$ sudo nano /etc/network/interfaces

Modify as follows:

auto eth0
auto eth0:0
auto eth0:1

iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.254
# add rest of alias / binds below

Save and close the file.

Now restart networking, enter:

$ sudo /etc/init.d/networking restart

That's all! Thanks NixCraft!

Embracing Linux

I've slowly worked my way into a Linux/Unix environment. I started using SSH access to familiarize myself with navigating the Unix landscape. Now I use Linux on one of my tower PCs; specifically, Ubuntu Server Linux. I like it because it's well documented and developed somewhat for ease-of-use. I've also used Ubuntu desktop via virtual machine as well as Open Solaris.


One thing that I noticed when using Linux is that it's difficult to find the correct commands when you need them. Often, they're just a simple search away, but other times it takes a long time to refine which tutorial is the proper one to follow. Some of them require a little customization for the specific distro. I'm going to try to publish some of the tutorials I use for personal reference in addition to clogging up my del.icio.us. The problem is that often these links I use aren't worth clogging up my del.icio.us, so this will work to clear that up and make it simple to find my solutions after I've found them once.