Translate

Sunday, 27 January 2013

Configuration of IP addresh in RHEL

How to assign IP address to RHEL machine

 
first to check the configuration file.
 
 # ls ifcfg-et*
    ifcfg-eth0
file will start with ifcfg-* , Here we have "ifcfg-eth0"
 
Now edit this file by using "vi editor" ( to know details about "vi" please read previous blog) .
 
# vi ifcfg-eth0
DEVICE=eth0                                                           : divice name of network card
HWADDR=08:00:27:25:f6:f0                                   : MAC address
ONBOOT=yes                                                            : It will start automatically after boot (yes)
IPADDR=192.168.80.10                                            : IP address of system
BOOTPROTO=none                                                  : DHCP off
NETMASK=255.255.255.0                                        : subnet mask of machine
TYPE=Ethernet                                                           : Type of LAN
GATEWAY=192.168.80.1                                         : Gateway of machine
IPV6INIT=no                                                              : IP version 6 disable
After this start/restart the network service
 
/etc/init.d/network restart
 
# /etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
#
To check the assign IP address use "ifconfig"
 
# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 08:00:27:25:F6:F0
          inet addr:192.168.80.10  Bcast:192.168.80.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe25:f6f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:54022 errors:0 dropped:0 overruns:0 frame:0
          TX packets:936 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3276156 (3.1 MiB)  TX bytes:145609 (142.1 KiB)
 
 
 
 

VI editor in RHEL 6

How to use VI editor..

To open a file use vi <filename>

e.g.

# vi test

use following key to edit the file by vi

i - insert the text at current cursor position.
I - insert the text at beginning of line.
a - appends the text after cuurent cursor position.
A - appends the text at end of line.
o - inserts a line below currnet cursor position.
O - inserts a line above currnet cursor position.
r - replace a single char at current cursor position.

Commands at execute mode

:q             - quit without saving
:q!           - quit forcefully without saving
:w            - save
:wq!         - save & quit forcefully
:x             - save & quit
:sh           - providing temporary shell
:se nu      - setting line number
:se nonu   - removing line number

Saturday, 26 January 2013

Commands for Linux Part 5

Basic command for Linux Part 5

12) To Search a word and file from single or multiple files's


For word use grep command

Option 1:

   #command word (to be search) files (from you are searching)

example :
# grep gdm /etc/passwd /etc/group /etc/shadow
/etc/passwd:gdm:x:42:42::/var/lib/gdm:/sbin/nologin
/etc/group:gdm:x:42:
/etc/shadow:gdm:!!:15727::::::

 Option 2 :

#cat (for read or open the file) file (from you are searching) | (pipe) word (to be search)

example :

# cat /etc/passwd |grep gdm
gdm:x:42:42::/var/lib/gdm:/sbin/nologin


For file use find command

find - search for files in a directory

#command (find) file (from you are searching) Synopsis (here using name means by name we are searching) file (to be search)

example:

#find /etc/ -name passwd
/etc/pam.d/passwd
/etc/passwd


continue..
 

Basic command for Linux Part 4

Basic command for Linux Part 4

10) To copy files and directories

 cp - copy files and directories

#cp <source>  <destination>

To copy file:

example:
# cp test /root/
# cd /root/
# ll test
-rw-r--r--. 1 root root     0 Jan 23 03:04 test
To copy folders

#cp -r dirtest/ /test/

11) To move directories and files

 mv - move (rename) files

DESCRIPTION ;
       Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

# mv dirtest/ /root/dirtest/
# cd /root/dirtest/
# ll
total 4
drwxr-xr-x. 2 root root 4096 Jan 23 03:08 dirtest
[#
To rename the file or directories :

# mv dirtest test
# ll
total 4
drwxr-xr-x. 2 root root 4096 Jan 23 03:08 test

continue....

Sunday, 20 January 2013

Basic command for Linux Part 3

 Basic command for Linux Part 3


8) Creating a single directory

#mkdir test

To creating multiple directories

#mkdir test test1 test2 test3

To create neated directories

#mkdir -p test1/test2/test3/test4

To see the tree structure

#ls -R test
test1:
test2

test1/test2:
test3

test1/test2/test3:
test4

