Monday 24 December 2012

SRE Interview Questions 4

RHCE_Questions1
1. There are five virtual are provided during installation process in the Redhat enterprise linux server:

ALT-F1: To access install in text mode
ALT-F2: to access bash shell
ALT-F3: to view log of installer messages
ALT-F4: to view log of kernel messages
ALT-F5: stdout of mke2fs and grub command
ALT-F7: access installer in Graphical mode.



2. How to load USB driver in linux:

modprobe usb-uhci
modprobe usb-ohci
similarly modules can be removed or unloaded using "modprobe -r"
also "insmod" can be used to add module


3. How to list loaded modules in RHEL:

lsmod


4. How to Enable vsftpd on RHEL4:

Enable VSFTPD on RHEL
To lock users in home dir:
Touch vsftpd.chroot_list;
To create file of users that are allowed to ftp outside there home dirs add root to this file:
cd /etc/vsftpd
vi vsftpd.conf:

# You may specify an explicit list of local users to chroot() to their home

# directory. If chroot_local_user is YES, then this list becomes a list of

# users to NOT chroot().

chroot_list_enable=YES

chroot_local_user=YES

# (default follows)

chroot_list_file=/etc/vsftpd.chroot_list ; add root to this file


service vsftpd restart

To lock users in home dir:

Touch vsftpd.chroot_list ; to create file of users that are allowed to ftp outside their home dirs add root to this file


5. RHEL NFS issue:

Many times you have NFS exported directories mounted on Linux server get hanged. Possible sided affects just find out on my test RedhatLinux server running RHEL4 AS update 3 df start hanging. Pretty annonying . Trouble part is how to get rid off hanging df issues and find outr why it's happening.

NFS mounts are hanging simply because Server exporting NFS mount is offline or not on network. Again let's say you have 50 0r more mount point mounted on your NFS Linux client machine. You have to compare nfs mount showing in df comand output and nfs mount listed in /etc/fstab. once you find out what NFS mount is hanging you can simply go in /etc/rmtab file and remove that mount point.... and guess what you just resolved hanging nfs mount issue .


6. How to stop and start network ethernet interface:

ifdown eth0
ifup eth0


7. Create and Mount filesystem in redhat enterprise Linux:

    Redhat Enterprise 4 Linux you can use fdisk -l to list existing partitions on your system as a part of your Lab in RH133 Course :

[root@ice ~]# fdisk -l /dev/sda

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 8e Linux LVM
/dev/sda3 1319 1579 2096482+ 82 Linux swap
/dev/sda4 1580 2610 8281507+ 5 Extended

    Here we have unallocated extended partition . Remember you can have only 3 Primary partitions for a single disk in Redhat in our case we have SCSI disk /dev/sda where we have 3 primary partitions,with remaining unlloacted space you need to create Extended partition if you need to create more than 3 partitions .

#fdisk /dev/sda

    ON COMMAND TYPE n to create new partition , hit enter for start cylinder number and then on last cyliner i used +1024M you can use +1G as well , because i am going to create 1 GB filesystem :

Command (m for help): n
First cylinder (1580-2610, default 1580):
Using default value 1580
Last cylinder or +size or +sizeM or +sizeK (1580-2610, default 2610): +1024M
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

    Here is a catch that would be really stupid idea to reboot your Redhat enterprise Linux server to activate your partition table changes. I am sure Redhat will remove this warning in their upcoming redhat enterprise level 5 Linux version.Also you can save time in your RHCT/RHCE Certification Exam using partprobe. Note this how i am activating new partition table changes using PARTPROBE magic command.



[root@ice ~]# partprobe

[root@ice ~]# fdisk -l /dev/sda

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 8e Linux LVM
/dev/sda3 1319 1579 2096482+ 82 Linux swap
/dev/sda4 1580 2610 8281507+ 5 Extended
/dev/sda5 1580 1704 1004031 83 Linux

    Now I have to create a directory where i need to mount new +1 GB fileystem i am going to make ext3 filesystem .

#mkdir /home

[root@ice ~]# mkfs -t ext3 /dev/sda5
[root@ice ~]# mount /dev/sda5 /home
[root@ice ~]# df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 966M 18M 899M 2% /home

Here is your +1GB home filesystem (type is ext3) ready to use . you can add this in yout /etc/fstab file to make change permanent where it will mount /home automatically and persistent to server reboots.


8. Exporting NFS filesystem in RHEL4 (Redhat enterprise Linux) servers:

To export directory /home/export you need to add an entry in /etc/exports :

/home/export parmount.ice.com(rw,sync)

make sure there is space between mount options and hostname otherwise you will get permission error on redhat linux client.


9. maximum telnet session limit reached in( RHEL4)Redhat Enterprise Linux :


