Monday, February 21, 2011

Tips For CentOS.

SΑ,
 I will start with some tips for CentOS, I am using them all the time. So, I thought may be some one else will need and use them.

  •    Use
      # ifconfig  -a             //to see your NIC is up or not (eth0)


  • GUI tool to configure your network.
     # system-config-network &


  •  To check your wireless connection use:
     # iwlist
     # iwlist        wlan0                   scan
  
  • To show the IP routing table:
     # route        -n
 
  •  There is a work around to enable your wireless card
          1.     Install NDIS wrraper
          # rpm          --import      …./RPM-GPG-key-…
         # rpm          -Uvh           …./elrepo…….rpm
        # yum         --enablerepo=elrepo       install                   kmod-ndiswrraper
       #modprobe ndiswrraper
      # ndiswrraper       -i       /..path-to-the-driver/hardware.inf  & .sys file

  • To mount NTFS on Centos:
          1.     Install rpmforge repository, download it for x86-64, check that using:         
          # uname  -i

          Install DAG's GPG key
          # rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

         Verify the package you have downloaded
# rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm
         
          Install the package
# rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
This will add a yum repository config file and import the appropriate GPG keys.
         # yum                   install          fuse   fuse-ntfs-3g
        # yum                   --enablerepo=rpmforge  install                   fuse   fuse-ntfs-3g

       Create a mount point
       # mkdir       /mymount/ /mymount/win/
       # vi    /etc/fstab
       /dev/sda1    /mymount/win      ntfs-3g        rw,umask=0000,defaults           0      0
       # mount /mymount/win
  • To increase the time out before the default OS starting:
       # vi    /boot/grup/menu.lst
       Timeout=30                   (in sec)
 
  • To install a new repository
      Download the repository .rpm
      Verify the package you have downloaded
     # rpm –K    ……rpm
     # rpm          -Uvh  ……rpm
     # yum          --enable-repo=”Repo-name”    install   “Required package”
 
  • If you face any problem with enabling the network
         1.     Check         /etc/sysconfig/network
               Gateway=”Gateway IP”
         2.     Check         /etc/resolv.conf
                 nameserver “DNS IP”
         3.     Check the default gateway using:      # route
                 If it is not correct delete it using:
           # /sbin/route                   del     default        gw     GW-IP
           Add the correct one:
           # /sbin/route                   add    default        gw     GW-IP
  
 
  •  Wget is a very cool command-line down loader for Linux and UNIX environments. 
 It is very powerful and versatile and can match some of the best graphical downloaders around today. It has features such as resuming of downloads, bandwidth control, it can handle authentication, and much more.
Most Linux distributions come with wget pre-installed. 
The most basic operation a download manager needs to perform is to download a file from a URL. Here’s how you would use wget to download a file:
wget http://www.sevenacross.com/photos.zip
 
  • Display TOTAL hard disk size
      # fdisk -l | grep Disk

  • To disable SELinux:
      # vi   /etc/selinux/config
          Selinux=disable
 
          Or : #  setenforce  0
          Or : #  lokkit     //Firewall and SELinux configuration tool.
 
  •  To check md5
         # md5sum   file-name

  • To list CPU info
     # more /proc/cpuinfo
 
  • To check the RAM Size in Linux Machine
      # free -m
 
  • To disable ping responses
      #  echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
OR
      #sysctl   -w   net.ipv4.icmp_echo_ignore_all=1
 
  • To enable ping responses
     #  echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
OR
     #sysctl   -w   net.ipv4.icmp_echo_ignore_all=0
 
  •  To make this permanent set the following into /etc/sysctl.conf
             net.ipv4.icmp_echo_ignore_all=1
 
How to Assign an IP Address Using ifconfig Command Line Tool?
 
# cp /etc/sysconfig/network-scripts/ifcfg-eth1      /etc/sysconfig/network-scripts/ifcfg-eth1.bak
ifconfig eth1 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255
The ifconfig command does not store these changes permanently. Upon reboot this information is lost. To make your changes permanent, open the file /etc/sysconfig/network-scripts/ifcfg-eth1 and enter the following information.

Static IP configuration


 
DEVICE=eth1

BOOTPROTO=static

BROADCAST=XXX.XXX.XXX.255

IPADDR=XXX.XXX.XXX.XXX

NETMASK=255.255.255.0

NETWORK=XXX.XXX.XXX.0

ONBOOT=yes

DHCP configuration


DEVICE=eth1

ONBOOT=yes

BOOTPROTO=dhcp


Once you have made changes to the files above, you can make the network card use the new values without any reboot by running the following command.

# ifup eth1

ifup is a script residing in /etc/sysconfig/network-scripts/ifup, which is used to bring network interfaces on-line.

Note: To disable DHCP change BOOTPROTO=dhcp to BOOTPROTO=none in the ifcfg-eth1 file above.

In order for updated information in any of these files to take effect, one must issue the command:

# service network restart
  
  • Setting a Default Gateway for Redhat / CentOS systems?
There are two possible ways for adding a default gateway.
Option 1: You can add a gateway definition to  the /etc/sysconfig/network file. This definition will apply to all network interfaces.
/etc/sysconfig/network file.

GATEWAY=192.168.4.1
 
Option 2: You can define a default gateway for a specific interface. For this approach you need to modify your interface definition. Let’s say we want to modify eth0 then you need to add the same definition to the  /etc/sysconfig/network-scripts/ifcfg-eth0 file.
For both options, your modifications will be activated after you restart your networking service.
root@centos ~]# /etc/init.d/networking restart

I hope if any one have any question or any comment will not hesitate to tell me.

Done.
Inas  











No comments:

Post a Comment