test1/tes2/test3/test4
#


9) To change the directory

go to the directory

#cd test1

Back to previous directory

#cd ..

Go to the one more down

#cd ../..

To check present working directory

#pwd

10)  To remove files

#rm test1
to remove regular file "test1" ? y

To remove empty file

#rmdir test

To remove a dirctory

#rm -rf test

continue....

Saturday, 19 January 2013

Basic command for Linux Part 2

Basic command for Linux Part 2

 
6) How to see file stating with word e.g f
 
#ls f*
 
 To see a file have middle string as disk

#ls /bin/*disk*

To see a file whose length is 3 characters

 #ls ???

To see a file which start with single char & end up with nay number of character

#ls ?edh*


7) How to create a file

#cat > test

how to see file content

#cat test

to append a file

#cat >> test

How to create a emply file

# touch test1

How to create multiple  file with one command

#touch test2 test3 test4  ... so on


continue....
 

Commands for Linux Part 1

Basic command for Linux Part1


1) To check the present working directory

#pwd

Example :

[root@test7 ~]# pwd
/root

2) To show contents of directory (folder)

#ls

Example:

[root@test7 ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog
[root@test7 ~]#
3) to see more details including the permission regarding the contents of directory (Folder)

#ls -l or #ll

Example:

[root@test7 ~]# ls -l
total 60
-rw------- 1 root root  1131 Dec 25 14:16 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Dec 25 14:28 Desktop
-rw-r--r-- 1 root root 36541 Dec 25 14:16 install.log
-rw-r--r-- 1 root root  3684 Dec 25 14:15 install.log.syslog
[root@test7 ~]#

[root@test7 ~]# ll
total 60
-rw------- 1 root root  1131 Dec 25 14:16 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 Dec 25 14:28 Desktop
-rw-r--r-- 1 root root 36541 Dec 25 14:16 install.log
-rw-r--r-- 1 root root  3684 Dec 25 14:15 install.log.syslog
[root@test7 ~]#

4) To see all contents including hidden files of a drectory (Folder)

#ls -a

Example:

[root@test7 ~]# ls -a
.                .bash_history  .bashrc  .dmrc     .gconfd  .gnome2_private    .ICEauthority       .metacity  .tcshrc
..               .bash_logout   .cshrc   .eggcups  .gnome   .gstreamer-0.10    install.log         .nautilus  .Trash
anaconda-ks.cfg  .bash_profile  Desktop  .gconf    .gnome2  .gtkrc-1.2-gnome2  install.log.syslog  .redhat    .xsession-errors

5) to see tree structure of nested directories

#ls -R

Example:
[root@test7 ~]# ls -R Desktop/
Desktop/:
test
Desktop/test:
test1
Desktop/test/test1:
[root@test7 ~]#

continue........

Thursday, 17 January 2013

How to change the Linux server name (hostname) ..

How to change the Linux server name (hostname) ..

To set the hostname just type the command hostname with name of server

# hostname test7

to check the hostname of server

[root@localhost ~]# hostname
test7
[root@localhost ~]#
Now this is not permanent , once you reboot the system it will change to previous name.

To set permanent hostname put the enytry in /etc/sysconfig/network file

#vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=test7
wq!
#
 

how to get the Linux OS version

how to get the Linux OS version...


To get the Linux OS version just follow any one method


1) Read the /etc/redhat-release file

[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
[root@localhost ~]#
2) use lsb_release command

[root@localhost ~]# lsb_release -a
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release:        5.5
Codename:       Tikanga
[root@localhost ~]#
3) by  /etc/issue file

[root@localhost ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
[root@localhost ~]#

Here OS version is RHEL 5.5

First option is best to get correct information : # cat /etc/redhat-release

Wednesday, 16 January 2013

YUM server configuration in Linux step by step

How to configure YUM server in Linux


First of all mount your Linux OS iso on your system. for this insert the DVD and follow the followig process

1) mount the DVD

#mount /dev/dvd /mnt

2)After mounting the DVD type df -hT command to check the status of DVD mount

#df -h

3)Than go to the directory.Check is there any file exist with name of .repo

#cd /etc/yum.repos.d
#ls -ltr


