Saturday, March 19, 2011

Linux: GUI vs. Command Line



In the Linux , there are two modes for users to interact with the computer. One is GUI (Graphical User Interface) and CLI (Command Line Interface). GUI looks like windows/ graphical and CLI is looks command prompt.
GUI:




CLI

Here is some different GUI and CLI

GUI makes it easy for the user, therefore makes the OS user-friendly.
GUI interface means the OS is "dumbed down"

=====>>CLI gives the user more control and options.
=====>>> CLI is stone-aged; it belongs to a "The History of Computers" museum.

@Xwindows is progress compared to the CLI.
@Xwindows presents a really big security risk...load it and you are asking to be hacked.

Using GUI is faster. Picking and choosing icons sure beats trying to remember and typing command lines.
====>Using CLI is faster. A keyboard is pretty much all you need here, much faster than all that clicking, scrolling, clicking some more, scrolling some more, and more typing, then clicking.

@@@ GUI consumes too much CPU and memory. ( With newer and more powerful computers, that is not a problem. And its benefits are well worth it.)


(~)

So, in the user-friendly vs. control and options debates, both sites have a point. But there is a third point: GUI and CLI can be used together to achieve great things that either one alone can't. This is particularly true with Linux where the user is given the flexibility of switching back and forth between GUI and Command Line easily. One example is that Linux CLI and GUI can give the user the ability to work on any computer on the network as if you were sitting at that computer. On Unix/Linux (running X-Windows) all you need to do is use the xhost command to specify which computers you want to allow access, and the DISPLAY environment variable to specify on which computer you want to start the GUI of the program you want to run.


Basic Network Commands for Linux

Required Information

To enable networking, you must configure your NIC (Network Interface Card/s) with an
IP address and netmask. The kernel must have support for your cards compiled in, either as modular support or direct support. If you don't have kernel support read the sections about the kernel and how to compile it. To set your cards up, do the following. In my example my network is 192.168.16.0, IP=192.168.16.100, broadcast=192.168.16.255, netmask=255.255.255.0, gateway-192.168.16.1, nameserver=192.168.16.10.

1. Determine your machines IP address from your network administrator
2. Your network mask. This determines which portion of the IP address specifies the subnetwork number and which portion specifies the host.

Class C (most networks) 255.255.255.0
Class B 255.255.0.0

3. Your network address which is your IP address bit wise anded with the network mask.
Ex: IP: 192.168.16.100 Mask: 255.255.255.0 Net Addr:: 192.168.16.0

4. Your broadcast address. Used to broadcast packets to every machine on your subnet.
Ex: IP: 192.168.16.100 Mask: 255.255.255.0 Net Addr: 192.168.16.255

5. Your gateway address. The address of the machine that is your gateway to the outside world.
In many cases: Ex: IP: 192.168.16.100 Gateway: 192.168.16.1

6. Your nameserver address. Translates host names into IP addresses. 192.168.16.10 or you can use 8.8.8.8 or 4.2.2.2
Configuration tools

There are many network configuration tools today. They are:

netconf A GUI interactive interface
linuxconf A GUI interactive interface includes netconf configuration.
netconfig A GUI step by step interface
ifconfig A text based program to configure the network interface. Type "man ifconfig" for info.

These programs will modify values in the following files:

* /etc/sysconfig/network - Defines your network and some of its characteristics.

* /etc/HOSTNAME - Shows the host name of this host. IF your name is "myhost" then that is exactly the text this file will contain.

* /etc/resolv.conf - Specifies the domain to be searched for host names to connect to, the nameserver address, and the search order for the nameservers.

* /etc/host.conf - Specifies the order nameservice looks to resolve names.

* /etc/hosts - Shows addresses and names of local hosts.

* /etc/networks - Provides a database of network names with network addresses similar to the /etc/hosts file. This file is not required for operation.

* /etc/sysconfig/network-scripts/ifcfg-eth* - There is a file for each network interface. This file contains the IP address of the interface and many other setup variables.

Analysis Tools

* netstat - Displays information about the systems network connections, including port connections, routing tables, and more. The command "netstar -r" will display the routing table.

* traceroute - This command can be used to determine the network route from your computer to some other computer on your network or the internet. To use it you can type
"route IPaddress" of the computer you want to see the route to.

* nslookup - Used to query DNS servers for information about hosts.

* arp - This program lets the user read or modify their arp cache.

* tcpdump - This program allows the user to see TCP traffic on their network.

* dig - Send domain name query packets to name servers for debugging or testing.

* ping

Manual Configuration

You can use one of the above tools or configure the network the old fashioned way as follows:

  1. First to use networking on any permanent basis you should setup the file /etc/sysconfig/network similar to the example shown below.
  2. Assign an ip address with "ifconfig eth0 192.168.16.100 netmask 255.255.255.0 up".
  3. Tell your machine that a hub is ready for information with the command "route add -net 192.168.16.0 netmask 255.255.255.0 eth0"
  4. To contact hosts outside your network if a machine with IP address 192.168.16.1 is the gateway use the command "route add default gw 192.168.1.1 eth0"

These settings are not permanent, but go away the next time you boot. They are normally set up in the directory /etc/sysconfig/network-scripts. Add the network interface to the file /etc/sysconfig/network-scripts/ifcfg-eth*. For example the file ifcfg-eth0 if for the first ethernet interface, ifcfg-eth1 for the second, ifcfg-lo is for the local interface. An example file from my system is:

DEVICE="eth0"
IPADDR="192.168.16.100"
NETMASK="255.255.255.0"
ONBOOT="yes"
BOOTPROTO="none"

Unless you know what you're doing it is best to use a network configuration tool. I cannot guarantee the accurateness of how to set these files up on your system.