Quick Fix if you are getting maximum telnet service_limit reached messages in /var/log/secure logs in redhat enterprise Linux servers . Awesome you don't need to reboot your RHEL4 server unlike HP-UX serves :

Getting error : xinetd [4092] :FAIL: telnet service_limit

Just change session limit from 60 for instances to some large number

#
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
instances = 400
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}

service telnet2
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}

#[root@host]# service xinetd reload


10.  How to check kernel in RHEL4 ?


[root@server ~]# file /sbin/init
/sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped


11. Checking memory:

grep Mem /proc/meminfo



12. Create partition on RHEL :Redhat Enterprise Linux without reboot :

[root@ice ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 8e Linux LVM
/dev/sda3 1319 1579 2096482+ 82 Linux swap

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (1580-2610, default 1580):
Using default value 1580
Last cylinder or +size or +sizeM or +sizeK (1580-2610, default 2610):
Using default value 2610

Command (m for help): p

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1318 10482412+ 8e Linux LVM
/dev/sda3 1319 1579 2096482+ 82 Linux swap
/dev/sda4 1580 2610 8281507+ 5 Extended
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Finally type partprobe to make parition change available to Redhat enterprise Linux (RHEL4) without reboot :

[root@ice ~]# partprobe /dev/sda

13. In RHEL4 (redhat hat enterprise Linux 4 AS ) running kernel 2.6 the number of open files per process is still limited to 1024. you can do ulimit -a to see number of open files per user :

[root@firefox] /# ulimit -a

core file size (blocks) 1000000
data seg size (kbytes) unlimited
file size (blocks) unlimited
max memory size (kbytes) unlimited
stack size (kbytes) 8192
cpu time (seconds) unlimited
max user processes unlimited (1)
pipe size (512 bytes) 8
open files 1024
virtual memory (kbytes) 2105343


To Increases the system limit on open files for instance a process on change the number of open files for Oracle , IB DB2 databases in redhat enterprise Linux (RHEL4) :

#ulimit -n 90000

To make changes permanent add soft and hard limits in /etc/security/limits.conf file :

* soft nofile 90000
* hard nofile 90000


14. How to enable root telnet for redhat enterprise Linux RHEL4:

To enable direct telnet for root account on redhat linux enterprise servers ( i have done wthis on RHEL3 and RHEL4 without any issues ) over the network :

under /etc/ directory edit /etc/securetty file and add pts entries :

pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
pts/6
pts/7
pts/8
pts/9
pts/10

or Just remove /etc/securetty file alltogether , i prefer moving /etc/securetty it.

mv /etc/securetty /etc/securetty.sav

Bingo root telnet is enabled now ... on redhat enterprise Linux 4 .That's all you need to do to enable telnet access for root account on Linux servers. Root access is activated right away you don't need to restart any services on redhat linux .


Warning : telnet is not secure and you should be using SSH only for logins on RHEL4.Keep reading redhatcert blog to find out how to enable SSH logins on redhat enterprise Linux 4.


15. configure kernel parameters in redhat enterprise Linux :


How to turn off ping response in redhat Linux :

#cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0

Zero means ping is enable and Linux machine will respond to ping requests.

# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

This kernel change is not permanent , to make it permanent add to /etc/sysctl.conf :

net.ipv4.icmp_echo_ignore_all=1



16. How to enable telnet services on Redhat enterprise Linux :

# chkconfig telnet --list
#chkconfig telnet on
#chkconfig --level 35 telnet on

where 3 and 5 are run levels , so telnet will run when Linux is running in runlevel 3 and 5 only.


17. You shoud know how to change Redhat Linux system default run level for RHCE and RHCT exam preparation and questions :

1. edit /etc/inittab file and changerun level from level 5 (which is X or GUI mode ) to run level 3


# vi /etc/inittab
id:3:initdefault:

2. simply reboot the server and your default run level changes to level 3 which is text based linux session.

3.How to dynamically change the runlevel of Linux system without rebooting


e.g: switch to single user mode :
# telinit S
e.g: switch to X or GUI (desktop) mode
#telinit 5
e.g:If you have made changes to the /etc/inittab file to change the default runlevel and want to change the system to that new default you can do so by using the telinit with the q command-line option:
# telinit q



18. You shoud know how to change Redhat Linux system default run level for RHCE and RHCT exam preparation and questions :

1. edit /etc/inittab file and changerun level from level 5 (which is X or GUI mode ) to run level 3


# vi /etc/inittab
id:3:initdefault:

2. simply reboot the server and your default run level changes to level 3 which is text based linux session.

3.How to dynamically change the runlevel of Linux system without rebooting


e.g: switch to single user mode :
# telinit S
e.g: switch to X or GUI (desktop) mode
#telinit 5
e.g:If you have made changes to the /etc/inittab file to change the default runlevel and want to change the system to that new default you can do so by using the telinit with the q command-line option:
# telinit q

No comments:

Post a Comment