4)if not  create a file with name of .repo, here we are creating with name of yum.repo .

#touch yum.repo

5) edit the .repo file with fillowing details ( we are using minimum requirment)

[root@localhost yum.repos.d]# cat yum.repo
[Server]
name=server
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
#
Note : /mnt/Server : is location where rpm repository is available or created by default in OS iso it is present in "Server" direcotry

6) Than clean the existing setting and update it with new one
#yum clean all
#yum list
7) Finally you have Yum server to install your packages

#yum install package name




Tuesday, 15 January 2013

Softlink & Hard Link


Difference between Softlink & Hard Link

 
Hardlink :-

1.        Hard link works with same inode number on source & destination files

2.        The size of shortcut file same as equal to original file

3.        Hard link can be only in same file system

4.        if shortcut file removed then data will be persistent or available

5.        Hardlink only create for files not directories

Softlink :-

1     Softlink  link works with different  inode number on source & destination files

2.       The size of shortcut file is total number of character in path

3.       Softlink link can be in different or network  file system

4.       if shortcut file removed then data will be lost

5.      softlink can be create on both files or directory

What command can you use to review boot messages in Linux

What command can you use to review boot messages in Linux

#dmesg or #dmesg |more (for page vise view)

The dmesg command displays the system messages contained in the kernel ring buffer. By using this command immediately after booting your computer, you will see the boot messages.

Monday, 14 January 2013

how to get the Linux server hardware information (hardware vender Serial number , model numbre , BIOS details etc)

how to get the serial number of Linux machine..


Run the below command
 
#dmidecode |more
 
It will show you hardware information and serial number of Linux machine..
 
serial number will come under the tab of system information.

This is a very useful tool from this you will get the all the system details : hardware vender Serial number , model numbre , BIOS details etc.

 

Sunday, 13 January 2013

Monitoring tools for system performance in Linux

How to monitor system performance in Linux


 
#1: top - Process Activity Command
#2: vmstat - System Activity, Hardware and System Information
#3: w - Find Out Who Is Logged on And What They Are Doing
#4: uptime - Tell How Long The System Has Been Running
#5: ps - Displays The Processes
#6: free - Memory Usage

How to configure password policy in Linux

How to configure password policy in Linux 


Configure Password Policy

#vi /etc/login.defs
 
Edit the file as follows:
 
PASS_MAX_DAYS 42
PASS_MIN_DAYS 7
PASS_MIN_LEN 8
PASS_WARN_AGE 14
 
Type ESC:x! to save and exit

Types of files in Linux and how can we check..

How many types of files in Linux and how can we check..


Just type ls -ltr.. it will show you the list of file and at first column you will see following word

#ls -ltr
....




d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file

Saturday, 12 January 2013

Disabling Graphical mode in RHEL

How to disable X Windows at System Boot in Linux


# vi /etc/inittab

Find line:
id:5:initdefault:
Replace with:
id:3:initdefault:
Save and close the file. Restart the server. You can also drop to text mode by typing init command "

# init 3

Friday, 11 January 2013

error :skiping packages broken with dependency in yum


How to handle skiping packages with dependency problems in yum linux

# yum -y upgrade --skip-broken
OR
# yum -y update --skip-broken

"NO KEY error" in YUM installtion in RHEL 6

"NO KEY error" in  YUM

How to resolve NO KEY error in installation through YUM in Linux.

 
# find / -name "*GPG*"
#rpm --import *GPG* (from where you have put rpm and repo.)
 
than try to run yun install your problem should resolve :-)

Thursday, 10 January 2013

overview of /etc/passwd file in Linux ..

There are seven fields in the /etc/passwd file.

username, UID, GID, comment, home directory, command

The seven fields required for each line in the /etc/passwd file are username, UID, GID, comment, home directory, command. Each of these fields must be separated by a colon even if they are empty

how to get running process details in Linux


What command to be used to check all process running in the server?

ps -ef

Type of shell in Linux




How many type of shell in Linux ?

 

Sh, bsh, ksh, ssh

Wednesday, 9 January 2013

What command is used to remove the password assigned to a group in linux?

What command is used to assign and remove the password assigned to a group in linux

gpasswd -r