Configuring an interface for multiple IP addresses

If you want to configure your network card to act as more than one IP address, issue the following command:

ifconfig dummy 192.168.16.102 netmask 255.255.255.0

This uses the dummy system interface capability supported in the kernel to setup another virtual interface which operates at IP address 192.168.1.102. Substitute the IP address that you want your virtual interface to be with an appropriate netmask for your network. To disable this, issue the following command.

ifconfig dummy down

Another way to use multiple IP addresses on one ethernet card is to set up a new file in your /etc/sysconfig/network-scripts directory. Copy your ifcfg-eth0 role to ifcfg-eth0:0. Edit that file and rename the device to "eth0:0" and the IP address to the desired IP address. You may also want to modify BROADCAST, NETWORK, or NETMASK. You can continue adding IP addresses by using :1, :2, etc such as ifcfg-eth0:2.

To make it effective, you must reboot your system or issue the command "/etc/rc.d/init.d/network restart" as root.

Dynamically allocated IP addresses

To get the IP address of a dynamically allocated network interface in a script file enter the following:

dynip=`/sbin/ifconfig | grep -A 4 ppp0 | awk '/inet/ { print $2 } ' | sed -e s/addr://`

Substitute the correct interface that you get your dynamic IP address in for ppp0 in the example above. This script line gets your dynamic IP address for use in a masquerade script. You can use the variable $dynip as in any other configuration. The next time you make a new connection you will need to extract the dynip value again and re-run the masquerade script.

Networking file formats, examples and considerations

Below are listed some more in depth information about the networking files.

  • /etc/sysconfig/network
    The /etc/inittab file contains the entry "si::sysinit:/etc/rc.d/rc.sysinit" which causes the system at startup to run the rc.sysinit script. The rc.sysinit file expects to find the file /etc/sysconfig/network if networking is to be enabled.
    The network file looks like this:

    NETWORKING=yes
    FORWARD_IPV4=false
    HOSTNAME=mymachine.mycompany.com
    DOMAINNAME=mycompany.com
    GATEWAY=192.168.16.1
    GATEWAYDEV=eth0

    Where GATEWAYDEV is the network interface card that is attached to the network the gateway machine is on. The GATEWAY is the actual IP address of the gateway machine.

  • /etc/hosts - Defines local hosts.
    127.0.0.1 localhost localhost.localdomain
    192.168.16.100 mymachine.mycompany.com mymachine
  • /etc/resolv.conf - Specifies the domain to be searched for host names to connect to, the nameserver address, and the search order for the nameservers.
    domain mycompany.com
    search mycompany.com mynet.net
    8.8.8.8
    nameserver 192.168.16.10
  • /etc/host.conf - Specifies the order nameservice looks to resolve names. An example file:
     order hosts, bind
    multi on
    nospoof on

Older X windows configuration

In Xwindows a working configuration is set up as follows:

NAMES:
hostname: mymachine.mycompany.com
Domain: mycompany.com
Nameservers: 192.168.16.10
nameserver: 8.8.8.8

HOSTS:
IP - 192.168.16.100
Name - mymachine.mycompany.com

INTERFACES:
Interface - eth0
IP- 192.168.16.100
proto - none
Netmask: 255.255.255.0
Network: 192.168.16.0
Broadcast: 192.168.16.255

ROUTING:
Default gateway: 192.168.16.1
Default gateway device: eth0


Wednesday, February 16, 2011

Cent os setup Procedure







Cent OS is a best Linux distributor in the World of Linux. Its free for all.

Before we start installation Cent OS, here is some information about Cent OS:
1. Download link for latest Version
2. Wiki for Cent OS

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!


1 Requirements

To install such a system you will need the following:

a. Download the CentOS 5.xx DVD or the CentOS 5.1 CDs from a mirror next to you
b. a fast internet connection.


2 Preliminary Note

In this tutorial I use
a. hostname myhost1.myserver.com

b. IP address 192.168.16.100
gateway 192.168.16.1

c. Primary dns 8.8.8.8 and Secondary dns 4.2.2.2

These settings might differ for you, so you have to replace them where appropriate.


3 Install The Base System

Step1
Boot from your first CentOS 5.xx CD (CD 1) or the CentOS 5.xx DVD. Press at the boot prompt:



Step2.
TEST CD?DVDS
It can take a long time to test the installation media so we skip this test.



Step3:
The welcome screen of the CentOS installer appears.
Click on Next:
Choose your language next:
Select your keyboard layout:



Step4: (Partition !!!! so important !!!!!!)

I'm installing CentOS 5.1 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?

Now we must select a partitioning scheme for our installation.

For simplicity's sake I select Remove linux partitions on selected drives and create default layout.

This will result in a small /boot and a large / partition as well as a swap partition. Of course, you're free to partition your hard drive however you like it. Then I hit Next:

Answer the following question (Are you sure you want to do this?) with Yes:



Step5:
On to the network settings. The default setting here is to configure the network interfaces with DHCP, but we are installing a server, so static IP addresses are not a bad idea...

Click on the Edit button at the top right.

In the window that pops up
  • uncheck Use dynamic IP configuration (DHCP) and Enable IPv6 support and give your network card a static IP address (in this tutorial I'm using the IP address 192.168.16.100 for demonstration purposes and a suitable netmask 255.255.255.0 etc.


Step6:
Set the hostname manually, e.g. myhost1.myserver.com,



Step7:
Enter a gateway (e.g. 192.168.16.1) and up to two DNS servers (e.g. 8.8.8.8 and 8.8.4.4):


Step8:
Choose your time zone:


Step9: (Password!!! )
Give root a password:


That all for installation!!!