The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group.

Difference between ssh & telnet and thier port number


What is the difference between ssh & telnet

Answer :

In Ssh data will be transfer between the systems in
Encrypted form. So that it is difficult for hackers to
Understand what is going on network.
In telnet & ftp data will be transfer in alphabhatical, so
Hackers easily hack u r server
 
For this very reason login to other systems using Ssh would
Be recommended.

Telnet port = 23
SSH port numbre = 22

what is the difference between TCP and UDP ???

Difference between TCP and UDP

TCPUDP
Reliability: TCP is connection-oriented protocol. When a file or message send it will get delivered unless connections fails. If connection lost, the server will request the lost part. There is no corruption while transferring a message.Reliability: UDP is connectionless protocol. When you a send a data or message, you don't know if it'll get there, it could get lost on the way. There may be corruption while transferring a message.
Ordered: If you send two messages along a connection, one after the other, you know the first message will get there first. You don't have to worry about data arriving in the wrong order.Ordered: If you send two messages out, you don't know what order they'll arrive in i.e. no ordered
Heavyweight: - when the low level parts of the TCP "stream" arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together.Lightweight: No ordering of messages, no tracking connections, etc. It's just fire and forget! This means it's a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.
Streaming: Data is read as a "stream," with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call.Datagrams: Packets are sent individually and are guaranteed to be whole if they arrive. One packet per one read call.
Examples: World Wide Web (Apache TCP port 80), e-mail (SMTP TCP port 25 Postfix MTA), File Transfer Protocol (FTP port 21) and Secure Shell (OpenSSH port 22) etc.Examples: Domain Name System (DNS UDP port 53), streaming media applications such as IPTV or movies, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and online multiplayer games etc

Monday, 7 January 2013

Demons for NIS Server in Linux..

what are the demons for NIS Server?

 

ypserv, yppasswd, ypupdated, ypxfer and ypbind

User login logs in linux

When a user types wrong password, will the system register that error in which file?


 /var/log/secure

How to check which user has made a 'su' to root

How to check which user has made a 'su' to root?


#more /var/log/secure

Sunday, 6 January 2013

How to rename a file in Linux


How to rename  a file ?

mv command is use for renaming the file in linux
#mv <filename> <new filename>

how to check size of file and directory


How to check whice file/directory occupying more space & how  to get the maximum space using directory & size on top of the output?


du -sk . | sort -nr

Saturday, 5 January 2013

How to set welcome message in to the Linux system

Which file is used to display welcome message in to the system?


Ans : Edit /etc/motd

#vi /etc/motd

How to set display message when a telnet is issued?

Which file is used to display message when a telnet is issued?


Ans : Edit /etc/issue

 

Friday, 4 January 2013

Superblock in Linux..


What is Superblock in Linux?


Superblock is balance sheet of a FS, it stores size of the filesystem, starting block of the FS and ending block of the FS, no of inodes for the FS, directories in the FS.

How to check current home path ..


How to check what is my current allocated path?

echo $PATH
or
$PATH

How to find out which are the other users logged in at that time in LInux?


How to find out which are the other users logged in at that time in Linux?

try any one...
#who
#w
#finger

Thursday, 3 January 2013

How to add or increase swap space in Linux


Swap File Management


Add system swap space for virtual memory paging:
Swap space may be a swap partition, a swap file or a combination of the two.One should size swap space to be at least twice the size of the computer's RAM. (but less than 2GB)


·            dd if=/dev/zero of=/swapfile bs=1024 count=265032 - Create file filled with zeros of size 256Mb
·            mkswap /swapfile         - Create swap file
·            swapon /swapfile         - Begin use of given swap file. Assign a priority with the "-p" flag.
·            swapon -s                - List swap files
·            cat /proc/swaps          - Same as above
    
This example refers to a swap file. One may also use a swap partition. Make entry to /etc/fstab to permanently use swap file or partition

If you are facing any issue please post or comment on
http://linuxtipsandsolution.blogspot.in/

RHEL Booting Process


   Boot Proceess Of Linux 


 1.Phase BIOS:-

 

When we turn on the system it run a programe called Basic input output system. After the BIOS load it perform some diagnostics on the hardware, Check the installed components to be sure they are functioning and check the system RAM, The BIOS tries to find out a system drive from which it can load the boot programe to begin the boot process of starting the operating system. Usually the first sector of the drive has an area called the Master Boot Record (MBR), Which hold the programe used to begin the actual loading of OS. As soon as the BIOS find the MBR it gives up control of the boot process and load boot loader in to memory. Usually Grand Unified Boot Loader (GRUB)

 

2. Boot Loader Phase

 

Linux has two step processes to begin loading the operating system. These two steps are typically referred to as stage1 and stage2.  In stage one a programe in MBR is used to find the second stage program that will begin the process of loading the operating system into memory, GRUB uses a configuration file called /boot/grub/grub.conf to provide information to the secound stage loader

 

3. Kernel Phase 

 

After the stage2 passes successfully. It load kernel into memory. And kernel will uncompressed the initrd  in RAM .  mount it as ram disk and then run linuxrc in the The

Ramdisk. After that kernel detect all hardware and configure it properly. And mount the root file system. After the kernel has configured all the system devices and mount the root file system drives, kernel main functions at boot time

a)      Device detection

b)      Device Driver initializations

c)      Mount root filesystem read only

d)     Load  initial process

 it run the /sbin/init command.

 

4. The /sbin/init Phase

 

/sbin/init programe is the first system process that runs after the kernel has configured the system devices and mounted the system. It just likes a project mamager of the system because it manages the remaining step of booting the system and it is the parent of all process. init have its configuration file /etc/inittab. And it consists of many scripts. After reading the /etc/inittab file, init turns over control to the rc.sysinit programe which reads the /etc/rc.d/init.d/functions file to determine the procedure to use to set the default system path, start and stop programe, sysinit also check

a)      set kernel parameter in /etc/sysctl.conf

b)      set system clock

c)      load keymap

d)     Enable swap partiotion

e)      Set hostname

f)       Add raid devices

g)      Enable disk quota

h)      Check and mount other filesystem

 

 The next script to run is /etc/rc.d/rc, which is responsible for starting and stoping services when the runlevel changes and determine the new runlevel. /etc/rc.d directory are additional directory rc0.d, rc1.d, rc2.d, rc3.d. The number in the directory name correspond to the runlevel, Each of these directory contain scripts that are used to stop and start services for the runlevel,All the scripts in the rc5.d directory are symbolic link to the actual scripts that are located in the /etc/rc.d/init.d/ directory 

 

After that init run the gettys specified in the /etc/initab file, These provide six terminal you can use tologin on your server, The last thing the init programe does it run the /etc/rc.d/rc.loacl scripts

If you are facing any issue please post or comment on
http://linuxtipsandsolution.blogspot.in/

Linux Tips : forget root password , How to recover rot password in Linux

Ohh you forget the root password... Now what to do.. how to recover root password???

Here is the Tips

Restart the system and intrupt the booting process by pressing any key to boot.

  • Use the arrows to select the boot entry you want to modify.
  • Press e to edit the entry
  • Select the line starting with the word kernel word
  • Press e to edit this entry
  • At the end of the line add the word single or numaric 1
  • Press ESC key 
  • Press b to boot this kernel

  • After booting in single user mode . Just type passwd command to reset the password

    #passwd


    If you are facing any issue please post or comment on
    http://linuxtipsandsolution.blogspot.in/



    Wednesday, 2 January 2013

    What command to be used, to know i n which shell I am currently working in Linux?

    What command to be used, to know i n which shell   I am currently working? ..


    Echo $SHELL

    How to block direct root access in Linux

    How to block direct root access in Linux


    Its very dangerous to give root access to any one and open your system to log in by remotely through "root" user, because its very difficult to capture its logs. So here is tips to block your direct root access through remote server by this u can get information who has logged in and using root access by verify /var/log/secure log by, It will give you information who logged in system and than use root access for there work.

    So for blocking root access follow these steps

    1. #vi /etc/ssh/sshd_config
    3. Locate the parameter -- PermitRootLogin yes
    4. Change this to PermitRootLogin no
    5. Save and exit

    #wq!
    6. Restart your sshd by type /etc/init.d/sshd restart