Sie sind auf Seite 1von 129

List out 10 commands which you now in

unix/linux ?
cd /directoryname         - change directory
ls -ltr - list files
pwd - present working directory
touch - create an  empty file
mkdir - create a new directory
rmdir - remove an empty directory
rm -rf - remove file forecefully and recursevily
chmod - change file/ directory persmissions
chown - change owner of the file or directory

================================
Explain ls command usage?

ls
1. How do you check the list of files and directories timestamp wise ?
   ls -ltr

2. How to check hidden files in  a directory ?


   ls -ltra

3. How to see the long list of files ?


   ll

cd - command usage
cd - change directory

1. Go to one directory backwards


cd ..
2. Go to Home directory
cd ~

3. Go to last directory
cd -

4. Go to a particular directory
cd /etc

mkdir command usage


mkdir  : Allows to  create single or multiple directories

create one directory

mkdir one

create three directories in the present directory

mkdir one two three

create directories as per the hierarchy defined

mkdir -p one/four/six

==

=
rmdir - command usage
rmdir : This command removes empty directories

Example:

 1. To remove single directory

rmdir dir1

2. To remove multiple directories

rmdir dir1 dir2 dir3

3. To direcory , sub direcory if they are empty

rmdir -p dir1/subdir1

cat command in Linux


cat command: can be used to
1. View contents of file
2. Create files
3. Concatenate files
4. Redirect output.

Examples of Cat :

Display contects of file:-


cat /etc/passwd

View contents of a file:-


cat file1 file2

Create a file :-
cat >testfile

Redirecting output of a file


cat testfile1> testfile2
cat filea fileb > filec
=

Linux Commands Cheat Sheet

Contents [hide]
 1 – SYSTEM INFORMATION
 2 – HARDWARE INFORMATION
 3 – PERFORMANCE MONITORING AND STATISTICS
 4 – USER INFORMATION AND MANAGEMENT
 5 – FILE AND DIRECTORY COMMANDS
 6 – PROCESS MANAGEMENT
 7 – FILE PERMISSIONS
 8 – NETWORKING
 9 – ARCHIVES (TAR FILES)
 10 – INSTALLING PACKAGES
 11 – SEARCH
 12 – SSH LOGINS
 13 – FILE TRANSFERS
 14 – DISK USAGE
 15 – DIRECTORY NAVIGATION
1 – SYSTEM INFORMATION
# Display Linux system information
uname -a

# Display kernel release information


uname -r

# Show which version of redhat installed


cat /etc/redhat-release

# Show how long the system has been running + load


uptime

# Show system host name


hostname

# Display the IP addresses of the host


hostname -I

# Show system reboot history


last reboot

# Show the current date and time


date

# Show this month's calendar


cal

# Display who is online


w

# Who you are logged in as


whoami
2 – HARDWARE INFORMATION
# Display messages in kernel ring buffer
dmesg

# Display CPU information


cat /proc/cpuinfo

# Display memory information


cat /proc/meminfo

# Display free and used memory ( -h for human readable,


-m for MB, -g for GB.)
free -h

# Display PCI devices


lspci -tv

# Display USB devices


lsusb -tv
# Display DMI/SMBIOS (hardware info) from the BIOS
dmidecode

# Show info about disk sda


hdparm -i /dev/sda

# Perform a read speed test on disk sda


hdparm -tT /dev/sda

# Test for unreadable blocks on disk sda


badblocks -s /dev/sda
3 – PERFORMANCE MONITORING AND
STATISTICS
# Display and manage the top processes
top

# Interactive process viewer (top alternative)


htop

# Display processor related statistics


mpstat 1

# Display virtual memory statistics


vmstat 1

# Display I/O statistics


iostat 1

# Display the last 100 syslog messages  (Use


/var/log/syslog for Debian based systems.)
tail 100 /var/log/messages

# Capture and display all packets on interface eth0


tcpdump -i eth0

# Monitor all traffic on port 80 ( HTTP )


tcpdump -i eth0 'port 80'

# List all open files on the system


lsof

# List files opened by user


lsof -u user

# Display free and used memory ( -h for human readable,


-m for MB, -g for GB.)
free -h

# Execute "df -h", showing periodic updates


watch df -h
4 – USER INFORMATION AND
MANAGEMENT
# Display the user and group ids of your current user.
id

# Display the last users who have logged onto the system.
last

# Show who is logged into the system.


who

# Show who is logged in and what they are doing.


w

# Create a group named "test".


groupadd test

# Create an account named john, with a comment of "John


Smith" and create the user's home directory.
useradd -c "John Smith" -m john

# Delete the john account.


userdel john

# Add the john account to the sales group


usermod -aG sales john
5 – FILE AND DIRECTORY COMMANDS
# List all files in a long listing (detailed) format
ls -al

# Display the present working directory


pwd

# Create a directory
mkdir directory

# Remove (delete) file


rm file

# Remove the directory and its contents recursively


rm -r directory

# Force removal of file without prompting for


confirmation
rm -f file

# Forcefully remove directory recursively


rm -rf directory

# Copy file1 to file2


cp file1 file2

# Copy source_directory recursively to destination. If


destination exists, copy source_directory into
destination, otherwise create destination with the
contents of source_directory.
cp -r source_directory destination

# Rename or move file1 to file2. If file2 is an existing


directory, move file1 into directory file2
mv file1 file2

# Create symbolic link to linkname


ln -s /path/to/file linkname

# Create an empty file or update the access and


modification times of file.
touch file

# View the contents of file


cat file

# Browse through a text file


less file

# Display the first 10 lines of file


head file

# Display the last 10 lines of file


tail file

# Display the last 10 lines of file and "follow" the file


as it grows.
tail -f file
6 – PROCESS MANAGEMENT
# Display your currently running processes
ps

# Display all the currently running processes on the


system.
ps -ef

# Display process information for processname


ps -ef | grep processname

# Display and manage the top processes


top

# Interactive process viewer (top alternative)


htop

# Kill process with process ID of pid


kill pid

# Kill all processes named processname


killall processname

# Start program in the background


program &

# Display stopped or background jobs


bg

# Brings the most recent background job to foreground


fg

# Brings job n to the foreground


fg n
7 – FILE PERMISSIONS

        PERMISSION      EXAMPLE

         U   G   W
        rwx rwx rwx     chmod 777 filename
        rwx rwx r-x     chmod 775 filename
        rwx r-x r-x     chmod 755 filename
        rw- rw- r--     chmod 664 filename
        rw- r-- r--     chmod 644 filename

# NOTE: Use 777 sparingly!

        LEGEND
        U = User
        G = Group
        W = World
        r = Read
        w = write
        x = execute
        - = no access
8 – NETWORKING
# Display all network interfaces and ip address
ifconfig -a

# Display eth0 address and details


ifconfig eth0

# Query or control network driver and hardware settings


ethtool eth0

# Send ICMP echo request to host


ping host

# Display whois information for domain


whois domain

# Display DNS information for domain


dig domain

# Reverse lookup of IP_ADDRESS


dig -x IP_ADDRESS

# Display DNS ip address for domain


host domain

# Display the network address of the host name.


hostname -i

# Display all local ip addresses


hostname -I

# Download http://domain.com/file
wget http://domain.com/file

# Display listening tcp and udp ports and corresponding


programs
netstat -nutlp
 

9 – ARCHIVES (TAR FILES)


# Create tar named archive.tar containing directory.
tar cf archive.tar directory

# Extract the contents from archive.tar.


tar xf archive.tar

# Create a gzip compressed tar file name archive.tar.gz.


tar czf archive.tar.gz directory

# Extract a gzip compressed tar file.


tar xzf archive.tar.gz

# Create a tar file with bzip2 compression


tar cjf archive.tar.bz2 directory

# Extract a bzip2 compressed tar file.


tar xjf archive.tar.bz2
10 – INSTALLING PACKAGES
# Search for a package by keyword.
yum search keyword

# Install package.
yum install package

# Display description and summary information about


package.
yum info package

# Install package from local file named package.rpm


rpm -i package.rpm

# Remove/uninstall package.
yum remove package

# Install software from source code.


tar zxvf sourcecode.tar.gz
cd sourcecode
./configure
make
make install
11 – SEARCH
# Search for pattern in file
grep pattern file

# Search recursively for pattern in directory


grep -r pattern directory

# Find files and directories by name


locate name

# Find files in /home/john that start with "prefix".


find /home/john -name 'prefix*'

# Find files larger than 100MB in /home


find /home -size +100M
12 – SSH LOGINS
# Connect to host as your local username.
ssh host

# Connect to host as user


ssh user@host

# Connect to host using port


ssh -p port user@host
13 – FILE TRANSFERS
# Secure copy file.txt to the /tmp folder on server
scp file.txt server:/tmp

# Copy *.html files from server to the local /tmp folder.


scp server:/var/www/*.html /tmp

# Copy all files and directories recursively from


server to the current system's /tmp folder.
scp -r server:/var/www /tmp
# Synchronize /home to /backups/home
rsync -a /home /backups/

# Synchronize files/directories between the local and


remote system with compression enabled
rsync -avz /home server:/backups/

14 – DISK USAGE
# Show free and used space on mounted filesystems
df -h

# Show free and used inodes on mounted filesystems


df -i

# Display disks partitions sizes and types


fdisk -l

# Display disk usage for all files and directories in


human readable format
du -ah

# Display total disk usage off the current directory


du -sh
15 – DIRECTORY NAVIGATION
# To go up one level of the directory tree.  (Change into
the parent directory.)
cd ..

# Go to the $HOME directory


cd

# Change to the /etc directory


cd /etc

https://www.linuxtrainingacademy.com/linux-commands-cheat-sheet/
https://plsqlblog.blogspot.com/p/interview-questions.html

==

What is Linux?
Ans:Linux is an operating system, multitask GUI based open source
operating system developed by Linus Torvalds. We use the term
“Linux” refer to Linux kernel, Comprises the set of programs, tools,
and services that are typically bundled together with the Linux
kernel to provide all of the necessary components of a fully
functional operating system. Linux is most-used open source
operating system. Linux is a Multi Tasking , Multi User, Multi Process
operating system.
Linux Operating system is widely used in smartphones to cars,
supercomputers and home appliances.

What is the core of Linux Operating System?

1. Shell

2. Scripting

3. Kernel

4. Command

5. Terminal
Shell: A command process that allows you to control the computer
via commands typed into a text interface.
Scripting: A shell script is a computer program designed to be run
by the shell, a command-line interpreter.
Kernel: Kernel is the core of the system and manages the CPU,
memory, and peripheral devices.
Command:A command is an instruction given by a user telling a
computer to do something, such a run a single program or a group
of linked programs.
Terminal:The terminal is a container for the shell (or any other
program). It provides input (through connected input devices) and
displays output.
What is the basic difference between UNIX and Linux
Operating System?
Answer : Linux Operating System is Free and Open Source
Software, the kernel of which is created by Linus Torvalds and
community. UNIX Operating System doesn’t comes under the
category of Free and Open Source Software, BSD, is a variant of
UNIX which comes under the category of FOSS. Moreover Big
companies like Apple, IBM, Oracle, HP, etc. are contributing to UNIX
Kernel.
 What is LILO?
 LILO is Linux Loader is a boot loader for Linux. It is used to load
Linux into the memory and start the Operating system. LILO can be
configured to boot other operating systems as well.LILO is also a
code snippet which loads PC BIOS into the main memory at the time
of starting the computer system.
What is the advantage of Linux?
Every aspect comes with additional features and it provides a free
downloading facility for all codes.

What is BASH?
 
BASH is a short form of Bourne Again SHell. It was a replacement to
the original Bourne shell, written bu Steve Bourne

What is the maximum length for a file name in Linux?


255 characters.

What are the file permissions in Linux?


There are 3 types of permissions in Linux OS that are given below:

 Read: User can read the file and list the directory.

 Write: User can write new files in the directory .

 Execute: User can access and run the file in a directory.


Linux Interview Questions and answers for L2 and L3 Engineers
Author: Joice Joseph 1 Comment

To set SGID
*  What are the process states in linux

  *  How to find out the linux kernel version and how to upgrade
kernel ?.
  To check the kernel version use any of the following command.
[root@node213 ~]# uname -a
Linux node213.example.com 2.6.18-348.el5 #1 SMP Wed Nov 28
21:22:00 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@node213 ~]# uname -r
2.6.18-348.el5
[root@node213 ~]# cat /proc/version
Linux version 2.6.18-348.el5 (mockbuild@x86-
002.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-
54)) #1 SMP Wed Nov 28 21:22:00 EST 2012
To upgrade the kernel , download the kernel rpm file and install it
using rpm -ivh

command. Don’t use rpm -Uvh, because it will upgrade the existing kernel and we

won’t able to go to the previous kernel version at any point of time. If we require

to remove the old kernel, use rpm -e and also remove the entry form

/etc/grub.conf file.

*  List the 6 stages of boot process ?

BIOS,  MBR,  GRUB, Kernel, init, runlevel.

*  How to mount an ISO file ?

[root@node213 mnt]# mount   -o   loop   /tmp/rhel-server-7.0-x86_64-dvd.iso   /

mnt

*  Which are the runlevels in linux ?

runlevel 0  –  Halt/ Shutdown .

runlevel 1  –  Single user mode.

runlevel 2  –  Multi user mode without network.

runlevel 3  –  Multi user mode with network.

runlevel 4  –  unused.

runlevel 5  –  Graphical.

runlevel 6  –  Reboot

*  Explain the entries in fstab ?


[root@node213 mnt]# cat /etc/fstab

LABEL=/1                       /                    ext3    defaults        1 1

LABEL=/home               /home             ext3    defaults        1 2

LABEL=/boot                /boot              ext3    defaults        1 2

device to mount mount point file system type mount options dump fscheck.

Mount Options :

ro  –  read only,  rw  –  read write,  user  –  user can mount,  exec  –  script can be

execute,  noexec  –  script can’t be execute,  noauto  –  partition will not mount

automatically,  auto  –  mounts automatically,  sync  –  input and output will

synchronize.

Dumping and fsck

Dumping is an outdated option for backup for cases when system went down, 0 –

stands for False and 1 – stands for true. Now a days we can leave this as 0.

fsck – This parameters is for file system check . The partitions  will go for fsck

based on the order given. The / partition should have value 1 and next partitions

can take 2,3.. as well. 0 stands for no fsck.

*  Explain about file system ?

File system is the hierarchy of directories that is used to organize files in

computer.Each file system contains a control block ( which contains information

about that file system ) and inodes ( Which contains information about each files

and data blocks).

Metadata contains the information about the entire data (one or more pieces of
data) , ie file name, owner,creation date, location etc. whereas inode is a type of

metadata which contains the information about a regular file, directory, or other

file system object such as permission, owner and group, file size, access and

modification time, number of links etc . Linux never store the file creation time.

Superblock is a filesystem metadata which defines the file system type, size,

status, and information about other metadata structures.The superblock is the

very critiical to the file system and thus in each file system there may be multiple

copies of superblock. Incase superblock become corrupt and at that point of time

fsck will automatically select an alternate backup of the superblock and attempt

to recover the filesystem. For the manual recovery of superblock, we can use

dumpe2fs command to find out the backup and then fsck.

[root@node213 mnt]# dumpe2fs /dev/sda2 |grep -i superblock

dumpe2fs 1.39 (29-May-2006)

Primary superblock at 0, Group descriptors at 1-5

Backup superblock at 32768, Group descriptors at 32769-32773

Backup superblock at 98304, Group descriptors at 98305-98309

Backup superblock at 163840, Group descriptors at 163841-163845

Backup superblock at 229376, Group descriptors at 229377-229381

Backup superblock at 294912, Group descriptors at 294913-294917

superblocks are existing on the first sector of a filesystem. It contains the location

of inode table.

  *  How can convert from one file system to another ?.


To convert from ext2 to ext3,
1) umount the partiton
2) tune2fs -j
3) change the fstab entry (change 3rd parameter as ext3)
4) reboot or mount file system.
To convert from ext3 to ext4
1) umount the partition
2) [root@node213 tmp]# tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
3) fsck -pf /dev/sdb1
4) mount -t ext4 /dev/sdb1
5) Change fstab entry.and reboot
No need to format the filesystem after conversion. tune2fs -l command will list
the current features of the file system.
  *  Explain about Linux users and groups ?.
Linux consist of three types of users
1)  system user  (id 0 to 499)
2)  root user  (id  =  0)
3) Local users  (id >499).
useradd command will add new users and at that time /etc/passwd
/etc/shadow /etc/group files get updated. To lock and unlock the user we can
use usermod  command.
To check whether a user account is locked, use passwd -S . chage -l will shows
various timers
  *  What is sticky bit and file attributes ?.
The sticky bit can be assigned to file or directory. If sticky bit is enabled, only the
owner or root can delete or rename that file or directory.
To add sticky bit use chmod +t   ( +t  – will add sticky bit, o-t   –  will remove)  or
chmod 1 644 .
[feapadmin@node212 ~]$ chmod 1644 temp1.txt
[feapadmin@node212 ~]$ ls -ltr
total 0
-rw-r–r-T 1 feapadmin feapadmin 0 Mar  1 18:11 temp1.txt
The “T” in the output denotes that sticky bit is enabled.
The attributes is nothing it is prevent anyone including root user from deleting a
file. attributes can be set through chattr command.
[root@node213 /]# chattr +i jo.txt
[root@node213 /]# lsattr jo.txt
—-i——– jo.txt
[root@node213 /]# rm jo.txt
rm: remove write-protected regular empty file `jo.txt’? y
rm: cannot remove `jo.txt’: Operation not permitted
To delete the file we have to remove the attributes using chattr -i command.
  *  What is ACL
Access control list can be set to files and directories for read, write and
executable permissions to more categories of users and groups. setfacl command
can be use to assign the acl permissions and same can view by using getfacl
command.

  *  What is SGID and SUID

SUID (Set owner User ID up on execution) is a special type of file permissions

given to a file. Normally in Linux/Unix when a program runs, it inherits access

permissions from the logged in user. SUID is defined as giving temporary

permissions to a user to run a program/file with the permissions of the file owner

rather that the user who runs it. In simple words users will get file owner’s

permissions as well as owner UID and GID when executing a

file/program/command.

[root@server1 ~]# ls -ltr /usr/bin/passwd

-r-sr-sr-x. 1 root root 30768 Feb 17  2012 /usr/bin/passwd

The first s stands for SUID and second S stands for SGID.

SUID can be used in such situations,

1) Where root login is required to execute some commands/programs/scripts.

2) Where you don’t want to give credentials of a particular user, but want to run some
programs as the owner.

3) Where you don’t want to use SUDO command, but want to give execute permission for a
file/script etc.

To set SUID

[root@server1 ~]#  chmod  4555 .


[root@server1 tmp]# ls -ltr

-r-sr-xr-x 1 root root 0 Mar  1 23:47

SGID permission is similar to the SUID permission, only difference is – when the

script or command with SGID on is run, it runs as if it were a member of the same

group in which the file is a member.

[root@server1 ~]#  chmod 2555

[root@server1 tmp]# ls -ltr

-r-xr-sr-x 1 root root 0 Mar  1 23:47

*  How we can check system performance?

a)  CPU utilization  –  To check CPU performance use the following commands,

1)  top  –  It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer

Size, Process PID, User, Commands and much more

2)  vmstat  –  To display statistics of virtual memory, kernerl threads, disks, system

processes, I/O blocks, interrupts, CPU activity and much more.

3)  lsof  –  To display list of all the open files and the processes. The open files

included are disk files, network sockets, pipes, devices and processes.

4)  tcpdump  –  A command-line network packet analyzer or packets sniffer

program that is used capture or filter TCP/IP packets that received or transferred

on a specific interface over a network.

5)  netstat  –  A command line tool for monitoring incoming and outgoing network
packets statistics as well as interface statistics.

6)  iotop  –  monitor and display real time Disk I/O and processes. This tool is

much useful for finding the exact process and high used disk read/writes of the

processes.

7)  iostat  –  This will collect and show system input and output storage device

statistics.This tool is often used to trace storage device performance issues

including devices, local disks, remote disks such as NFS.

8)  iptraf  –   An open source console-based real time network (IP LAN)

monitoring utility for Linux. It collects a variety of information such as IP traffic

monitor that passes over the network, including TCP flag information, ICMP

details, TCP/UDP traffic breakdowns, TCP connection packet and byne counts. It

also gathers information of general and detaled interface statistics of TCP, UDP,

IP, ICMP, non-IP, IP checksum errors, interface activity etc.

9)  sar  –  Sar is part of the sysstat package. Using sar utility you can do two

things: 1) Monitor system real time performance (CPU, Memory, I/O, etc) 2)

Collect performance data in the background on an on-going basis and do analysis

on the historical data to identify bottlenecks.

10)  free  –  Free command displays information about the physical (RAM) and

swap memory of your system.

b)  RAM usage  –  free , cat /proc/meminfo, top, can be used to monitor memory

usage.

c)  HDD usage  –  iotop,  iostat,

d)  buggy Software  –  Check the software logs .

e)  Network Checking
  *  What is Server hardening?

It is the process of enhancing server security through a variety of means which

results in a much more secure server operating environment. Eg, System access

level, fies or directories permission, unwanted services disabling, patch installtion

etc..

  *  How to scan and mount newly added LUN in RHEL without reboot?

Once after a new LUN connected to a Linux box through HBA card, we can run

the “rescan-scsi-bus.sh ” command which comes with  sg3_utils rpm. Once we

finished the script execution, we can able to see the new LUN as raw disk through

fdisk utility.

[root@server1 ~]# which rescan-scsi-bus.sh

/usr/bin/rescan-scsi-bus.sh

[root@server1 ~]# rpm -qf /usr/bin/rescan-scsi-bus.sh

sg3_utils-1.28-4.el6.x86_64

* Explain system/ kernel level tuning with example?

The default UNIX kernel behavior is sub-optimal out of the box because it is

difficult to anticipate what type of work or workload the operating system will be

assigned. Therefore, UNIX products provide parameters that may change the

allocation of critical resources.

Eg. File Handling Limit  –  The kernel has built-in limits on the number of files that

a process can open.


[root@server1 ~]# cat /proc/sys/fs/file-max

66034

To change the value temporary,


[root@server1 ~]# sysctl -w fs.file-max=100000
fs.file-max = 100000
 To change the value permanently
[root@server1 ~]# vi /etc/sysctl.conf
and add the edit the entry as  fs.file-max = 100000.
To save the changes run
[root@server1 ~]# sysctl -p
Like this we can do socket tuning, process scheduling, etc.

*  What is the impact of inode fill in file system.

*  What is multipathing in linux

*  What is hotspare and hotswap ?

*  Explain about Nagios monitoring tool ?

The NRPE ( Nagios Remote Plugin Executor ) agent will send all the alerts related

CPU load, Swap, Memory usage, Online users, etc.  to the nagios monitoring

server through port 5666.

*  Why xinetd daemon required ?

The xinetd stands for Extended Internet Services.The xinetd service listens on all

ports used by the daemons it controls. When a connection is requested, xinetd

determines if the client is allowed access. If the client is allowed access, xinetd

starts up the desired service and allows the client to connect.


*   What is the status code 403,404 represented in apache server?

403 represent forbidden error, means if a file misses some selinux security context.
404 represent that there is a cgi script missing or web pages missing.
 
  *  What is a zombie process?

  Zombie often called process is a process state when the child dies before the

parent process. In this case the structural information of the process is still in the

process table

*  Which daemon tracks the events on the linux server.

                                The syslogd daemon tracks all the events of linux server and
maintain the log files.

 *  What are the difference between hard links and soft links.

                           Soft link or symbolic link or symlink is same as shortcuts in


windows OS, an easiest way to link files or directories .
#  ln  -s  source_file  link_file    –   To create soft link.
#  ln   source_file  link_file   –   To create hard link.
Difference  Parameter
Soft Link
Hard Link
Inode
Inode will be different for both the files
Inode will be same for both the files
Deletion of original file
Deletion of original file, impact on link. Another file will not be accessible.
Deletion of original file, no impact on link. Another file will be accessible.
Time to execute
Access time is slow as compared to hard link
Access time is fast as compared to soft link
Cross File System
In Cross file system, Soft link works
In cross file system, hard link is not working. Needed same file system

 *  What is inode number

                        Inode number or Index number is the entry in inode table


containing the informations ( metadata ) of a file or directories . To check the
inode number of file or directory , do as follows

[root@server1 tmp]#   ls -li inode_testing.txt

  1179668 -rw-r–r– 1 root root 0 Sep 29 11:36 inode_testing.txt

                               The first field in the above output is the inode number


(1179668) . While copying a file or directory the inode number may also change ,
ie it may allocate a new entry in inode table. While moving, inode number will be
same only if the file system is same. Inode number contains the informations like
file access, modification, created date and time, group, number of links, owner,
permission, etc..

  *  How to review the boot messages


 

                             We can review the logs from /var/log/messages file. or for


better way use dmesg command.
  *  How to make system log rotation to avoid disk space usage

                                             The /etc/logrotate.conf file can be used to rotate the


system logs.

  *  What is  /etc/passwd file.

                            The passwd file contains the user account information such as


user id, group id, home directory, shell etc..
#  getent passwd |grep redhat      or    #  cat /etc/passwd

redhat : x : 500 : 500 : redhat-user : /home/redhat : /bin/bash


  (1)     (2)  (3)    (4)         (5)                   (6)                 (7)

The first one is the user name (root) . Second field stands the password, x

indicates encrypted password in the /etc/shadow file. Third field is user id (UID),

UID 0 is assigned for root user and 1 to 499 is using by other predefined

accounts. Fourth field is the group id (GID) stored in /etc/group file. Fifth field is

the user ID info location where we can add users such as users full name,phone
number etc. . The sixth field is for user home directory . The last and seventh field

provides the shell path assigned for the user.

  *  What is shadow file in linux.

                     The shadow file stores the actual password in encrypted format . It


stores a secured user information. Each fields are separated by ( : ).
#  cat  /etc/shadow

redhat : $6$cIBzWB05$kqCbIvlNpyz : 16276 : 0 : 99999 : 7 : : :

  (1)                        (2)                                (3)    (4)    (5)     (6)

         First field is the user name . Second field is the password which is in
encrypted  format. Third field gives the number of days since Jan 1 1970 the
password was last changed. Fourth field stands for number of minimum days
which the user can change his password, 0 stands for user can change password
at any time. Fifth fields stands for the number of days after which password must
be changed. Sixth field stands for the number of days to warn the user of an
expiring password .  Seventh field stands for the number of days the after
password expires the account is disabled . Eight field stands for the number of
days the since Jan 1 1970 that an account has been disabled.  The nine field is
kept reserved for future use.
 

*  What is the importance of updating the kernel and package versions.

                           To enhance the security of the system we should be ensure that


we are upgraded to latest kernel version and software packages which contain
recent security updates.

  *  What is the use of sar command.

                           The sar command collect, report, or save system activity


information . It save the information in /var/log/sa directory.

 *  What is network bonding and network aliases

                                    Bonding is a Linux kernel feature that allows us to aggregate


multiple interfaces (such as eth0, eth1) into a single virtual link such as bond0.
This method is  simple to get higher data rates and as well as link failover.

 
                      Network alias in linux allows us to add additional network address of
same subnet to a single network interface. Eg . eth0:0, eth0:1, etc.

  *  What is the role of luci and ricci in redhat clustering.

                          luci is a service which presents the web based cluster interface via
https at port 8084. ricci service is the underlying daemon that that helps in cluster
configuration sync and file copy , cluster service stop start etc. .It uses tcp port
11111.

    *  What is the difference between root_squash & no_root_squash in NFS.

 
root_squash – If we are putting root_squash, then it will map root UUID/ GID to
anonymous UUID/GID. So in client side the client root user will be denied for
accessing, creating file in mounted NFS partition.

no_root_squash  – In no_root_squash , It won’t map root UUID/GID to


anonymous user and thus the client root user have all the privileges on the
mounted NFS partition.

*  What command we can  use to find currently mounted drives

                                To find currently mounted drives, the simplest method is to use


the mount command. Other commands that can tell about mounted drives are cat
/etc/mtab and df.

  *  What command we can  use to add the /usr/sbin directory to PATH.

PATH=$PATH:/usr/sbin command. To make it permenent add this entry in


.bash_profile file.

  
 

  *  From where we can find more information associated with your CPU

                              Most closely associated with information on the CPU is


/proc/cpuinfo . Along with that /var/log/dmesg will gives less informations.

Running : The process is either running or it is ready to run .


Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
  *  What is the difference between Ext2, Ext3, and Ext4
                                  The most important difference in Ext2 and Ext3 is Ext3
support journaling. After an unexpected power failure or system crash or unclean
system shutdown Ext2 file system may checked for consistency check using
e2fsck program . The time taken to recover Ext3 filesystem  is only depend on the
default journal size irrespective of the size of filesystem or number of files. Ext4
stands for fourth extend file system. It also support journaling.
Ext2  ==  Maximum file size  –  16GB to 2 TB.
                Maximum filesystem size  –  2 TB to 32 TB.
Ext3  ==  Maximum file size  –  16GB to 2 TB.
                Maximum filesystem size  –  2 TB to 32 TB
Ext4  ==  Maximum file size  –  16GB to 16 TB.
                Maximum filesystem size  –  1 EB.
  *  How to change the expiration date of user password
                               We can use chage command to change the password expiry of
a user.
Q:: What Is a Port Number?

 A port number is part of the addressing information used to identify the senders and receivers
of messages. Port numbers are most commonly used with TCP/IP connections. Home network
routers and computer software work with ports and sometimes allow you to configure port
number settings. These port numbers allow different applications on the same computer to share
network resources simultaneously.

Q. What is the range of ports or how many ports are there? 


Port numbers can vary from 0 to 65535, so total we can get 65536 ports 

Q. Why port numbers are just 65536? 


This is because limitation in TCP/IP stacks where the port field is just 16bit size. So we get only
2^16 port which is equal to 65536 ports

Port numbers have a range of 0…65535 (although often 0 has special meaning). In the original
BSD TCP implementation, only root can bind to ports 1…1023, and dynamically assigned ports
were assigned from the range 1024…5000; the others were available for unprivileged static
assignment. These days 1024…5000 is often not enough dynamic ports, and IANA has now
officially designated the range 49152..65535 for dynamic port assignment. However even that is
not enough dynamic ports for some busy servers, so the range is usually configurable (by an
administrator). On modern Linux and Solaris systems (often used as servers), the default
dynamic range now starts at 32768. Mac OS X and Windows Vista default to 49152..65535.
 
[root@desktop12 ~]# cat /proc/sys/net/ipv4/ip_local_port_range
32768   61000
 
solaris$ /usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port
32768
 
65535
 
macosx$ sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
 
vista> netsh int ipv4 show dynamicport tcp
Protocol tcp Dynamic Port Range
 
Start Port : 49152
Number of Ports : 16384

Q.What are the well-known ports? 


Well known ports are from 0 to 1023(total 2^10=1024 ports) 

Q.What are the Registered Ports, and    (Range:  1024 to 49151 )


Used by specific service upon applications such as Oracle database listener (1521), MySql
(3306), Microsoft Terminal server (3389) etc.

Q.What are the Dynamic and/or Private Ports. (Range: 49152 to 65535 )

These ports can’t be registered by IANA.  This is used for custom or temporary purposes and for
automatic allocation of short-lived (or ephemeral ) ports which is used internally by
application/processes. You can see these ports by running ‘netstat’ command under “Local
address” column.

Q.What do you mean by default port? Default port is a designated port for particular well-
known server. 

Q.Can we change default port for a service(example Apache, squid)? 


Yes, we can change

Q.What are the protocol numbers for TCP and UDP? 


TCP protocol number:6
UDP protocol number:17

Q.How to find which ports are open? 


You can find the ports in your linux server with the nmap command
#netstat -ntlp 
  here n -> display the host by numbers 
           t  ->shows tcp protocols 
           u ->to check udp protocols 
           l ->listening ports 
          p -> displays which process controls the port 
Q.How to find printer open ports  ?
[root@desktop13 Desktop]# netstat -ntlp |grep cups
tcp        0      0  127.0.0.1:631               0.0.0.0:*                   LISTEN      1525/cupsd
tcp        0      0   ::1:631                             :::*                        LISTEN      1525/cupsd    Q. How to
detect remote server openports? 
[root@desktop13 Desktop]# nmap -sT 192.168.0.250 
it will show like this
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
Q. How to change SSH port number?
[root@desktop13 Desktop]# netstat -ntlp | grep ssh
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1646/sshd
tcp        0      0 :::22                               :::*                        LISTEN      1646/sshd    
go to the configuration file
[root@desktop13 Desktop]# vim /etc/ssh/sshd_config
port=2200
save and quit
 
[root@desktop13 Desktop]# service sshd restart

Stopping sshd:                                             [  OK  ]


Starting sshd:                                             [  OK  ]

[root@desktop13 Desktop]# netstat -ntlp | grep ssh


tcp        0      0 0.0.0.0:2200                0.0.0.0:*                   LISTEN      11904/sshd
tcp        0      0 :::2200                          :::*                        LISTEN      11904/sshd       
 
   now port num changed successfully

Q. rempte loggin with port number?


 
ssh -p 22 root@192.168.0.111
 
Some important port numbers:
20-FTP Data (For transferring FTP data)
 
21-FTP Control (For starting FTP connection)
 
22-SSH (For secure remote administration which uses SSL to encrypt the transmission)
 
23-Telnet (For insecure remote administration
 
25-SMTP (Mail Transfer Agent for e-mail server such as SEND mail)
 
53- DNS (Special service which uses both TCP and UDP)
 
68-DHCP
 
69-TFTP (Trivial file transfer protocol uses udp protocol for connection less transmission of
data)
 
80 -HTTP/WWW (apache)
 
88-Kerberos
 
110-POP3 (Mail delivery Agent)
 
123-NTP (Network time protocol used for time syncing uses UDP protocol)
 
137-NetBIOS (nmbd)
 
139,138,445-SMB-Samba (smbd)
 
143-IMAP
 
161-SNMP (For network monitoring)
 
389-LDAP (For centralized administration)
 
443-HTTPS (HTTP+SSL for secure web access)
 
514-Syslogd (udp port)
 
995-POP3s
 
3260-ISCSI
 
3128-squid proxy
 
631-Printers (cups)
 
2049-NFS (nfsd, rpc.nfsd, rpc, portmap)
 
*If protocol is not mention then the above port are solely for TCP. Some service use UDP as
mention in above list.

MY LINUX INTERVIEW EXPERIENCE WITH A


COMPANY- WRITTEN TEST QUESTIONS: PART 1
In Unix everything is a ________

Ans: File2.
2. What is the command to make a file executable?

Ans: Chmod +x filename

3. What is the name of the file that contains hostname?

Ans: /etc/hosts

4. What is the FTP mode for transferring text files?

Ans:  There are two common modes for transferring files via FTP, ascii and binary.

 Ascii mode transfers files as ‘text’.   Examples of ascii files would be .txt, .asp,

.html, and .php files…

 Binary mode transfers files as raw data.    Examples of binary files would be .wav,

.jpg, .gif, and mp3 files…

 The file transfer type is ASCII by default.

5. What is the IP Address in Virtual Box VM if network adapter is in NAT mode?

Ans: In NAT mode it gets the IP Address from Virtual LAN of Virtual BOX.

6. What is the command to create a symbolic link?

Ans: ln -s <source-path> <destination-path>

7. What is the difference between ext2 and ext3?

ext2, ext3 and ext4 are all filesystems created for Linux. This article explains the
following:

 High level difference between these filesystems.

 How to create these filesystems.

 How to convert from one filesystem type to another.


Ext2

 Ext2 stands for second extended file system.

 It was introduced in 1993. Developed by Rémy Card.

 This was developed to overcome the limitation of the original ext file system.

 Ext2 does not have journaling feature.


 On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the

over head of journaling.

 Maximum individual file size can be from 16 GB to 2 TB

 Overall ext2 file system size can be from 2 TB to 32 TB


Ext3

 Ext3 stands for third extended file system.

 It was introduced in 2001. Developed by Stephen Tweedie.

 Starting from Linux Kernel 2.4.15 ext3 was available.

 The main benefit of ext3 is that it allows journaling.

 Journaling has a dedicated area in the file system, where all the changes are

tracked. When the system crashes, the possibility of file system corruption is less

because of journaling.

 Maximum individual file size can be from 16 GB to 2 TB

 Overall ext3 file system size can be from 2 TB to 32 TB

 There are three types of journaling available in ext3 file system.

 Journal – Metadata and content are saved in the journal.

 Ordered – Only metadata is saved in the journal. Metadata are journaled

only after writing the content to disk. This is the default.

 Writeback – Only metadata is saved in the journal. Metadata might be

journaled either before or after the content is written to the disk.

 You can convert a ext2 file system to ext3 file system directly (without

backup/restore).

8. What is the command to download webpages from command prompt?

Ans: wget

9. What is the command to list hidden files in a directory?

Ans: ls -a

10. How do you find the shell you are running?

Ans: echo $SHELL


11. What happens when you enter the command “cd -“?

Ans: It shows the path of our previous working directory

12. Expand NAT?

Ans: Network Address Translation

13. What is the filename that contains ssh public keys?

Ans: id_rsa.pub [in Centos6/RHEL6]

14. What is ClamAV?

Ans: Its an Anti-Virus for Unix Based OS, but specially designed and used for scanning in

Email Servers

15. What is Shebang?

Ans: #!/bin/bash

16. What is Virt-Manager?

Ans: The virt-manager application is a desktop user interface for managing virtual

machines through libvirt. It primarily targets KVM VMs, but also manages Xen and LXC

(linux containers).

17. Write the command to mount an NTFS partition in Linux?

Ans: mount -t ntfs /dev/sdb1 /mnt/ntfs {If the flavour of Linux supports NTFS}

For Cent OS:

#yum install epel-release

#yum install ntfs-3g

#mkdir /mnt/win

#mount -t ntfs-3g /dev/sdb1 /mnt/win


#mount -t ntfs-3g /dev/sdb1 /mnt/win

#vi /etc/fstab

/dev/sdb1 /mnt/win ntfs-3g defaults 0 0

18.What is the command to find the default gateway in Linux?

Ans: route -n {or} netstat -r

19. What is the command to list the server processes listening on TCP ports?

Ans: netstat -tulpn

20. What is init S or init 1?

Ans: init 1 or Runlevel 1 corresponds to Single User Mode which is used for

troubleshooting

https://zenpwning.wordpress.com/tag/linux/

LINUX INTERVIEW QUESTIONS


1. The dmesg command

a) Shows user login logoff attempts

b) Shows the syslog file for info messages

c) kernel log messages

d) Shows the daemon log messages

2. Which command is used to record a user login session in a file

a) macro

b) read

c) script

d) none of the above

3. Which command is used to display the operating system name

a) os
b) Unix

c) kernel

d) uname

4. Which command is used to display the unix version

a) uname -r

b) uname -n

c) uname -t

d) kernel

5. Which command is used to print a file

a) print

b) ptr

c) lpr

d) none of the above

6. Which option of ls command used to view file inode number

a) –l

b) -o

c) –a

d) –i

7. Which command is used to view compressed text file contents

a) cat

b) type

c) zcat

d print

8. Which command changes a file’s group owner

a) cgrp

b) chgrp

c) change

d) group

9. Which command is used to extract intermediate result in a pipeline

a) tee
b) extract

c) exec

d) none of the above

10. Which option of rm command is used to remove a directory with all its

subdirectories

a) –b

b) –o

c) –p

d) –r

11. Which command creates an empty file if file does not exist?

a) cat

b) touch

c) ed

d) read

12. Which command is used to identify file type?

a) Type

b) File

c) Finfo

d) Info

13. Command used to determine the path of an executable file is

a) which

b) where

c) wexec

d) what

14. Command used to count number of character in a file is

a) grep

b) wc

c) count

d) cut
15. Which of these commands could you use to show one page of output at a time?

a) less

b) sed

c) pause

d) grep

1:c – 2:c – 3:d – 4:a – 5:c – 6:d – 7:c – 8:b – 9:a – 10.d – 11:b – 12:b – 13:a – 14:b –

15:a –

1        Q. Which command is used to check the number of files and disk space used and the each
user’s defined quota

 Repquota , it shows filesystem, no. of blocks used, soft and hard limit, no. of files used,
soft and hard limits

2        What is the name and path of the main system log

 A. /var/log/messages. (Syslog)

3        Which command is used to review boot messages

 Dmesg, used as dmesg | more or dmesg | grep Memory, etc

4        Which utility is used to automate rotation of logs

 logrotate (/etc/logrotate.conf and /etc/logrotate.d)

5        What are the fields in the /etc/passwd file

 Username, mask password, UID, GID, comment, home directory, default shell

6        Which commands are used to set a processor-intensive job to use less CPU time

 nice, it is used for scheduling priority of PIDs. -20 means highest priority. 19 means
lowest priority.
 Top command can also be used for this job. Press r and PID and Priority.

7        How do you create a new user account

 Useradd –d /home/newuser –s /bin/ksh –c “New User”  newuser

8        Which shell account do you assign to a POP3 mail-only account


 /sbin/nologin

9        Which daemon is responsible for tracking events on Linux system

 Syslogd, it logs events to /var/log/messages

10    Which daemon is used for scheduling of the commands

 Crond, it schedules commands with crontab –e command

11    How environment variables is set so that the file permission can be automatically set to the
newly created files

 Umask, umask 000 means full full permission, umask 777 means least permissions will
be assign to newly created files.

12    Which key combination can you press to suspend a running job and place it in background

 Ctrl+z

13    What file would you edit in your home directory to change the default window manager

 ~/.xinitrc

14    Which command can split long text files into smaller ones

 Split, it divides file into equal sizes

15    What is pwconv

 Pwconv command creates /etc/shadow and changes all passwords to X in /etc/passwd

16    What is page in, page out, swap in, swap out

 Page-ins and page-outs are pages moved in and out between RAM and Disk
 swap-ins and swap-outs are processes moved in and out between RAM and Disk
 page-out = The system’s free memory is less than a threhsold “lotsfree” and vhand
daemon use “LRU, Last Recently Used” algorithm to move some unused / least used
pages to the swap area.
page-in = One process which is running requested for a page that is not in the current
memory (page-fault), vhand daemon is bringing it’s pages to memory.
 Page in – Page outs – They are similar in function to any other operating system. When a
particular page is requested by the main memory, but it is not present in the main
memory; a page fault occurs…and this page is “paged in” to the main memory. Similarly
pages that have been inactive for a while are “paged out” to page data sets on the
auxiliary memory(Swap).
 swap-out = System is thrashing and swapper daemon has de-activated a process and it’s
memory pages are moved into the swap area.
swap-in = A deactivated process is back to work and it’s pages are being brought into the
memory.
 Swapping involves the moving of a process’s entire collection data in memory to a range
of space on the backing store, often to a swapfile or swap partition. The process goes
from being in memory to swapped out entirely; there is no in-between.
 Swapping occurs when whole process is transferred to disk, while paging is when some
part of process is transferred to disk while rest is still in physical memory.

17    What is tee command used for

 It reads standard input and transfers it to standard output while storing the contents in a
separate file
sort inputfile.txt | tee outputfile.txt | cat
tee “Hello, I am output” > outputfile.txt
who | tee userlist.txt
 It can also be used to write multiple files at the same time
date | tee –a file1 file2 file3

18    What are $? And $! System variables

 Echo $? à Shows zero if the last executed command was successful


 Echo $! à Shows last executed background job

19    What is difference between find and grep

 Find is used to search / locate files


 Grep is used to search a pattern inside a file

20    What are differences between Hard and Soft links

 Hard Link is a mirror copy of the original file.


 Hard links share the same inode.
 Any changes made to the original or Hard linked file will reflect the other.
 Even if you delete any one of the files, nothing will happen to the other.
 Hard links can’t cross file systems.
 Soft Link is a symbolic link to the original file.
 Soft Links will have a different Inode value.
 A soft link points to the original file.
 If you delete the original file, the soft link fails.
 If you delete the soft link, nothing will happen.
 Soft links can cross file systems.
21    Which file defines the level of logs written to system log

 Kernel.h

22    Describe the boot process of Linux

 BIOS (Basic Input/Output System) Loads from BIOS chip on motherboard


 POST (Power On Self Test) Checks all connected devices
 BIOS checks for Boot device availability
 BIOS loads MBR (Master Boot Record) in Memory (which is first 512 bytes of primary
disk)
 MBR contains information about Boot Loader. MBR loads default boot loader i.e. GRUB
 Grub loads Kernel of Operating System, VMLinuz
 Here onwards Kernel controls booting process
 Kernel starts INITRD (Initial RAM DISK). InitRD contains preloaded drivers for
hardware
 After loading drivers from INITRD, partitions are mounted (ready only)
 Init process is started, it becomes first process of system (PID = 1)
 INIT will mount root and other partitions(read/write) and does FSCK
 INIT sets up System Clock and Hostname, etc
 Based on runlevel it will load the services and startup scripts
 Finally, it will run rc.local script
 Now the Login Prompt will appear

23    What is DORA Process

 DORA (Discover, Offer, Request, Accept) is the process by which a client acquires
DHCP IP Address

24    What is output of Kill -3 <PID> and Kill -0

 Kill -3 <PID> is used to take thread dump of a running JAVA Process


 Kill -0 will kill all process in current process group except Login shell

25    What is difference between Kill and Kill -9 command

 kill <PID>à  Generates SIGTERM signal requesting process to terminate


 kill -9 <PID> à Generates SIGKILL signal for process to terminate immediately
 KILL -9 is FORCE KILL a process because the signal can’t be caught by the process

26    What is VLAN

 Virtual LAN, is a broadcast domain created by switches. With VLAN a switch can create
and broadcast domain. It separates large broadcast domains into smaller ones thus
improves performance.
27    What are hard and soft mount

 Hard mount is used to mount local filesystem. The filesystem will be in the mounted state
until you unmount it manually.
 Soft mount is an option that is very useful for mounting network filesystems(NFS). Soft
mount will allow automatic unmount if the filesystem is idle for a specified time period.
 NFS supports two types of mounts — hard mounts and soft mounts. If a mount is a hard
mount, an NFS request affecting any part of the mounted resource is issued repeatedly
until the request is satisfied (for example, the server crashes and comes back up at a later
time). When a mount is a soft mount, an NFS request returns an error if it cannot be
satisfied (for example, the server is down), then quits.
 Hard mount ensures data integrity and soft mount causes data loss if NFS server is
unreachable.
 Soft mount improves performance and Hard mount improves reliability

28    What is PS1 in Linux

 Bash supports 4 prompts:


PS1 – the default prompt
PS2 – for multi-line input
PS3 – printed for the select command
PS4 – printed before output if set -x is set

29    What is difference between a deamon and a server process

 A daemon (Disk and Execution Monitor) is a software process that runs in the
background (continuously) and provides the service to client upon request. For example
named is a daemon. When requested it will provide DNS service.
Other examples are:
* xinetd (it is a super-daemon, it is responsible for invoking other Internet servers when
they are needed)
* inetd (same as xinetd, but with limited configuration options)
* sendmail/postfix (to send/route email)
* Apache/httpd (web server)
 Browser Running one daemon for each of the services could significantly increase the
load. However if you are running big site (with many user) it is advisable to use
dedicated daemon. For example web server or MySQL database server.
 A server process runs one time, when called by a daemon. Once done it will stop. For
example telnetd (in.telnetd) or ftpd called from xinetd/inetd daemon. By calling server
process from daemon you can save the load and memory. Use a server process for small
services such as ftpd, telnetd

30    Where is kernel located in Linux

 Kernel file is stored in /boot with the name VMLinux


 When Linux OS is running, kernel is loaded into memory
31    Explain configure, make and make install

 ./configure
 The above command makes the shell run the script named ‘ configure ‘ which exists in
the current directory. The configure script basically consists of many lines which are used
to check some details about the machine on which the software is going to be installed.
This script checks for lots of dependencies on your system. For the particular software to
work properly, it may be requiring a lot of things to exist on your machine already. When
you run the configure script you would see a lot of output on the screen , each being some
sort of question and a respective yes/no as the reply. If any of the major requirements are
missing on your system, the configure script would exit and you cannot proceed with the
installation, until you get those required things.
 The main job of the configure script is to create a ‘ Makefile ‘ . This is a very important
file for the installation process. Depending on the results of the tests (checks) that the
configure script performed it would write down the various steps that need to be taken
(while compiling the software) in the file named Makefile.
 If you get no errors and the configure script runs successfully (if there is any error the last
few lines of the output would glaringly be stating the error) then you can proceed with the
next command which is
 make
 ‘make’ is actually a utility which exists on almost all Unix systems. For make utility to
work it requires a file named Makefile in the same directory in which you run make. As
we have seen the configure script’s main job was to create a file named Makefile to be
used with make utility. (Sometimes the Makefile is named as makefile also)
 make would use the directions present in the Makefile and proceed with the installation.
The Makefile indicates the sequence that Linux must follow to build various
components / sub-programs of your software. The sequence depends on the way the
software is designed as well as many other factors.
 The Makefile actually has a lot of labels (sort of names for different sections). Hence
depending on what needs to be done the control would be passed to the different sections
within the Makefile or it is possible that at the end of one of the section there is a
command to go to some next section.
 Basically the make utility compiles all your program code and creates the executable. For
particular section of the program to complete might require some other part of the code
already ready, this is what the Makefile does. It sets the sequence for the events so that
your program does not complain about missing dependencies.
 One of the labels present in the Makefile happens to be named ‘install’.
 If make ran successfully then you are almost done with the installation. Only the last step
remains which is
 make install
 As indicated before make uses the file named Makefile in the same directory. When you
run make without any parameters, the instruction in the Makefile begin executing from
the start and as per the rules defined within the Makefile (particular sections of the code
may execute after one another.. that’s why labels are used.. to jump from one section to
another). But when you run make with install as the parameter, the make utility searches
for a label named install within the Makefile, and executes only that section of the
Makefile.
 The install section happens to be only a part where the executable and other required files
created during the last step (i.e. make) are copied into the required final directories on
your machine. E.g. the executable that the user runs may be copied to the
/usr/local/apache2 so that all users are able to run the software. Similarly all the other
files are also copied to the standard directories in Linux. Remember that when you ran
make, all the executable were created in the temporary directory where you had unzipped
your original tarball. So when you run make install, these executable are copied to the
final directories.

32    What is LD_LIBRARY_PATH

 LD_LIBRARY_PATH is an environment variable. It is used for debugging a new library


or a non-standard library. It is also used for which directories to search. Path to search for
directories need to given
 LD_LIBRARY_PATH is an environment variable you set to give the run-time shared
library loader (ld.so) an extra set of directories to look for when searching for shared
libraries. Multiple directories can be listed, separated with a colon (:). This list is
prepended to the existing list of compiled-in loader paths for a given executable, and any
system default loader paths.

33    Explain RSync

 rsync utility is used to synchronize the files and directories from one location to another
in an effective way. Backup location could be on local server or on remote server.
 # rsync  options  <source>  <destination>

i)        -z is to enable compression

ii)       -a archive (recursive, preserve symbolic links, permissions, timestamps, owner and group)

iii)     -l copy symbolic links as well

iv)     -h output numbers in human readable format

v)      -v verbose

vi)     -r indicates recursive

vii)   -u Update (do not overwrite)

viii)  -d sync only directory structure(not the files)

ix)     -i only displays difference in source and destination


x)      –progress to view progress during transfer

xi)     –delete to delete the files not present at source but present at destination

xii)   –exclude to exclude file or directory or pattern or RELATIVE path

xiii)  –exclude-from <FileName> to exclude files/directories listed in FileName

xiv) –max-size not to transfer files larger than this limit

34    How to enable password-less authentication among two linux servers

 Generate key on server1

i)        # ssh-keygen

 copy public key to server2

i)        # ssh-copy-id -i ~/.ssh/id_rsa.pub <remote-server>

35    How to create users in Linux

 Using useradd command


 To see all the defaults of useradd command
 # useradd -D

i)        GROUP=100

ii)       HOME=/home

iii)     INACTIVE=-1

iv)     EXPIRE=

v)      SHELL=/bin/bash

vi)     SKEL=/etc/skel

vii)   CREATE_MAIL_SPOOL=yes

 Modify defaults of useradd


 # useradd -D –shell=/bin/ksh
 # useradd -D

i)        GROUP=100
ii)       HOME=/home

iii)     INACTIVE=-1

iv)     EXPIRE=

v)      SHELL=/bin/ksh

vi)     SKEL=/etc/skel

vii)   CREATE_MAIL_SPOOL=yes

 Create customized users using useradd


 # useradd -s <shell> -m -d <home> -g <secondary group> username

i)        -s = shell

ii)       -m = create home directory, if not exists

iii)     -d = where to create home directory

iv)     -g = gid or name of group user will become member of

 Adduser command
 # adduser <username>
 Creating n number of users
 # newusers <file containing list of users>

36    How to define Password expiry

 To see current settings for password age policy


 # chage –list <user>

i)        Last password change                                    : Apr 01, 2009

ii)       Password expires                                        : never

iii)     Password inactive                                       : never

iv)     Account expires                                         : never

v)      Minimum number of days between password change          : 0

vi)     Maximum number of days between password change          : 99999

vii)   Number of days of warning before password expires       : 7


 Set password expiry date for a user using -m option
 # chage -M 10 <user>
 This will change ‘password expires’ and ‘Max number of days between password
change’
 Set password expiry date for a user using -E option (YYYY-MM-DD)
 # chage -E “2012-12-31” <user>
 Set the user accound to be locked after X number of inactivity days
 # chage -I 10 <user>
 This will change ‘password inactive’
 Force user to change password upon next logon
 # chage -d 0 <user>

37     What is the use of login.defs

 /etc/login.defs file contains defaults for a new user. Various options in login.defs file are

i)        MAIL_DIR /var/spool/mail

ii)       PASS_MAX_DAYS   99999

iii)     PASS_MIN_DAYS   0

iv)     PASS_MIN_LEN    5

v)      PASS_WARN_AGE   7

vi)     UID_MIN                   500

vii)   UID_MAX                 60000

viii)  GID_MIN                   500

ix)     GID_MAX                 60000

x)      CREATE_HOME     yes

xi)     UMASK           077

xii)   USERGROUPS_ENAB yes

xiii)  MD5_CRYPT_ENAB yes

38    What is the use of limits.conf

 /etc/security/limits.conf file is used to describe limits for a user/group


 Add session required /lib/security/pam_limits.so in /etc/pam.d/login
 Limits defined in limits.conf

i)        core – limits the core file size KB

ii)       data – max data size KB

iii)     fsize – max file size KB

iv)     nofile – max number of open files

v)      cpu – max CPU time (Mins)

vi)     nproc – max number of process

vii)   maxlogins – max number of logins for this user

viii)  maxsyslogins – max number of logins on the system

ix)     priority – the priority to run user process with

x)      locks – max number of file locks user and hold

xi)     nice – max nice priority allowed to raise to

 ex.

i)        @students soft nproc 10

ii)       @students hard nproc 20

39     What is RAID and explain different RAID levels used

 RAID is Redundant Array of Inexpensive Disks. It improves performance, redundancy


and flexibility
 RAID 0 = Striping (pronounced as stryping)

i)        Two or more disks

ii)       Data is broken into equal size chunks and distributed over all disks

iii)     Performance is improved because of simultaneous read and write disk operations

iv)     No fault tolerance (no redundancy)

v)      Suitable for intensive i/o tasks


vi)     Total size = sum of disks used

vii)   Two 80G disk = 160×1 = 160G available disk in RAID 0 (Space efficiency =1)

viii)  Mathematical  AND function

 RAID 1 = Mirroring

i)        Two or more disks

ii)       Data is duplicated to disks simultaneously

iii)     Performance remains same

iv)     Provides fault tolerance if one disk fails, Redundancy increases

v)      Suitable for non-intensive i/o tasks

vi)     Total size = Size of smallest disk used

vii)   Two 80G disk = 160×1/2 = 80G available disk in RAID 0 (Space efficiency = 1/n = 1/2)

viii)  Mathematical OR function

 RAID 4 = Striping with dedicated Parity Disk

i)        Three or more disks

ii)       Data is broken into stripes and distributed over two disks

iii)     Parity bit is stored only in third disk i.e. Parity Disk

iv)     Performance also depends on performance of Parity Disk

v)      Provides fault tolerance if one disk fails

vi)     Suitable for intensive i/o tasks

vii)   3x80G disk = 240×2/3 = 160G available disk in RAID 4 (Space efficiency = 1-1/n = 1-1/3
= 2/3)

 RAID 5 = Striping with distributed Parity

i)        Three or more disks

ii)       Data is broken into stripes and distributed over three disks
iii)     Parity bit is also distributed over three disks

iv)     Performance is improved with simultaneous i/o on three disks

v)      Provides fault tolerance if one disks fails

vi)     Suitable for intensive i/o tasks

vii)   3x80G disk = 240×2/3 = 160G available disk in RAID 5 (Space efficiency = 1-1/n = 1-1/3
= 2/3)

40     How to boot client with Kick Start file

 Boot: linux ks=http://server.com/path/kickstart.cfg


 Boot: linux ks=nfs://server.com/path/kickstart.cfg

41    How to setup Kick Start server

 Install DHCP and configure it


 Install system-config-kickstart
 Run system-config-kickstart
 Provide answers to question in installation wizard
 Save the file in NFS/HTTP path
 Add the name of groups and packages at the bottom of files which needs to be pre-
installed on remote server

42    How to check system boot / reboot time

 # last reboot
 # last shutdown
 # who –b
 # uptime

43    What is difference between ext2 and ext3 file systems

 Ext3 supports journaling whereas ext2 doesn’t.


 Journal is a type of log file which tracks all the file system changes
 So that you can recover data in case of filesystem crash
 Journal contains ‘metadata’ i.e. ownership, date stamp information etc

44    How to extend LVM with 2GB space (add 2GB)

 # lvextend –L +2G <LVNAME>


 # resize2fs <LVNAME>
45    How to extend LVM to a final of 2GB space

 # lvextend –L 2G <LVNAME>
 # resize2fs <LVNAME>

46    How do you check hardware errors in Linux

 dmesg
 /var/log/messages
 dmidecode –t system
 IML (Integrated Management Logs) – An iLO console feature
 hpacucli – To check RAID array status
 use grep or less commands on
 /var/log/messages and /var/log/warn
 /var/log/mcelog

47    How do you find BIOS version from Linux Command

 # dmidecode –type 0

48    What is dmidecode command

 dmidecode  is  a  tool for dumping a computer’s DMI (some say SMBIOS) table contents
in a human-readable format. This table contains a description of the system’s hardware
components, as well as other useful pieces of information such as serial numbers and 
BIOS  revision.  Thanks to this table, you can retrieve this information without having to
probe for the actual hardware.

49    How do you find out server architecture

 # uname –a
 # arch

50    How to perform automatic reboot after kernel panic (10seconds)

 # cat /proc/sys/kernel/panic
 # sysctl –a | grep kernel.panic

i)        Kernel.panic = 0

 # echo “10” > /panic/sys/kernel/panic


 # cat /etc/sysctl.conf | grep kernel.panic

i)        Kernel.panic = 10
51    What are the general causes of kernel panic

 Defective or incompatible RAM


 Incompatible, obsolete, or corrupted kernel extensions.
 Incompatible, obsolete, or corrupted drivers.
 Incorrect permissions on System-related files or folders.
 Hard disk corruption, including bad sectors, directory corruption, and other hard-disk ills.
 Insufficient RAM and available hard disk space.
 Improperly installed hardware or software.
 Incompatible hardware

52    What are the uses of dd command

 Disk Dump (copy all content from one disk to another)


 # dd if=/dev/sda of=/dev/sdb
 Partition Dump (copy all content from one partition to another)
 # dd if=/dev/sda1 of=/dev/sda2
 Creating empty file of specific size (File used as swap)
 # dd if=/dev/zero of=/swapfile bs=1024 count=524288

i)        1024×512=524288 block size = 512MB

53    What is DMM

 DMM or DM-Multipath or Device Mapper Multipathing allows you to configure


multiple I/O paths between server nodes and storage arrays into a single device.
 I/O paths are physical SAN connections , multipath combines these I/O paths and creates
a new device
 Redundancy

i)        Active/Passive configuration

ii)       Only half of the paths are used at a time for I/O

 Improved Performance

i)        Active/Active mode

ii)       Round robin fashion

54    What is WWID in DM-Multipath

 World Wide Identifier is a unique and unchanging name of every multipath device

55    What is use of multipath command


 It lists and configures multipath devices

56    What is the procedure to configure your system with DM-Multipath

 Install device-mapper-multipath rpm


 Edit the /etc/multipath.conf configuration file:

i)        comment out the default blacklist  (it blacklists all devices)

ii)       change any of the existing defaults as needed

iii)     save the configuration file

 Start the multipath daemons

i)        # modprobe dm-multipath

ii)       # service multipathd start

iii)     # multipath –v2

iv)     # chkconfig multipathd on

 Create the multipath device with the multipath command

57    How to exclude local disk from multipath list

 Modify /etc/multipath.conf and write local disk’s WWID in blacklist section

i)        blacklist {

ii)              wwid 26353900f02796769

iii)     }

 You can also black list device by its Device Name and Device Type
 # multipath –F à Removes all multipath devices
 # multipath –f < device > à Removes the given device
 # multipath –v2 à verbosity = 2
 # multipath –l à Displays info from sysfs and device mapper
 # multipath –ll à Also displays variable components of the system

58    How to find WWID

 # cat /var/lib/multipath/binding
59    How to add devices to multipath database

 Multipath by default includes support for most common storage arrays


 This list can be found in multipath.conf.defaults file
 If you want to add a unsupported device then edit /etc/multipath.conf

i)        devices {

ii)              device {

iii)                    vendor “HP”

iv)                    product “OPEN-V.”

v)                     getuid_callout “/sbin/scsi_id -g -u -p0x80 -s /block/%n”

vi)            }

vii)   }

 To know Vendor and Product information

i)        # cat /sys/block/sda/device/vendor

ii)       # cat /sys/block/sda/device/model

60    What is the use of DMSetup command

 DMSetup command is used to find out Device Mapper entries match the Multipathed
device
 # dmsetup ls

61    How do you troubleshoot multipath

 # multipathd –k

i)        show config

ii)       reconfigure

iii)     show paths

iv)     CTRL+D

62    How to format, mount and use SAN Volumes


 # fdisk /dev/sda
 # kpartx –a /dev/mapper/mpath0
 # ll /dev/mapper

i)        mpath0    mpath0p1

 # mkfs.ext3 /dev/mapper/mpath0p1
 # mount /dev/mapper/mpath0p1 /mnt/san
 Kpartx creates device maps from partition tables
 We must use fdisk command on underlying device /dev/sda

63    How to resize online multipath disk

 Use the following command to find paths to LUNs

i)        # multipath –l

 Now, resize your paths, for SCSI device

i)        # echo 1 > /sys/block/<device>/device/rescan

 Resize multipath device

i)        # multipathd –k ‘resize map mpath0’

 Resize the file system (if there is no LVM configured upon mpath0)

i)        # resize2fs /dev/mapper/mpath0

 If LVM resides over mpath0 then we should not resize it. We should resize LVM

i)        # pvscan

ii)       # vgscan

iii)     # lvextend –L +SizeG <LVNAME>

iv)     # resize2fs <LVNAME>

64    How to differentiate local storage from SAN

 # ls –l /sys/block/*/device

65    How to upgrade Linux Kernel


 Kernel can be upgraded either by compiling from source or by installing kernel rpm
 Kernel should be compiled only in case if you need custom kernel with specific patch
 Using RPM –ivh command is safer than RPM –Uvh (ivh will preserve old kernel to fall
back)

i)        # rpm –Uvh kernel-headers kernel-source kernel-devel

ii)       # rpm –ivh kernel kernel-smp à SMP is multi core or multi CPU

 RPM command modifies grub.conf accordingly


 Linux OS can have as many kernels but can load only 1 at a time

66    How to delete or remove unnecessary kernel

 /boot/vmlinux à Kernel File


 /boot/grub.conf à Edit
 /lib/modules/kernel-VERSION à Modules
 If Kernel was installed using rpm, it can be removed via rpm –e

i)        # rpm –qa | grep kernel

ii)       # rpm –vv –e kernel-smp

67    Where are the Kernel Modules (Device Drivers in Windows terminology) stored

 /lib/modules/kernel-version
 /lib/modules/$(uname –r)

68    How to list all the loaded kernel modules

 # lsmod
 # less /proc/modules
 # modinfo ipv6

69    How to add or remove modules from running kernel

 MODPROBE is the command used to add or remove modules in kernel on fly


 # modprobe  ip_tables
 # lsmod à uses file /proc/modules
 # modprobe –r ip_tables
 # lsmod
 Alternatively, we can use insmod and rmmod

i)        INSMOD à Load a module


ii)       RMMOD à Unload a module

70    How to load a module in kernel automatically at system boot

 If you want to load cdrom module in kernel upon next boot, modify modules.conf [old
method]

i)        # vi /etc/modules.conf

ii)       ide-cd

iii)     ide-core

iv)     cdrom

v)      save and close file, reboot system

 Or we can use rc.modules file. We should use rc.modules file and not rc.local for loading
kernel modules because rc.modules file is read much eary in boot sequence

i)        # echo modeprobe ide-cd >> /etc/rc.modules

ii)       # chmod u+x /etc/rc.modules

71    How to delete log files older than 10 days

 # find /var/log/http/ -name *.log  -mtime +10 –exec rm –f {} \;

72    How to find Disk being used by a user

 # find /directory –user <username> -type –f –exec du –sh {} \;

73    How to find information about your Hard Disk from Linux Command

 # hdpram /dev/sda à INFO


 # hdpram –I /dev/sda à More INFO
 # hdpram –tT /dev/sda à Read Write Speed

i)        Timing cached reads:   9460 MB in  2.00 seconds = 4737.22 MB/sec

ii)       Timing buffered disk reads: 708 MB in  7.57 seconds =  93.49 MB/sec

74    How to mount ISO files in Linux

 # mount –o loop linux-dvd.iso /mnt


75    Explain the output of PS command

 S: State of the process

i)        S: Sleeping,

ii)       O: Runing on processor,

iii)     R: Runnable (it is in run queue),

iv)     Z: Zombie,

v)      T: Stopped process (either by a job control signal or because it is being traced)

 PID: Process ID
 PPID: Parent process ID
 USER: User name who initiated process
 GROUP: Group name from whom user belong/currently launched the job
 RSS: The resident set size of the process, in kilobytes.
 VSZ:The total size of the process in virtual memory, in kilobytes.
 %CPU: Total % of CPU taken by this process
 %MEM: Total % of Memory taken by this process
 TIME: the cumulative CPU time of the process in the form
 ELAPSED: Total time elapsed since this process is live
 TT: Terminal ID
 COMMAND: Command/daemon/process with args
 # ps -eo s,pid,ppid,user,group,rss,vsz,pcpu,pmem,time,etime,tty,args
 # ps L à to see list of format codes like above

76    Explain what is /proc file system

 /proc file system contains information about

i)        Kernel

ii)       Hardware

iii)     Running Process

 Important files under proc are: cpuinfo, mdstat, meminfo, modules, mounts, partitions,
net, version, /proc/sys/kernel/hostname, /proc/sys/net/ipv4/ip_forward

77    What is a Zombie Process


 When the parent keeps some of the information of child although the child process is
dead, such a process is called as Zombie Process
 Zombie process is dead but not have been removed from process table
 Zombie process doesn’t cause any load or issues to machine (because it is already dead)

78    How to tune Linux kernel

 # vi /etc/sysctl.conf à Modify / Add / Remove kernel parameters


 # /sbin/sysctl –p à Save configuration
 # sysctl –a à Check configuration

79    How to configure ntp client

 Open system-config-date, Network Management Tab and add NTP Server’s name/IP
 Click OK
 Run command ntpq –p to check available NTP servers

i)        # ntpq –p

ii)      * is displayed against active NTP server

iii)    Stratum number 16 means you are not synchronized

iv)    Lower the stratum number, nearer the NTP server is

 Run ntpstat to see if Time is updated (synchronous) and what is Time lag (seconds
behind)

i)        # ntpstat

 To synchronize client with server manually

i)        # ntpupdate –u <NTP Sever>

80    How to unmounts file system when resource is busy

 # umount /dev/sda1
 # fuser –m /dev/sda1 à identify which pid is using resource
 # lsof | grep /dev/sda1 à identify which pid is using resource
 # kill -9 <PID> à Kill the pid
 # umount /dev/sda1

81    What is Network Bonding? What are the steps for Network Bonding?
 Bonding is creation of a single bonded interface by combining 2 or more ethernet
interfaces. This helps in high availability and performance improvement.
 Step 1:
 Create the file ifcfg-bond0 with the IP address, netmask and gateway.

i)         $ cat /etc/sysconfig/network-scripts/ifcfg-bond0

ii)       DEVICE=bond0

iii)     IPADDR=192.168. 1.100

iv)     NETMASK=255. 255.255.0

v)      GATEWAY=192. 168.1.1

vi)     USERCTL=no à Only root can control services (say no to other users)

vii)   BOOTPROTO=none à Can be Static/DHCP or none

viii)  ONBOOT=yes à device will start when system starts

 Step 2:
 Modify eth0, eth1 and eth2 configuration as shown below. Comment out, or remove the
ip address, netmask, gateway and hardware address from each one of these files, since
settings should only come from the ifcfg-bond0 file above.

i)        $ cat /etc/sysconfig/network-scripts/ifcfg-eth0

ii)       DEVICE=eth0

iii)     BOOTPROTO=none

iv)     ONBOOT=yes

v)      MASTER=bond0

vi)     SLAVE=yes

vii)  $ cat /etc/sysconfig/network-scripts/ifcfg-eth1

viii)  DEVICE=eth1

ix)     BOOTPROTO=none

x)      ONBOOT=yes
xi)     USERCTL=no

xii)  MASTER=bond0

xiii)  SLAVE=yes

xiv) $ cat /etc/sysconfig/network-scripts/ifcfg-eth2

xv)   DEVICE=eth2

xvi) BOOTPROTO=none

xvii)            ONBOOT=yes

xviii)          MASTER=bond0

xix) SLAVE=yes

 Step 3:
 Set the parameters for bond0 bonding kernel module. Add the following lines
to/etc/modprobe. conf

i)        # bonding commands

ii)       alias bond0 bonding

iii)     options bond0 mode=balance-alb miimon=100

 Here, balance-alb = Adaptive Load Balancing


 Other options are, balance-rr = Balanced Round Robin
 Note: Here we configured the bonding mode as “balance-alb”. All the available modes
are given at the end and you should choose appropriate mode specific to your
requirement.
 Step 4:
 Load the bond driver module from the command prompt.

i)        $ modprobe bonding

 Step 5:
 Restart the network, or restart the computer.

i)        $ service network restart  Or restart computer

 When the machine boots up check the proc settings.

i)        $ cat /proc/net/bonding/bond0


ii)       Ethernet Channel Bonding Driver: v3.0.2 (March 23, 2006)

iii)     Bonding Mode: adaptive load balancing

iv)     Primary Slave: None

v)      Currently Active Slave: eth2

vi)     MII Status: up

vii)   MII Polling Interval (ms): 100

viii)  Up Delay (ms): 0

ix)     Down Delay (ms): 0

x)      Slave Interface: eth2

xi)     MII Status: up

xii)   Link Failure Count: 0

xiii)  Permanent HW addr: 00:14:72:80: 62:f0

 Look at ifconfig -a and check that your bond0 interface is active. You are done!
 RHEL bonding supports 7 possible “modes” for bonded interfaces. These modes
determine the way in which traffic sent out of the bonded interface is actually dispersed
over the real interfaces. Modes 0, 1, and 2 are by far the most commonly used among
them.
 ·* Mode 0 (balance-rr)
 This mode transmits packets in a sequential order from the first available slave through
the last. If two real interfaces are slaves in the bond and two packets arrive destined out
of the bonded interface the first will be transmitted on the first slave and the second frame
will be transmitted on the second slave. The third packet will be sent on the first and so
on. This provides load balancing and fault tolerance.
 * Mode 1 (active-backup)
 This mode places one of the interfaces into a backup state and will only make it active if
the link is lost by the active interface. Only one slave in the bond is active at an instance
of time. A different slave becomes active only when the active slave fails. This mode
provides fault tolerance.
 * Mode 2 (balance-xor)
 Transmits based on XOR formula. (Source MAC address is XOR’d with destination
MAC address) modula slave count. This selects the same slave for each destination MAC
address and provides load balancing and fault tolerance.
 * Mode 3 (broadcast)
 This mode transmits everything on all slave interfaces. This mode is least used (only for
specific purpose) and provides only fault tolerance.
 * Mode 4 (802.3ad)
 This mode is known as Dynamic Link Aggregation mode. It creates aggregation groups
that share the same speed and duplex settings. This mode requires a switch that supports
IEEE 802.3ad Dynamic link.
 * Mode 5 (balance-tlb)
 This is called as Adaptive transmit load balancing. The outgoing traffic is distributed
according to the current load and queue on each slave interface. Incoming traffic is
received by the current slave.
 * Mode 6 (balance-alb)
 This is Adaptive load balancing mode. This includes balance-tlb + receive load balancing
(rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The
bonding driver intercepts the ARP Replies sent by the server on their way out and
overwrites the src hw address with the unique hw address of one of the slaves in the bond
such that different clients use different hw addresses for the server.

82    What are LVM Snapshots

 “lvcreate –size 100m –snapshot –name snap /dev/vg00/lvol1”


  Ceates a snapshot logical volume named /dev/vg00/snap which has access to the
contents of the original logical volume named /dev/vg00/lvol1 at snapshot logical volume
creation time.  If  the  original logical  volume  contains  a  file  system, you can mount
the snapshot logical volume on an arbitrary directory in order to access the contents of
the filesystem  to  run  a  backup  while  the  original filesystem continues to get updated.

83    How to backup MySQL using LVM Snapshot

 First login to mysql and lock all tables. This will ensure that no update operations are
performed on LVM mount point

i)        Mysql> flush tables with read lock;

ii)       Mysql> flush logs;

 Now create LVM Snapshot of /dev/vg01/mysql (mounted as /var/lib/mysql)

i)        # lvcreate –snapshot –size=1000M –name=db-snapshot /dev/vg01/mysql

 Now login to MySQL and release the lock

i)        Mysql> unlock tables;

 Now move the backup to Tape or another server


i)        # find /dev/vg01/db-snapshot | cpio -o -H tar -F /dev/nst0

ii)       OR

iii)     # mount –o ro /dev/vg01/db-snapshot /mnt

iv)     # cd /mnt

v)      # tar cvfz mysql.tar * (# tar cvfz /dev/st0 /mnt)

vi)     # cd

vii)   # umount /mnt

viii)  # lvremove –f /dev/vg01/db-snapshot

84    Explain in detail what is LVM Snapshot

 It is a feature of Linux which creates virtual image of a device. This image will then keep
track of the changes being made to the origin.
 Example, If you have 1000mb data logical volume out of which 800mb is already used.
Now you take a lvm-snapshot of this volume with size 1000mb. Then this snapshot will
be able to keep a track of changes made to origin data volume till next 200mb. After
200mb usage on data volume, our snapshot will become INVALID.
 The size of snapshot need to be chosen by admin looking at the amount of expected level
of changes in data (origin)

85    What does lvdiskscan shows

 Shows block devices which can be used as physical volumes

86    How to scan for volumes

 pvscan, vgscan, lvscan

Cluster Administration
1         What is a Cluster

 A cluster is two or more computers (called as nodes or members) that works together to
perform a taks.

2         What are the types of cluster

 Storage
 High Availability
 Load Balancing
 High Performance

3         What is CMAN

 CMAN is Cluster Manager. It manages cluster quorum and cluster membership.


 CMAN runs on each node of a cluster

4         What is Cluster Quorum

 Quorum is a voting algorithm used by CMAN.


 CMAN keeps a track of cluster quorum by monitoring the count of number of nodes in cluster.
 If more than half of members of a cluster are in active state, the cluster is said to be in
Quorum
 If half or less than half of the members are not active, the cluster is said to be down and all
cluster activities will be stopped
 Quorum is defined as the minimum set of hosts required in order to provide service and is
used to prevent split-brain situations.
 The quorum algorithm used by the RHCS cluster is called “simple majority quorum”, which
means that more than half of the hosts must be online and communicating in order to provide
service.

5         What is split-brain

 It is a condition where two instances of the same cluster are running and trying to access
same resource at the same time, resulting in corrupted cluster integrity
 Cluster must maintain quorum to prevent split-brain issues

6         What is Quorum disk

 In case of a 2 node cluster, quorum disk acts as a tie-breaker and prevents split-brain issue
 If a node has access to network and quorum disk, it is active
 If a node has lost access to network or quorum disk, it is inactive and can be fenced
 A Quorum disk, known as a qdisk is small partition on SAN storage used to enhance quorum.
It generally carries enough votes to allow even a single node to take quorum during a cluster
partition. It does this by using configured heuristics, that is custom tests, to decided which which
node or partition is best suited for providing clustered services during a cluster reconfiguration.

7         What is RGManager

 RGManager manages and provides failover capabilities for collections of cluster resources
called services, resource groups, or resource trees.
 In the event of a node failure, RGManager will relocate the clustered service to another node
with minimal service disruption. You can also restrict services to certain nodes, such as restricting 
httpd to one group of nodes while  mysql can be restricted to a separate set of nodes.
 When the cluster membership changes, openais tells the cluster that it needs to recheck it’s
resources. This causes rgmanager, the resource group manager, to run. It will examine what
changed and then will start, stop, migrate or recover cluster resources as needed.
 Within rgmanager, one or more resources are brought together as a service. This service is
then optionally assigned to a failover domain, an subset of nodes that can have preferential
ordering.

8         What is Fencing

 Fencing is the disconnection of a node from the cluster’s shared storage. Fencing cuts off I/O
from shared storage, thus ensuring data integrity. The cluster infrastructure performs fencing
through the fence daemon,  fenced.
 Power fencing — A fencing method that uses a power controller to power off an inoperable
node.
 storage fencing — A fencing method that disables the Fibre Channel port that connects storage
to an inoperable node.
 Other fencing — Several other fencing methods that disable I/O or power of an inoperable
node, including IBM Bladecenters, PAP, DRAC/MC, HP ILO, IPMI, IBM RSA II, and others.

9         How to manually fence an inactive node

 # fence_ack_manual –n <node2>

10      How to see shared IP address (Cluster Resource) if ipconfig doesn’t show it

 # ip addr list

11      What is DLM

 A lock manager is a traffic cop who controls access to resources in the cluster
 As implied in its name, DLM is a distributed lock manager and runs in each cluster node; lock
management is distributed across all nodes in the cluster. GFS2 and CLVM use locks from the lock
manager.

12      What is Conga

 This is a comprehensive user interface for installing, configuring, and managing Red Hat High
Availability Add-On.
 Luci — This is the application server that provides the user interface for Conga. It allows users
to manage cluster services. It can be run from outside cluster environment.
 Ricci — This is a service daemon that manages distribution of the cluster configuration. Users
pass configuration details using the Luci interface, and the configuration is loaded in to corosync for
distribution to cluster nodes. Luci is accessible only among cluster members.

13      What is OpenAis or Corosync

 OpenAIS is the heart of the cluster. All other computers operate though this component, and
no cluster component can work without it. Further, it is shared between both Pacemaker and RHCS
clusters.
 In Red Hat clusters, openais is configured via the central cluster.conf file. In Pacemaker
clusters, it is configured directly in openais.conf.

14      What is ToTem

 The totem protocol defines message passing within the cluster and it is used by openais. A
token is passed around all the nodes in the cluster, and the timeout in fencing is actually a token
timeout. The counter, then, is the number of lost tokens that are allowed before a node is considered
dead.
 The totem protocol supports something called ‘rrp’, Redundant Ring Protocol. Through rrp, you
can add a second backup ring on a separate network to take over in the event of a failure in the first
ring. In RHCS, these rings are known as “ring 0” and “ring 1”.

15      What is CLVM

 CLVM is ideal in that by using DLM, the distributed lock manager, it won’t allow access to
cluster members outside of openais’s closed process group, which, in turn, requires quorum.
 It is ideal because it can take one or more raw devices, known as “physical volumes”, or
simple as PVs, and combine their raw space into one or more “volume groups”, known as VGs. These
volume groups then act just like a typical hard drive and can be “partitioned” into one or more
“logical volumes”, known as LVs. These LVs are where Xen’s domU virtual machines will exist and
where we will create our GFS2 clustered file system.

16        What is GFS2

 It works much like standard filesystem, with user-land tools like mkfs.gfs2, fsck.gfs2 and so
on. The major difference is that it and clvmd use the cluster’s distributed locking mechanism
provided by the dlm_controld daemon. Once formatted, the GFS2-formatted partition can be
mounted and used by any node in the cluster’s closed process group. All nodes can then safely read
from and write to the data on the partition simultaneously.

17      What is the importance of DLM

 One of the major roles of a cluster is to provide distributed locking on clustered storage. In
fact, storage software can not be clustered without using DLM, as provided by the dlm_controld
daemon and using openais’s virtual synchrony via CPG.
 Through DLM, all nodes accessing clustered storage are guaranteed to get POSIX locks, called
plocks, in the same order across all nodes. Both CLVM and GFS2 rely on DLM, though other clustered
storage, like OCFS2, use it as well.

18      What is CCS_TOOL

 we can use ccs_tool, the “cluster configuration system (tool)”, to push the new cluster.conf to
the other node and upgrade the cluster’s version in one shot.
 ccs_tool update /etc/cluster/cluster.conf

19      What is CMAN_TOOL

 It is a Cluster Manger tool, it can be used to view nodes and status of cluster
 Cman_tool nodes
 Cman_tool status
20      What is clusstat

 Clusstat is used to see what state the cluster’s resources are in

21      What is clusvadm

 Clusvadm is a tool to manage resource in a cluster


 clusvcadm -e <service> -m <node>: Enable the <service> on the specified <node>. When a
<node> is not specified, the local node where the command was run is assumed.
 clusvcadm -d <service> -m <node>: Disable the <service>.
 clusvcadm -l <service>: Locks the <service> prior to a cluster shutdown. The only action
allowed when a <service> is frozen is disabling it. This allows you to stop the <service> so that
rgmanager doesn’t try to recover it (restart, in our two services). Once quorum is dissolved and the
cluster is shut down, the service is unlocked and returns to normal operation next time the node
regains quorum.
 clusvcadm -u <service>: Unlocks a <service>, should you change your mind and decide not
to stop the cluster.

22      What is Luci_admin init

 This command is run to create Luci Admin user and set password for it
 Service luci start, chckconfig luci on
 Default port for Luci web server is 8084

—>> Post is a draft and will be updated soon

Common Ports and Protocols

Port (IP Protocols) Service/Protocol


21 (TCP) FTP
22 (TCP/UDP) SSH/ SFTP
25 and 587 (TCP) SMTP
53 (TCP/UDP) DNS
80 (TCP/UDP) HTTP
110 (TCP) POP3
143 (TCP/UDP) IMAP
389 (TCP/UDP) LDAP
443 (TCP/UDP) HTTPS
465 (TCP) SMTPS
636 (TCP/UDP) LDAPS
694 (UDP) Heartbeat
873 (TCP) rsync
3306 (TCP/UDP) MySQL
5900 (TCP/UDP) VNC
6660-6669 (TCP) IRC
8080 (TCP) Apache Tomcat

The inetd Super Server

Programs that provide application services via the network are called network daemons . A
daemon is a program that opens a port, most commonly a well-known service port, and waits for
incoming connections on it. If one occurs, the daemon creates a child process that accepts the
connection, while the parent continues to listen for further requests. This mechanism works well,
but has a few disadvantages; at least one instance of every possible service you wish to provide
must be active in memory at all times. In addition, the software routines that do the listening and
port handling must be replicated in every network daemon.

To overcome these inefficiencies, most Unix installations run a special network daemon, what
you might consider a “super server.” This daemon creates sockets on behalf of a number of
services and listens on all of them simultaneously. When an incoming connection is received on
any of these sockets, the super server accepts the connection and spawns the server specified for
this port, passing the socket across to the child to manage. The server then returns to listening.

The most common super server is called inetd , the Internet Daemon. It is started at system boot
time and takes the list of services it is to manage from a startup file named /etc/inetd.conf . In
addition to those servers, there are a number of trivial services performed by inetd itself called
internal services . They include chargen , which simply generates a string of characters,
and daytime , which returns the system’s idea of the time of day.

Services managed by inetd daemon are ftp, tftp, chargen, daytime, finger, etc

Running TOP Command in batch

top -b -d 10 -n 3 >> top-file

This command will run TOP in –b(batch) mode, with a delay (-d) of 10 seconds and 3(-n) times.

To write multiple files at the same time using TEE

ps | tee file1 file2 file3

This will send output of ps command to multiple files at the same time use TEE Command

Use IOStat to get Disk and CPU usage

iostat -x 10 10

This will show stats for 10 times, every 10 seconds


Memory usage monitoring using VMSTAT

vmstat -x 10 10

This command shows memory stats every 10 seconds for 10 times

procs            memory                        swap        io       system    cpu


r  b   swpd   free   buff  cache         si   so    bi    bo     in    cs       us sy id wa
2  5 375912  19548  17556 477472    0    1     0     0      1     1        1  0  0  1

proc:

r: Process that are waiting for CPU time

b: Process that are waiting for I/O

Memory:

Swapd: Shows how many blocks (1KB) are swapped out(paged) to disk

Free: Idle memory

Buff: Memory used as buffer, before/after I/O operation

Cache: Memory used as cache by OS

SWAP:

Si: Blocks per sec swapped in (From swap area(disk) to memory(RAM))

So: Blocks per sec swapped out (From memory(RAM) to swap area(disk))

IO:

Bi: Blocks per sec received from block device – Read Hard Disk

Bo: Blocks per sec sent to block device – Write Hard Disk

System:

In: No. of interrupts per sec

Cs: No. of context switches per sec (storing and restoring state of CPU. This enables multiple
processes to share a single CPU)

CPU:
Us: % of CPU used for running non-kernel code (user process)

Sys: % of CPU used for running kernel code (system time, network, I/O, clock etc)

Id: CPU idle time in %

Wa: % of time spent by CPU in waiting for I/O

Listing Dynamic Dependencies (LDD)

ldd /bin/ls

This command will list all the dependent missing libraries for ls command

List Open Files (LSOF)

To list all open files in system

lsof

To list all open files by a particular process

lsof –p <pid>

To list all open files by a user

lsof –u <name>

To list all open files in a partition

lsof | grep /dev/sda1

To list files/command/pid LISTENING to any port

lsof | grep LISTEN

To list files/command/pid listening to 6366

lsof | grep 6366

To list open IPV4 ports

lsof –i4

To list open IP v6 ports open


lsof –i6

To list files/operations running on nas directory

lsof +d /mnt/nas

This is extremely useful in unmounting a directory when it shows message ‘device is busy’

Commands for checking System Load

 Uptime
 Top
 Vmstat
 Free
 IOTop
 HTop
 aTOP

Using TOP

After running top command

Shift+m (or M) for sort by %MEM

n à 20 à for showing only 20 lines in output

Shift+o (or O) à k à Enter à to sort output by %CPU

Shift + w (or W) à To save the configuration

P – Sort by CPU usage

T – Sort by cumulative time

z – Color display

k – Kill a process

q – quit

Understanding OUTPUT of TOP Command

The first line in top:

top – 22:09:08 up 14 min,  1 user,  load average: 0.21, 0.23, 0.30


“22:09:08″ is the current time; “up 14 min” shows how long the system has been up for; “1 user”
how many users are logged in; “load average: 0.21, 0.23, 0.30″ the load average of the system
(1minute, 5 minutes, 15 minutes).

Load average is an extensive topic and to understand its inner workings can be daunting. The
simplest of definitions states that load average is the cpu utilization over a period of time. A load
average of 1 means your cpu is being fully utilized and processes are not having to wait to use a
CPU. A load average above 1 indicates that processes need to wait and your system will be less
responsive. If your load average is consistently above 3 and your system is running slow you
may want to upgrade to more CPU’s or a faster CPU.

The second line in top:

Tasks:  82 total,   1 running,  81 sleeping,   0 stopped,   0 zombie

Shows the number of processes and their current state.

The third line in top:

Cpu(s):  9.5%us, 31.2%sy,  0.0%ni, 27.0%id,  7.6%wa,  1.0%hi, 23.7%si,  0.0%st

Shows CPU utilization details. “9.5%us” user processes are using 9.5%; “31.2%sy” system
processes are using 31.2%; “27.0%id” percentage of available cpu; “7.6%wa” time CPU is
waiting for IO.

When first analyzing the Cpu(s) line in top look at the %id to see how much cpu is available. If
%id is low then focus on %us, %sy, and %wa to determine what is using the CPU.

The fourth and fifth lines in top:

Mem:    255592k total,   167568k used,    88024k free,    25068k buffers

Swap:   524280k total,        0k used,   524280k free,    85724k cached

Describes the memory usage. These numbers can be misleading. “255592k total” is total
memory in the system; “167568K used” is the part of the RAM that currently contains
information; “88024k free” is the part of RAM that contains no information; “25068K buffers
and 85724k cached” is the buffered and cached data for IO.

So what is the actual amount of free RAM available for programs to use ?

The answer is: free + (buffers + cached)

88024k + (25068k + 85724k) = 198816k

How much RAM is being used by progams ?


The answer is: used – (buffers + cached)

167568k – (25068k + 85724k) = 56776k

The processes information:

Top will display the process using the most CPU usage in descending order. Lets describe each
column that represents a process.

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

3166 apache    15   0 29444 6112 1524 S  6.6  2.4   0:00.79 httpd

PID – process ID of the process

USER – User who is running the process

PR – The priority of the process

NI – Nice value of the process (higher value indicates lower priority, -20 is highest, 19 is lowest)

VIRT – The total amount of virtual memory used

RES – Resident memory used

SHR – Amount of shared memory used

S – State of the task. Values are S (sleeping), D (uninterruptible sleep), R (running), Z(zombies),
or T (stopped or traced)

%CPU – Percentage of CPU used

%MEM – Percentage of Memory used

TIME+ – Total CPU time used by process

COMMAND – Command issued

Using Free

Free –m

Actual Usage is shown

-/+ bufferes/cache: 51 202


It means out of 254MB, 51MB is used by running programs. So I have 202MB to play with and
for my other application to grow into.

Using Fuser

It gives information about file user or the process that is currently using the file/directory

fuser –v /etc/init.d/httpd

USER        PID ACCESS COMMAND

/etc/init.d/httpd:

root       2652 …e. httpd

apache    28592 …e. httpd

apache    28595 …e. httpd

 c      current directory


 e      executable being run
 f      open file. f is omitted in default display mode
 F      open file for writing. F is omitted in default display mode
 r      root directory
 m      map’ed file or shared library

To find and kill a PID using Fuser:

fuser –v –k -i /etc/init.d/httpd

TAR

Extract individual file from archive

tar xvjf dest.tar.bz2 textfile.txt

Add a file to existing archive

tar rvf dest.tar myfile.txt

Add a directory to existing archive

tar rvf dest.tar myfolder/

Delete a file from existing archive


tar –delete -vf dest.tar myfile.txt

Delete a folder from existing archive

tar –delete -vf dest.tar myfolder/

Exclude a file from being archived

tar cvf dest.tar –exclude=’myfile.txt’ myfolder/

Use a exclude list

tar cvf dest.tar -X exclude.txt myfolder/

How to use CPIO

GNU cpio is a tool for creating and extracting archives, or copying files from one place to
another. It handles a number of cpio formats as well as reading and writing tar files. cpio
command works just like tar, only better. It can read input from the “find” command.

# find / -name “*.c” | cpio -o –format=tar > c-file.backup.tar

# find / -iname “*.pl” | cpio -o -H tar > perl-files.tar

# find / -iname “*.pl” | cpio -o -H tar -F perl-files.tar

# cpio -i -F perl-files.tar

# cpio -it -F perl-files.tar

 -o: Create archive


 -F: Archive filename to use instead of standard input or output. To use a tape drive on
another machine as the archive.
 -H format: Specify file format to use.
 -i: Restore archive
 -t: List files in archive

Archive contents to tape /dev/nst0

# find /home | cpio -o -H tar -F /dev/nst0

Restore contents from tape

# cpio -i -F /dev/nst0

Backup /home to remote system tape drive


# find /home | cpio -o -H tar -F user@backup.domain.com:/dev/nst0 –rsh-command=/usr/bin/ssh

Package installation using APT/Dpkg (Debian, Ubuntu)

 Install package:

aptitude install PACKAGENAME

 Reinstall package:

aptitude reinstall PACKAGENAME

 Remove package (keep config files):

aptitude remove PACKAGENAME

 Remove package and purge config files:

aptitude remove --purge PACKAGENAME

 Update package list:

aptitude update

 Upgrade system (security/bug fixes):

aptitude upgrade

 Upgrade system to newest release (dangerous!):

aptitude dist-upgrade

 Show info on an installed package:

aptitude show PACKAGENAME

 Search package repositories:

aptitude search SEARCHSTRING

Package installation using Yum/RPM (CentOS, Fedora, Red Hat)

 Install package:

yum install PACKAGENAME

 Remove package:
yum remove PACKAGENAME

 Update package:

yum update PACKAGENAME

 List available updates:

yum list updates

 Update system:

yum update

 Upgrade system to newest release (dangerous!):

yum upgrade

 Show package:

yum list PACKAGENAME

 Search package repositories:

yum search SEARCHSTRING

 List package groups:

yum grouplist

 Install package group:

yum groupinstall 'GROUP NAME'

 Update package group:

yum groupupdate 'GROUP NAME'

 Remove package group:

yum groupremove 'GROUP NAME'

 Download RPM file without installing it:

yum install yum-utils.noarch


yumdownloader httpd

 How to extract files from RPM without installing it:


rpm2cpio httpd* | cpio –idmv

o i = restore mode
o d = create directories wherever necessary
o m = retain time stamps
o v = verbose mode
 How to build RPM from tar
o rpmbuild –ta abc.tar
o rpm –ivh /usr/src/redhat/RPMS/[arch]/abc.xxx.[arch].rpm
 How to build RPM from spec
o rpmbuild –ba package.spec
o Install rpmbuild if ‘command not found’ by ‘yum install rpm-build’ command

SUID, SGID, Sticky Bit

What’s that about SUID, SGID, and the sticky bit (oh my!)? Once again, a table seems
appropriate…

Access File Directory


File executes with rights of its
SUID
owner (not the user who Ignored
(setuid) (4)
executed it)
File executes with rights of its Files created within directory inherit the directory’s
SGID
group (not the user who group memberships (rather than the creator’s group
(setgid) (2)
executed it) memberships)
Sticky Bit Files created within directory may only be moved or
Ignored
(1) deleted by their owner (or directory’s owner)

This probably isn’t intuitive, so we’ll go over it in a bit more detail. First, the sticky bit. One
place the sticky bit is commonly used on Unix-like systems is the /tmp directory. This directory
needs to be world-writable, but you don’t want anyone going around and deleting everyone
else’s files. The sticky bit offers exactly this protection.

The Sticky Bit is a permission bit that can be set on either a file or a directory.

If it is set on a file, then that file will remain in memory after execution, thus sticking in memory.
This is useful when running a multi-user program (such as a bulletin board system that I ran
once) to make the program execute faster for the next user. This was a common programming
tactic earlier in the history of computer programming when speed and disk space were at a
premium. This feature is UNIX specific. This feature is not used in LINUX. Sticky Bit used
on a file is USELESS in LINUX. It was useful when fast disk access and memory access
technologies were not around. So in today’s age concept of Sticky Bit is obsolete.
If the sticky bit is set on a directory, only the owner of files in that directory will be able to
modify or delete files in that directory – even if the permissions set on those files would
otherwise allow it.

RSync for backup

rsync -e ‘ssh -p 30000’ -avl –delete –stats –progress –-exclude ‘source’ –exclude ‘source/file.txt’
–exclude-from ‘/root/exclude.txt’ demo@123.45.67.890:/home/demo /backup

-e ‘ssh –p 30000’ à This ensures rsync uses the SSH protocol and sets the port to 30000

-a à Archive mode, retains the permissions of file

-v à Verbose mode

-vv à Double verbosity

-l à Preserves links

–delete à Delete files from destination folder that have been deleted from source folder

–stats à Gives Transfer Statistics

–progress à Progress of each file transfer, useful for rysncing large files

–exclude à exclude directory or file from being backed up

–exclude-from à exclude the list of file/folders written in exclude.txt

Logs on Linux

Some of the common log files and directories you might see in /var/log:

Filename(s) Purpose
auth.log Authentication logs
boot.log Boot logs
btmp Invalid login attempts
cron Cron logs
daemon.log Logs for specific services (daemons)
dmesg Kernel boot messages
httpd/ Apache logs
kern.log Kernel logs
mail* Mail server logs
messages General/all logs
mysql* MySQL logs
secure Security/authentication logs
syslog All system logs
wtmp User logins and logouts

VPN Tunneling on CentOS using OpenVPN

3 Types of tunneling available:

·       Simple VPN (no security or encryption)

Server 1

/usr/sbin/openvpn –remote 10.100.1.50 –dev tun1 –ifconfig 172.16.1.1 172.16.1.2

Server 2

/usr/sbin/openvpn –remote 10.100.1.20 –dev tun1 –ifconfig 172.16.1.2 172.16.1.1

·       Static Key VPN (simply 128-bit security)

Server 1

openvpn –genkey –secret key

scp key root@10.100.1.20:/usr/share/doc/openvpn-2.0.9/

/usr/sbin/openvpn –remote 10.100.1.50 –dev tun1 –ifconfig 172.16.1.1 172.16.1.2 –secret key

Server 2

/usr/sbin/openvpn –remote 10.100.1.20 –dev tun1 –ifconfig 172.16.1.2 172.16.1.1 –secret key

·       Full TLS VPN (revolving-key encryption)

Simple Load Balancing with APACHE MOD_PROXY

<VirtualHost *:80>

ProxyRequests off

ServerName domain.com

<Proxy balancer://mycluster>
# WebHead1

BalancerMember http://10.176.42.144:80

# WebHead2

BalancerMember http://10.176.42.148:80

# Security “technically we aren’t blocking

# anyone but this the place to make those

# chages

Order Deny,Allow

Deny from none

Allow from all

# Load Balancer Settings

# We will be configuring a simple Round

# Robin style load balancer.  This means

# that all webheads take an equal share of

# of the load.

ProxySet lbmethod=byrequests

</Proxy>

# balancer-manager

# This tool is built into the mod_proxy_balancer

# module and will allow you to do some simple

# modifications to the balanced group via a gui

# web interface.

<Location /balancer-manager>
SetHandler balancer-manager

# I recommend locking this one down to your

# your office

Order deny,allow

Allow from all

</Location>

# Point of Balance

# This setting will allow to explicitly name the

# the location in the site that we want to be

# balanced, in this example we will balance “/”

# or everything in the site.

ProxyPass /balancer-manager !

ProxyPass / balancer://mycluster/

</VirtualHost>

mysqld and mysqld_safe

Behind the scenes there are actually two versions of the MySQL server, “mysqld” and
“mysqld_safe”. Both read the same config sections. The main difference is that mysqld_safe
launches with a few more safety features enabled to make it easier to recover from a crash or
other problem.

Both mysqld and mysqld_safe will read config entries in the “mysqld” section. If you include a
“mysqld_safe” section, then only mysqld_safe will read those values in.

To LOCK and UNLOCK all tables in MySQL (Useful for backup/LVM Snapshot)

mysql -u root -p”password” -e “FLUSH TABLES WITH READ LOCK;”

mysql -u root -p”password” -e “UNLOCK TABLES;”


Q1.WHAT IS LINUX
Linux is an operating system based on UNIX, and was first introduced by Linus
Torvalds. It is based on the Linux Kernel, and can run on different hardware
platforms manufactured by Intel, MIPS, HP, IBM, SPARC and Motorola.

Q2.WHAT IS THE DIFFERENCE BETWEEN UNIX AND LINUX?


Unix originally began as a propriety operating system from Bell Laboratories,
which later on spawned into different commercial versions. On the other hand,
Linux is free, open source and intended as a non-propriety operating system for
the masses.

Q3.WHAT IS BASH?
BASH is short for Bourne Again SHell. It was written by Steve Bourne as a
replacement to the original Bourne Shell (represented by /bin/sh). It combines
all the features from the original version of Bourne Shell, plus additional
functions to make it easier and more convenient to use. It has since been
adapted as the default shell for most systems running Linux.

Q4. WHAT IS LILO?


LILO is a boot loader for Linux. It is used mainly to load the Linux operating
system into main memory so that it can begin its operations.

Q5.WHAT IS A SWAP SPACE?


A swap space is a certain amount of space used by Linux to temporarily hold
some programs that are running concurrently. This happens when RAM does not
have enough memory to hold all programs that are executing.

Q6.WHAT IS THE ADVANTAGE OF OPEN SOURCE?


Open source allows you to distribute your software, including source codes
freely to anyone who is interested. People would then be able to add features
and even debug and correct errors that are in the source code. They can even
make it run better, and then redistribute these enhanced source code freely
again. This eventually benefits everyone in the community.

Q7.WHAT ARE THE BASIC COMPONENTS OF LINUX?


Just like any other typical operating system, Linux has all of these components:
kernel, shells and GUIs, system utilities, and application program. What makes
Linux advantageous over other operating system is that every aspect comes
with additional features and all codes for these are downloadable for free.
Q8.DOES IT HELP FOR A LINUX SYSTEM TO HAVE MULTIPLE DESKTOP
ENVIRONMENTS INSTALLED?
In general, one desktop environment, like KDE or Gnome, is good enough to
operate without issues. It’s all a matter of preference for the user, although the
system allows switching from one environment to another. Some programs will
work on one environment and not work on the other, so it could also be
considered a factor in selecting which environment to use.

Q9.WHAT IS THE BASIC DIFFERENCE BETWEEN BASH AND DOS?


The key differences between the BASH and DOS console lies in 3 areas: – BASH
commands are case sensitive while DOS commands are not; – under BASH, /
character is a directory separator and acts as an escape character. Under DOS, /
serves as a command argument delimiter and is the directory separator – DOS
follows a convention in naming files, which is 8 character file name followed by a
dot and 3 character for the extension. BASH follows no such convention.

Q10.WHAT IS THE IMPORTANCE OF THE GNU PROJECT?


This so-called Free software movement allows several advantages, such as the
freedom to run programs for any purpose and freedom to study and modify a
program to your needs. It also allows you to redistribute copies of a software to
other people, as well as freedom to improve software and have it released to
the public.

Q11.DESCRIBE THE ROOT ACCOUNT.


The root account is like a systems administrator account, and allows you full
control of the system. Here you can create and maintain user accounts,
assigning different permissions for each account. It is the default account every
time you install Linux.

Q12.WHAT IS CLI?
CLI is short for Command Line Interface. This interface allows user to type
declarative commands to instruct the computer to perform operations. CLI offers
an advantage in that there is greater flexibility. However, other users who are
already accustom with using GUI find it difficult to remember commands
including attributes that come with it.

Q13. WHAT IS GUI?


GUI, or Graphical User Interface, makes use of images and icons that users click
and manipulate as a way of communicating with the computer. Instead of
having to remember and type commands, the use of graphical elements makes
it easier to interact with the system, as well as adding more attraction through
images, icons and colors.
Q14.HOW DO YOU OPEN A COMMAND PROMPT WHEN ISSUING A COMMAND?
To open the default shell (which is where the command prompt can be found),
press Ctrl-Alt-F1. This will provide a command line interface (CLI) from which you
can run commands as needed.

Q15.HOW CAN YOU FIND OUT HOW MUCH MEMORY LINUX IS USING?
From a command shell, use the “concatenate” command: cat /proc/meminfo for
memory usage information. You should see a line starting something like: Mem:
64655360, etc. This is the total memory Linux thinks it has available to use.

Q16.WHAT IS TYPICAL SIZE FOR A SWAP PARTITION UNDER A LINUX SYSTEM?


The preferred size for a swap partition is twice the amount of physical memory
available on the system. If this is not possible, then the minimum size should be
the same as the amount of memory installed.

Q17.WHAT ARE SYMBOLIC LINKS?


Symbolic links act similarly to shortcuts in Windows. Such links point to
programs, files or directories. It also allows you instant access to it without
having to go directly to the entire pathname.

Q18. DOES THE CTRL+ALT+DEL KEY COMBINATION WORK ON LINUX?


Yes, it does. Just like Windows, you can use this key combination to perform a
system restart. One difference is that you won’t be getting any confirmation
message and therefore, reboot is immediate.

Q19.HOW DO YOU REFER TO THE PARALLEL PORT WHERE DEVICES SUCH AS


PRINTERS ARE CONNECTED?
Whereas under Windows you refer to the parallel port as the LPT port, under
Linux you refer to it as /dev/lp . LPT1, LPT2 and LPT3 would therefore be referred
to as /dev/lp0, /dev/lp1, or /dev/lp2 under Linux.

Q20.ARE DRIVES SUCH AS HARDDRIVE AND FLOPPY DRIVES REPRESENTED


WITH DRIVE LETTERS?
No. In Linux, each drive and device has different designations. For example,
floppy drives are referred to as /dev/fd0 and /dev/fd1. IDE/EIDE hard drives are
referred to as /dev/hda, /dev/hdb, /dev/hdc, and so forth.

35 Tricky and Complex Unix Interview Questions and Commands (Part 1)

Here is the list of 35 complex and tricky unix interview questions and answers. A lot of complex unix
commands which are asked in unix interviews are SED, AWK, DU, HEAD, TAIL, WATCH, GREP, CUT,
PS, ZIP, UNZIP etc. A lot of tips and tricks are asked about these unix commands during interview.
Following questions and unix commands might help you in your unix interview.

1. How do you find which processes are using a particular file?

By using lsof command in UNIX. It will list down PID of all the processes which are using a particular file.

2. How do you find which remote hosts are connecting to your host on a particular port say
10123?

By using netstat command

For example: execute netstat -a | grep "port" and it will list the entire hosts which are connected to this
host on port 10123.

3. How to tell if my process is running in Unix?

You can list down all the running processes using [ps] command. Then you can “grep” your user name or
process name to see if the process is running.

4. What is ephemeral port in UNIX?

Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which
OS can open any port specified by ephemeral port range.

5. How to list down file/folder lists alphabetically?

Normally [ls –lt] command lists down file/folder list sorted by modified time. If you want to list then
alphabetically, then you should simply specify: [ls –l]

6. If one process is inserting data into your MySQL database? How will you check how many rows
inserted into every second?

By using "watch" command in UNIX


7. There is a file Unix_Test.txt which contains words "Unix". How will you replace all Unix to
UNIX?

By using SED command in UNIX

For example: you can execute sed s/Unix/UNIX/g fileName.

8. You have a tab separated file which contains Name, Address and Phone Number. List down all
Phone Number without their name and addresses?

By using either AWK or CUT command.

9. How to check if the last command was successful in Unix?

To check the status of last executed command in UNIX, you can check the value of an inbuilt bash
variable [$?]. See the below example:

$> echo $?

10. How to check all the running processes in Unix?

The standard command to see this is [ps]. But [ps] only shows you the snapshot of the processes at that
instance. If you need to monitor the processes for a certain period of time and need to refresh the results
in each interval, consider using the [top] command.

$> ps –ef

If you wish to see the % of memory usage and CPU usage, then consider the below switches:

$> ps aux

If you wish to use this command inside some shell script, or if you want to customize the output of [ps]
command, you may use “-o” switch like below. By using “-o” switch, you can specify the columns that you
want [ps] to print out.

$>ps -e -o stime,user,pid,args,%mem,%cpu
 

11 Your application home directory is full? How will you find which directory is taking how much
space?

By using disk usage (DU) command in Unix

For example du –sh . | grep G  will list down all the directories which have GIGS in Size.

12. How do you find for how many days your Server is up?

By using uptime command in UNIX

13. How to check if a file is present in a particular directory in Unix?

Using command, we can do it in many ways. Based on what we have learnt so far, we can make use of
[ls] and [$?] command to do this. See below:

$> ls –l file.txt; echo $?

If the file exists, the [ls] command will be successful. Hence [echo $?] will print 0. If the file does not exist,
then [ls] command will fail and hence [echo $?] will print 1.

14. You have an IP address in your network. How will you find hostname and vice versa?

By using nslookup command in UNIX

15. How to execute a database stored procedure from Shell script?

$> SqlReturnMsg=`sqlplus -s username/password@database<<EOF


BEGIN
Proc_Your_Procedure(… your-input-parameters …);
END;
/
EXIT;
EOF`
$> echo $SqlReturnMsg
16. How to check the command line arguments in a UNIX command in Shell Script?

In a bash shell, you can access the command line arguments using $0, $1, $2, … variables, where $0
prints the command name, $1 prints the first input parameter of the command, $2 the second input
parameter of the command and so on.

17. How to fail a shell script programmatically?

Just put an [exit] command in the shell script with return value other than 0. This is because the exit code
of successful Unix program is zero. So, suppose if you write exit -1 inside your program, then your
program will throw an error and exit immediately.

18. How to print/display the first line of a file?

There are many ways to do this. However the easiest way to display the first line of a file is using the
[head] command.

$> head -1 file.txt

If you specify [head -2] then it would print first 2 records of the file.

Another way can be by using [sed] command. [Sed] is a very powerful text editor which can be used for
various text manipulation purposes like this.

$> sed '2,$ d' file.txt

How does the above command work? The 'd' parameter basically tells [sed] to delete all the records from
display from line 2 to last line of the file (last line is represented by $ symbol). Of course it does not
actually delete those lines from the file, it just does not display those lines in standard output screen. So
you only see the remaining line which is the 1st line.]

19. How to print/display the last line of a file?

The easiest way is to use the [tail] command.


$> tail -1 file.txt

If you want to do it using [sed] command, here is what you should write:

$> sed -n '$ p' test

From our previous answer, we already know that '$' stands for the last line of the file. So '$ p' basically
prints (p for print) the last line in standard output screen. '-n' switch takes [sed] to silent mode so that [sed]
does not print anything else in the output.

20. How to display n-th line of a file?

The easiest way to do it will be by using [sed]. Based on what we already know about [sed] from our
previous examples, we can quickly deduce this command:

$> sed –n '<n> p' file.txt

You need to replace <n> with the actual line number. So if you want to print the 4th line, the command will
be

$> sed –n '4 p' test

Of course you can do it by using [head] and [tail] command as well like below:

$> head -<n> file.txt | tail -1

You need to replace <n> with the actual line number. So if you want to print the 4th line, the command will
be

$> head -4 file.txt | tail -1

21. How to remove the first line / header from a file?

We already know how [sed] can be used to delete a certain line from the output – by using the'd' switch.
So if we want to delete the first line the command should be:
$> sed '1 d' file.txt

But the issue with the above command is, it just prints out all the lines except the first line of the file on the
standard output. It does not really change the file in-place. So if you want to delete the first line from the
file itself, you have two options.

Either you can redirect the output of the file to some other file and then rename it back to original file like
below:

$> sed '1 d' file.txt > new_file.txt


$> mv new_file.txt file.txt

Or, you can use an inbuilt [sed] switch '–i' which changes the file in-place. See below:

$> sed –i '1 d' file.txt

22. How to remove the last line/ trailer from a file in Unix script?

Always remember that [sed] switch '$' refers to the last line. So using this knowledge we can deduce the
below command:

$> sed –i '$ d' file.txt

23. How to remove certain lines from a file in Unix?

If you want to remove line <m> to line <n> from a given file, you can accomplish the task in the similar
method shown above. Here is an example:

$> sed –i '5,7 d' file.txt

The above command will delete line 5 to line 7 from the file file.txt

24. How to remove the last n-th line from a file?


This is bit tricky. Suppose your file contains 100 lines and you want to remove the last 5 lines. Now if you
know how many lines are there in the file, then you can simply use the above shown method and can
remove all the lines from 96 to 100 like below:

$> sed –i '96,100 d' file.txt   # alternative to command [head -95 file.txt]

But not always you will know the number of lines present in the file (the file may be generated
dynamically, etc.) In that case there are many different ways to solve the problem. There are some ways
which are quite complex and fancy. But let's first do it in a way that we can understand easily and
remember easily. Here is how it goes:

$> tt=`wc -l file.txt | cut -f1 -d' '`;sed –i "`expr $tt - 4`,$tt d" test

As you can see there are two commands. The first one (before the semi-colon) calculates the total
number of lines present in the file and stores it in a variable called “tt”. The second command (after the
semi-colon), uses the variable and works in the exact way as shown in the previous example.

25. How to check the length of any line in a file?

We already know how to print one line from a file which is this:

$> sed –n '<n> p' file.txt

Where <n> is to be replaced by the actual line number that you want to print. Now once you know it, it is
easy to print out the length of this line by using [wc] command with '-c' switch.

$> sed –n '35 p' file.txt | wc –c

The above command will print the length of 35th line in the file.txt.

26. How to get the nth word of a line in Unix?

Assuming the words in the line are separated by space, we can use the [cut] command. [cut] is a very
powerful and useful command and it's real easy. All you have to do to get the n-th word from the line is
issue the following command:

cut –f<n> -d' '


'-d' switch tells [cut] about what is the delimiter (or separator) in the file, which is space ' ' in this case. If
the separator was comma, we could have written -d',' then. So, suppose I want find the 4th word from the
below string: “A quick brown fox jumped over the lazy cat”, we will do something like this:

$> echo “A quick brown fox jumped over the lazy cat” | cut –f4 –d' '

And it will print “fox”

27. How to reverse a string in unix?

Pretty easy. Use the [rev] command.

$> echo "unix" | rev

xinu

28. How to get the last word from a line in Unix file?

We will make use of two commands that we learnt above to solve this. The commands are [rev] and [cut].
Here we go.

Let's imagine the line is: “C for Cat”. We need “Cat”. First we reverse the line. We get “taC rof C”. Then
we cut the first word, we get 'taC'. And then we reverse it again.

$>echo "C for Cat" | rev | cut -f1 -d' ' | rev

Cat

29. How to get the n-th field from a Unix command output?

We know we can do it by [cut]. Like below command extracts the first field from the output of [wc –c]
command

$>wc -c file.txt | cut -d' ' -f1


But I want to introduce one more command to do this here. That is by using [awk] command. [awk] is a
very powerful command for text pattern scanning and processing. Here we will see how may we use of
[awk] to extract the first field (or first column) from the output of another command. Like above suppose I
want to print the first column of the [wc –c] output. Here is how it goes like this:

$>wc -c file.txt | awk ' ''{print $1}'

The basic syntax of [awk] is like this:

awk 'pattern space''{action space}'

The pattern space can be left blank or omitted, like below:

$>wc -c file.txt | awk '{print $1}'

In the action space, we have asked [awk] to take the action of printing the first column ($1).

30. How to replace the n-th line in a file with a new line in Unix?

This can be done in two steps. The first step is to remove the n-th line. And the second step is to insert a
new line in n-th line position. Here we go.

Step 1: remove the n-th line

$>sed -i'' '10 d' file.txt       # d stands for delete

Step 2: insert a new line at n-th line position

$>sed -i'' '10 i This is the new line' file.txt     # i stands for insert

31. How to show the non-printable characters in a file?

Open the file in VI editor. Go to VI command mode by pressing [Escape] and then [:]. Then type [set list].
This will show you all the non-printable characters, e.g. Ctrl-M characters (^M) etc., in the file.
32. How to zip a file in Linux?

Use inbuilt [zip] command in Linux

33. How to unzip a file in Linux?

Use inbuilt [unzip] command in Linux.

$> unzip –j file.zip

34. How to test if a zip file is corrupted in Linux?

Use “-t” switch with the inbuilt [unzip] command

$> unzip –t file.zip

35. How to check if a file is zipped in Unix?

In order to know the file type of a particular file use the [file] command like below:

$> file file.txt


file.txt: ASCII text

If you want to know the technical MIME type of the file, use “-i” switch.
$>file -i file.txt
file.txt: text/plain; charset=us-ascii

If the file is zipped, following will be the result


$> file –i file.zip
file.zip: application/x-zip

10 Interesting Unix Commands You Should Know

Following is the collection of some of the interesting unix commands which you should know. These unix
commands are based on network connections, SVN, find, list, history, lsof, sudo, until, git and cat. If you
know some extra unix commands like following, please share them. Here goes the list of unix commands
which I thought I must share.

1. How to get your top 100 unix commands?


history | sed "s/^[0-9 ]*//" | sed "s/ *| */\n/g" | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 100 >
commands.txt

2. How to copy a file to all subfolders of a directory using unix command?

find . -type d -exec cp pathtofile {}/ \;

3. How to delete all .svn folders from current directory using unix command?

find . -type d -name '.svn' -print -exec rm -rf {} \;

4. How to list all network connections (including which app they belong to)?

lsof -i -nP

5. How to run the last command as root?

sudo !!

6. How to execute the previous command until it is successful?

until !!; do :; done

7. How to display summary of git commit ids and messages for a given branch?

git log --pretty='format:%Cgreen%H %Cred%ai %Creset- %s'

8. How to list all file extensions present in the current directory?

ls | perl -lne '++$x{lc $1} if /[.](.+)$/ }{ print for keys %x'

9. How to get your top 10 commands with number of times you have used it?

cat .bash_history | cut -f 1 -d\ | sort | uniq -c | sort -r | head

10. How to generate list of usernames from an svn logs (Run from top level of the svn project)?

svn log | grep -E "r[0-9]+ \| .+ \|" | awk -F"|" '{print $2}' | sort | uniq > ~/authors.txt

Unix Basic Commands Interview Questions and Answers

Following is the list of unix basic commands interview questions and answers. These are very basic unix
commands and you must know these commands if you are going to appear in a unix interview. I have
listed down 31 unix interview questions with answers which cover basic unix commands like ls, banner,
cat, date, tee, who, man, head, pg, cmp, diff, grep, kill, echo, su etc. So lets have a look on following unix
interview questions and commands.

1. Construct pipes to execute the following jobs.

1. Output of who should be displayed on the screen with value of total number of users who have logged
in displayed at the bottom of the list.

2. Output of ls should be displayed on the screen and from this output the lines containing the word
‘poem’ should be counted and the count should be stored in a file.
3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a
file. From output of ls the lines containing ‘poem’ should be displayed on the screen along with the count.

4. Name of cities should be accepted from the keyboard . This list should be combined with the list
present in a file. This combined list should be sorted and the sorted list should be stored in a file ‘newcity’.

5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file
‘errorlog’.

2. Explain the following commands.

$ ls > file1
$ banner hi-fi > message
$ cat par.3 par.4 par.5 >> report
$ cat file1>file1
$ date ; who
$ date ; who > logfile
$ (date ; who) > logfile

3. What is the significance of the “tee” command?

It reads the standard input and sends it to the standard output while redirecting a copy of what it has read
to the file specified by the user.

4. What does the command “ $who | sort –logfile > newfile” do?

The input from a pipe can be combined with the input from a file . The trick is to use the special symbol “-“
(a hyphen) for those commands that recognize the hyphen as std input. In the above command the output
from who becomes the std input to sort , meanwhile sort opens the file logfile, the contents of this file is
sorted together with the output of who (rep by the hyphen) and the sorted output is redirected to the file
newfile.

5. What does the command “$ls | wc –l > file1” do?

ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying
this count , the value is stored in file1.

6. Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head

Ans: man
A filter is a program which can receive a flow of data from std input, process (or filter) it and send the
result to the std output. 

7. How is the command “$cat file2 “ different from “$cat >file2 and >> redirection operators?

8. Explain the steps that a shell follows while processing a command.

After the command line is terminated by the key, the shell goes ahead with processing the command line
in one or more passes. The sequence is well defined and assumes the following order.

Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless
quoted. All consecutive occurrences of a space or tab are replaced here with a single space.

Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped. 
Command substitution: Any command surrounded by backquotes is executed by the shell which then
replaces the standard output of the command into the command line.

Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?,
[, ]). Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The
list of these filenames then forms the arguments to the command.

PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to
search in order to hunt for the command.

9. What difference between cmp and diff commands?

cmp - Compares two files byte by byte and displays the first mismatch
diff - tells the changes to be made to make the files identical

11. What is the use of ‘grep’ command?

‘grep’ is a pattern search command. It searches for the pattern, specified in the command line with
appropriate option, in a file(s).
Syntax : grep
Example : grep 99mx mcafile

12. What is the difference between cat and more command?

Cat displays file contents. If the file is large the contents scroll off the screen before we view it. So
command 'more' is like a pager which displays the contents page by page.

13. Write a command to kill the last background job?

Kill $!

14. Which command is used to delete all files in the current directory and all its sub-directories?

rm -r *

15. Write a command to display a file’s contents in various formats?

$od -cbd file_name


c - character, b - binary (octal), d-decimal, od=Octal Dump.

16. What will the following command do?

$ echo *
It is similar to 'ls' command and displays all the files in the current directory.

17. Is it possible to create new a file system in UNIX?

Yes, ‘mkfs’ is used to create a new file system.

18. Is it possible to restrict incoming message?

Yes, using the ‘mesg’ command.

19. What is the use of the command "ls -x chapter[1-5]"


ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1,
chapter2, and so on.

20. Is ‘du’ a command? If so, what is its use?

Yes, it stands for ‘disk usage’. With the help of this command you can find the disk capacity and free
space of the disk.

21. Is it possible to count number char, line in a file; if so, How?

Yes, wc-stands for word count.


wc -c for counting number of characters in a file.
wc -l for counting lines in a file.

22. Name the data structure used to maintain file identification?

‘inode’, each file has a separate inode and a unique inode number.

23. How many prompts are available in a UNIX system?

Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).

24. How does the kernel differentiate device files and ordinary files?

Kernel checks 'type' field in the file's inode structure.

25. How to switch to a super user status to gain privileges?

Use ‘su’ command. The system asks for password and when valid entry is made the user gains super
user (admin) privileges.

26. What are shell variables?

Shell variables are special variables, a name-value pair created and maintained by the shell.
Example: PATH, HOME, MAIL and TERM

27. What is redirection?

Directing the flow of data to the file or from the file for input or output.
Example : ls > wc

28. How to terminate a process which is running and the specialty on command kill 0?

With the help of kill command we can terminate the process.


Syntax: kill pid
Kill 0 - kills all processes in your system except the login shell.

29. What is a pipe and give an example?

A pipe is two or more commands separated by pipe char '|'. That tells the shell to arrange for the output
of the preceding command to be passed as input to the following command.

Example : ls -l | pr

The output for a command ls is the standard input of pr.


When a sequence of commands are combined using pipe, then it is called pipeline.
30. Explain kill() and its possible return values.

There are four possible results from this call:

‘kill()’ returns 0. This implies that a process exists with the given PID, and the system would allow you to
send signals to it. It is system-dependent whether the process could be a zombie.

‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or security
enhancements are causing the system to deny its existence. (On some systems, the process could be a
zombie.)

‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process. This
means that either the process exists (again, it could be a zombie) or draconian security enhancements
are present

(e.g. your process is not allowed to send signals to *anybody*).

‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique is to
assume that success or failure with ‘EPERM’ implies that the process exists, and any other error implies
that it
doesn't.

An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ‘/proc’
filesystem: checking for the existence of ‘/proc/PID’ may work.

31. What is relative path and absolute path.

Absolute path : Exact path from root directory.


Relative path : Relative to the current path.

10 Basic Linux Networking and Monitoring Commands You Should Know

I have listed down 10 basic Linux networking and monitoring commands which each Linux user should
know. These Linux basic networking and monitoring commands like hostname, ping, ifconfig, iwconfig,
netstat, nslookup, traceroute, finger, telnet, ethtool are used for viewing the IP address of the Linux
server, managing Linux server network adapter configuration, making network connections among Linux
servers over telnet and ethernet, Linux server information etc. Lets have a look on the following Linux
networking and monitoring commands.

1. hostname

hostname with no options displays the machines host name

hostname –d displays the domain name the machine belongs to


hostname –f displays the fully qualified host and domain name
hostname –i displays the IP address for the current machine

2. ping

ping sends packets of information to the user-defined source. If the packets are received, the destination
device sends packets back. ping can be used for two purposes

1. To ensure that a network connection can be established.


2. Timing information as to the speed of the connection.
If you do ping www.yahoo.com it will display its IP address. Use ctrl+C to stop the test. 

3. ifconfig

View network configuration, it displays the current network adapter configuration. It is handy to determine
if you are getting transmit (TX) or receive (RX) errors.

4. iwconfig

The iwconfig tool is like ifconfig and ethtool for wireless cards. You can view and set the basic Wi-Fi
network details, such as the SSID, channel, and encryption. There's also many advanced settings you
can view and change, including receive sensitivity, RTS/CTS, fragmentation, and retries.

5. nslookup

If you know the IP address it will display hostname. To find all the IP addresses for a given domain name,
the command nslookup is used. You must have a connection to the internet for this utility to be useful.

e.g. nslookup blogger.com

You can also use nslookup to convert hostname to IP Address and from IP Address from hostname.

6. traceroute

A handy utility to view the number of hops and response time to get to a remote system or web site is
traceroute. Again you need an internet connection to make use of this tool.

7. finger

View user information, displays a user’s login name, real name, terminal name and write status. this is
pretty old unix command and rarely used now days.

8. telnet

Connects destination host via telnet protocol, if telnet connection establish on any port means connectivity
between two hosts is working fine.

telnet hostname port - will telnet hostname with the port specified. Normally it is used to see whether host
is alive and network connection is fine or not.

9. ethtool

Ethtool lets you view and change many different settings for ethernet adapters (which does not include
Wi-Fi cards). You can manage many different advanced settings, including tx/rx, checksumming, and
wake-on-LAN settings. However, here are more basic commands you might be interested in:

Display the driver information for a specific network adapter, great when checking for software
compatibility.

ethtool -i

Initiate an adapter-specific action, usually blinking the LED lights on the adapter, to help you identify
between multiple adapters or interface names:

ethtool -p
Display network statistics:

ethtool -s

Set the connection speed of the adapter in Mbps:

ethtool speed <10|100|1000>

10. netstat

Most useful and very versatile Linux command for finding connection to and from the host. You can find
out all the multicast groups (network) subscribed by this host by issuing "netstat -g"

netstat -nap | grep port will display process id of application which is using that port
netstat -a  or netstat –all will display all connections including TCP  and UDP  
netstat --tcp  or netstat –t will display only TCP  connection
netstat --udp or netstat –u will display only UDP  connection
netstat -g will display all multicast network subscribed by this host.

Linux Server Monitoring and Networking Commands for Linux Server Administrators - Part 2

I have complied a list Linux server monitoring and networking commands for Linux server administrators.
These are the very basic monitoring and networking commands which each Linux server administrator
should know. I had also compiled a list of basic Linux Networking and Monitoring commands in my
previous article. I will talk about iostat, meminfo, free, mpstat, netstat, nmon, pmap, ps, pstree, sar,
strace, tcpdump, top, uptime, vmstat, wireshark Linux server monitoring and networking commands for
Linux server administrators. These networking and monitoring Linux server commands helps Linux server
administrators to identify input/output problems on your Linux server, memory management of Linux
server, performance of Linux server, CPU usage, socket usage, routing, interface, protocol, network
statistics and lot more.

1. iostat

The iostat command shows in detail what your storage subsystem is up to. You usually use iostat to
monitor how well your storage sub-systems are working in general and to spot slow input/output problems
before your clients notice that the server is running slowly. 

2. meminfo and free

Meminfo gives you a detailed list of what's going on in memory. Typically you access meminfo's data by
using another program such as cat or grep. For example,

cat /proc/meminfo

gives you the details of what's going on in your server’s memory at any given moment.

For a quick “just the facts” look at memory, you can use the free command. In short, free gives you the
overview; meminfo gives you the details.

3. mpstat

The mpstat command reports on the activities of each of the available CPUs on a multi-processor server.
These days, thanks to multi-core processors, that’s almost all servers. mpstat also reports on the average
activities of all your server's CPUs. It enables you to display overall CPU statistics per system or per
processor. This overview can alert you to possible application problems before they get to the point of
annoying users.

4. netstat

Netstat, like ps, is a Linux tool that administrators use every day. It displays a lot of network related
information, such as socket usage, routing, interface, protocol, network statistics, and more. Some of the
most commonly used options are:

-a Show all socket information


-r Show routing information
-i Show network interface statistics
-s Show network protocol statistics

5. nmon

Nmon, short for Nigel's Monitor, is a popular open-source tool to monitor Linux systems performance.
Nmon watches the performance information for several subsystems, such as processor utilization,
memory utilization, run queue information, disk I/O statistics, network I/O statistics, paging activity, and
process metrics. You can then view nmon's real-time system measurements via its curses “graphical”
interface.

To run nmon, you start the tool from the shell. Once up, you select the subsystems to monitor by typing in
its one-key commands. For example, to get CPU, memory, and disk statistics, you type c, m, and d. You
can also use nmon with the -f flag to save performance statistics to a CSV file for later analysis.

For day to day server monitoring I find nmon to be the single most useful program in my Linux system
management tool-kit.

6. pmap

The pmap command reports the amount of memory that your server's processes are using. You can use
this tool to determine which processes on the server are being allocated memory and whether any of
these processes are being piggy with RAM.

7. ps and pstree

The ps and pstree commands are two of the Linux administrator’s best friends. They both provide a list of
all currently running processes. Ps tells you how much memory and processor time the server’s programs
are using. Pstree shows less information, but highlights which processes are the children of other
processes. Armed with this information, you can spot out–of-control processes and kill them off with
Linux's “take no prisoners” kill command.

8. sar

The sar program is a Swiss-army knife of a system monitoring tool. The sar command is actually made up
of three programs: sar, which displays the data, and sa1 and sa2, which collect and store it. Once
installed, sar creates a detailed overview of CPU utilization, memory paging, network I/O and transfer
statistics, process creation activity, and storage device activity. The big difference between sar and nmon
is that the former is better at long-term system monitoring, while I find nmon to be better at giving me a
quick read on my server's status.

9. strace

strace is often thought of a programmer's debugging tool, but it's more than that. It intercepts and records
the system calls that are called by a process. This makes it a useful diagnostic, instructional, and
debugging tool. For example, you can use strace to find out which configuration file a program is actually
using when it starts up.

Strace does have one flaw though. When it's checking out a specific process, that process' performance
will fall through the floor. Thus, I only use strace when I already have a darned good reason to think that
that program is causing trouble.

10. tcpdump

Tcpdump is a simple, robust network monitoring utility. Its basic protocol analyzing capability enables you
to get a rough view of what is happening on your network. To really dig into what's going on with your
network however, you'll want to use Wireshark.

11. top

The top command shows what's going on with your active processes. By default, it displays the most
CPU-intensive tasks running on the server and updates the list every five seconds. You can sort the
processes by PID (Process ID); age, newest first; time, by cumulative time; and resident memory usage
and total time it's been using the CPU since startup. I find this a fast and easy way to see if any process is
starting to go out of control and about to get into trouble.

12. uptime

Use uptime to see how long the server has been running and how many users are logged on. It also gives
you an overview of the average server load. The optimal value of the load is 1 or less, which means that
each process has immediate access to the CPU and there are no CPU cycles lost.

14. vmstat

For the most part, you use vmstat to monitor what's going on with virtual memory. Linux constantly uses
virtual memory to get the best possible storage performance.

If your applications are taking up too much memory you get excessive page-outs — programs moving
from RAM to your system's swap space, which is on the hard drive. Your server can reach a point where
it's spending more time managing memory paging than running your applications, a condition called
thrashing. When your computer is thrashing, its performance falls through the floor. 

Vmstat, which can display either average data or actual samples, can help you spot memory pig
programs and processes before they bring your server to a crawl.

15. Wireshark

Wireshark, formerly known as Ethereal (and still often referred to that way), is tcpdump's big brother,
though it is more sophisticated and with far more advanced protocol analyzing and reporting. Wireshark
has both a GUI interface and a shell interface. 

If you can master these commands, you'll be well on your way to being a good Linux system
administrator.

1. How to check Gateway and net mask??

Ans. netstat -ar


2. RSYNC command executed, got error while copying, again the command initiated,
whether the file copies from 1st and incremental.

Ans:- The rsync command is incremental copy(check the files with destination and copies rest of
the part).

3. In RAID 5, two disks are corrupted what to do ?

Ans:- In RAID 5 , if one disk is corrupted , we can replace that effective drive without any
downtime. But here the scenario is  two disks are corrupted , in this case we don’t have much
option left. Need to replace all the effective disks and rebuild the OS. If we kept two spare hard
disk while creating RAID , the situation will be different.

4.what is hard and soft mounting?

Ans.  Hard mount:

— If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the
server. The NFS daemon retries will not time out, will affect system performance, and you
cannot interrupt them.

Soft mount

— If the NFS file system is soft mounted, NFS will try repeatedly to contact the server until
either:

A connection is established

The NFS retry threshold is met

The nfstimeout value is reached

When one of these events occurs, control returns to the calling program.

5.what is /proc file system ?

Ans. procfs (or the proc file system  is a special file system in UNIX-like operating systems that
presents information about processes and other system information in a hierarchical file-like
structure, providing a more convenient and standardized method for dynamically accessing
process data held in the kernel than traditional tracing methods or direct access to kernel
memory.

6.what is daemon responsible for tracking events in a server?

Ans. syslogd
7.what is difference between raid 0 and raid 1?

Ans. RAID 0, No redundancy

RAID 1, Redundancy

8.what is kernel panic?

Ans. A kernel panic is an action taken by an operating system upon detecting an internal fatal
error from which it cannot safely recover. The term is largely specific to Unix and Unix-like
systems; for Microsoft Windows operating systems the equivalent term is “bug check” (or “Blue
Screen of Death”).

9.what is ‘0’ process?

Ans. parent process id of ‘init’ (sched process)

10.what is the last service started by init before logging screen appears?

Ans. /etc/rc.local which are the last commands run in initialization process or even booting
process

11.difference between LILO &GRUB?

Ans. LILO, Linux Loader, on kernel versions < 2.4,It does’nt support booting from n/w.

Grub, Grand unified boot loader. on Kernel versions >= 2.6, supports booting from network.

12.Stages of boot loader?

Ans.6 stages.

1. BIOS
2. MBR
3. GRUB
4. Kernel
5. Init
6. Runlevels

13.when two machines are there, one machine MAC & IP address is known,  another machine
MAC address is there, how to find IP of another machine using command?

Ans. ‘arp’ command

14.while ‘ping’ cmd is used  the system not receiving any o/p?
Ans. ping cmd is blocked in kernel parameters

ping  cmd uses icmp protocol.

15.Issue is there with hard drives ,dont know  which drive is fault. how to check which drive is
fault?

Ans. If it is HP and IBM Servers, it will show amber color for faulty HDD.  otherwise we can
see the status of the hard disks in ILO (Integrated Lights   Out)configuration for HP servers and
the same remote accessing feature also available for IBM. other wise you can check in dmesg .

16.In production server one drive got failed,how to replace new drive?

Ans. plug and play devices, in raid -1 mirror is used machine can run with one hard disk . we can
replace

17.ASR means AUTOMATED SERVER RECOVERY

18. What is Network bonding? Requirements for bonding?

Ans. N/w Bonding will configure on the servers for redundancy. It requires minimum 2 Ethernet
Ports/Cards.

19. MI means?

Ans. Major Incident

20. Different mount options apart from mount command?

Ans. crazy question, i will say /bin/mount., But it is mount command full form. I heared
guestmount commnad also there to mount a disk …but didn’t used yet.

22.how to start services apart from ‘service’ cmd?

Ans. /ect/init.d/<service name> start

23.how to display memory info?

Ans. cat /proc/meminfo

free -go (To see in GB)

24.how to display hardware information?

Ans. dmidecode |less


Command: lscpu

List available cpus and their caracteristics , Not available on older distribution

Command: lshal

Require HAL (Hardware Abstraction Layer) to be installed . List all hardware visible by HAL

Command: lshw

Available on Debian and Ubuntu based distributions by default .Available in the Fedora
repositories .Uses many inputs            to detect all hardware: Kernel, HAL, DMI, etc. use ‘-html’
switch that generates hardware reports

Command: lspci

Standard command ,List all hardware connected to the PCI bus as detected by the kernel

Command: lsusb

Standard command. List all hardware connected to the USB buses as detected by the kernel

Command: dmidecode

Standard command, Get the source information from the DMI (a kind of BIOS interface) .List all
hardware as reported by       the DMI interface

25. command to check the directory’s partition or mount ?

Ans. df -P file/goes/here | tail -1 | cut -d’ ‘ -f 1

[root@testmachine Desktop]# df -P /boot/ | tail -1 | cut -d’ ‘ -f1

/dev/sda1

26.how to rollback application?

Ans.  insert ‘ts_flags=repackage’ in /etc/yum.conf and create file /etc/rpm/macros with an


entry’repackage’ parameter.

27.how to rollback filesystem?

Ans. If ‘Snapshot'(backup) is taken, using superblocks we can rollback file system.

28. Newly attached hard drive is not recognizing how to make it active ?
Ans. After building server with 2 hard disks, again if we attach any hdd, server wont recognizes
it. if the server want to recognize it, we need to reboot it and create RIAD fo that HDD also.

If we replaced Faulty hard disk with new one, Server will take 1 hr time to synchronize the data
(RIAD 1 and RAID 5).

29.Different raid levels & explanation?

Ans. raid 0, raid1, raid1+0, raid 1+0, raid3, raid 5, raid50, raid6.

30.file system is full? user need some space to run his work ?

Ans. 1. If it is configured with ‘lvm’ we can extend it, or else we can make use of reserved
blocks.

2. Delete the old files after getting confirmation from user.

31. How to check a package is installed or not?

Ans.  rpm -qa | grep <package name>, it will gives package name and version, if it installed,
returns empty screen if not installed.

32.how to check which ports are working?

Ans. netstat cmd

33.how to configure static route?

Ans. vi /etc/sysconfig/network-scripts/ifcfg-route0

34. How to check the processor type ?

Ans. grep “model name” /proc/cpuinfo

[root@testmachine Desktop]# grep -i “model name” /proc/cpuinfo  | cut -d: -f2

Intel(R) Core(TM)2 Duo CPU     T9550  @ 2.66GHz

35.what is GRUB?

Ans. Grand unified Boot loader. Its boot loader in linux. (kernel versions >=2.6)

36.how to check info of  hard drives ?

Ans. df or mount
37.How to increase physical memory in steps?

Ans. Hardware job, Its requires a down time form the users/customers , to upgrade memory
modules . (memory size should be match with old memory modules.)

38.how to mount alternate superblock command?

Ans. mount  sb=alternative superblock  /dev/sda

39.How to create a never expire passwod for user?

Ans. chage -E -1 username

40.tune2fs command used for ?

Ans. for tuning  the file system parameters

41.I am sharing a directory through samba , everything is accessible apart  from soft link files
,how to share those soft links shares?

Ans. Apply parameters in share definition

follow symlinks =yes

wide links =yes

42.maximum file grow in ext4 filesystem?

Ans. The ext4 file system can support volumes with sizes up to 1 exbibyte (EiB) and files with
sizes up to 16 tebibytes (TiB). However, Red Hat recommends using XFS instead of ext4 for
volumes larger than 100 TB.

1 exbibyte = 260 bytes = 1152921504606846976bytes = 1,024 pebibytes


1 tebibyte = 240 bytes = 1099511627776bytes = 1024 gibibytes

43.scenerio

# df -h

……………. file system full

#ls -l

two files…..1. one file is occupying full space

# rm -f filename
#df  -h

same output …file system is full

#ls -l

file is not there ..still file system is full.

Ans.

# lsof | grep “(deleted)” # (or lsof | grep (filename))

If it’s safe to do so, take the pid from the lsof command, and do:

Code:

# ls -l /proc/(pid)/fd # to get the fd# for the file

# > /proc/(pid)/fd/(fd#) # to empty the file.

Otherwise the space will be freed when the application using it closes, or the system restarts.

# implies a root prompt, meaning your sysadmin needs to do this.

(S)he will need to install lsof if it’s not already installed.

44.No such file or directory error?

Ans. ls -ld <filename>, error, no such file or directory..

Reasons: Check it , by logging as a root. might be normal user not having the permissions to
view it.

we will get these type of messages, if the directory or file is unmounted or deleted.

45.how to check database and other applications running?

Ans. ps -ef | grep <database name/ application name>

46.mpstat, iostat,vmstat statistics define?

Ans.

1. iostat – Basic example

 
Iostat without any argument displays information about the CPU usage, and I/O statistics about
all the partitions on the system as shown below.

#iostat

Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2013

avg-cpu:  %user   %nice %system %iowait  %steal   %idle

5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn

sda             194.72      1096.66      1598.70 2719068704 3963827344

sda1            178.20       773.45      1329.09 1917686794 3295354888

sda2             16.51       323.19       269.61  801326686  668472456

vmstat : vmstat by default will display the memory usage (including swap) as shown below.

#vmstat

procs ———–memory———- —swap– —–io—- –system– —–cpu——

r  b   swpd   free   buff  cache     si   so    bi    bo   in   cs us sy id wa st

0  0 305416 260688  29160 2356920    2    2     4     1    0    0  6  1 92  2  0

Procs – r: Total number of processes waiting to run

Procs – b: Total number of busy processes

Memory – swpd: Used virtual memory

Memory – free: Free virtual memory

Memory – buff: Memory used as buffers

Memory – cache: Memory used as cache.

Swap – si: Memory swapped from disk (for every second)

Swap – so: Memory swapped to disk (for every second)

IO – bi: Blocks in. i.e blocks received from device (for every second)
IO – bo: Blocks out. i.e blocks sent to the device (for every second)

System – in: Interrupts per second

System – cs: Context switches

CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time

mpstat – Display basic info

By default mpstat displays CPU statistics.

46.how to list newly attached hardware?

Ans. dmidecode | less

47.In RAID , statistics display  “_U” .what is the meaning?

Ans. one of the hard disk is failed.

48.what is initrd? what it does?

Ans. initrd stands for Initial RAM Disk. initrd is used by kernel as temporary root file system
until kernel is booted and the real root file system is mounted. It also contains necessary drivers
compiled inside, which helps it to access the hard drive partitions, and other hardware parts of
the server.

49.where /proc file system rests?

Ans. Linux systems store all data as files. Most users are familiar with the two primary types of
files: text and binary. But the /proc/ directory contains another type of file called a virtual file. As
such, /proc/ is often referred to as a virtual file system.

50.where tmpfs stores?

Ans. Tmpfs is a file system which keeps all files in virtual memory. Everything in tmpfs is
temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs
instance, everything stored therein is lost. tmpfs lives completely in the page cache and on swap,
all tmpfs pages currently in memory will show up as cached

51.Daemons in nfs?

Ans. mountd ,nfsd,lockd,statd,nfslogd

52.how to change user access to entire file system?


Ans. chown -R

53.why UMASK is used, where to change its value to be effective on entire OS?

Ans. When user create a file or directory under Linux or UNIX, it creates with a default set of
permissions. In most case the system defaults may be open or relaxed for file sharing purpose.
For example, if a text file has 666 permissions, it grants read and write permission to everyone.
Similarly a directory with 777 permissions, grants read, write, and execute permission to
everyone.

You can setup umask in /etc/bashrc or /etc/profile file for all users. By default most Linux
machines set it to 0022 (022) or 0002 (002).

Open /etc/profile or ~/.bashrc file, enter:

# vi /etc/profile

OR

# vi ~/.bashrc

Append/modify following line to setup a new umask:

umask 022

Save and close the file. Changes will take effect after next login. All UNIX users can override
the system umask defaults in their /etc/profile file, ~/.profile (Korn / Bourne shell) ~/.cshrc file
(C shells), ~/.bash_profile (Bash shell) or ~/.login file (defines the user’s environment at login).

54.how to display the list of specific  port ?

Ans. netstat -ntlp | grep <service daemon name>

55.what is SFTP?

Ans.secure file transfer protocol, a network protocol for secure file transfer over a secure shell.

56.Top responding slowly..other option to check load average?

Ans. vmstat

57.Difference between crontab and at ?

list crontab entry?

Ans.crontab -l
58.what is MTA?

Ans. Mail Transfer Agent

59.while install rpm package, progress reports already use , but  no package name doesn’t exist
in rpm  list ?

Ans. rpm –reinstall <package name>

60.create user in different directory?

Ans. useradd -m -d  /newdir/<username>  username

Errors:—

Error name: /dev/null: Permission denied

I got this  error message while  Logging (doing ssh) into  one production server.   Please do the
Following things to fix it. It doesn’t requires any reboot and it wont effect to production.

testmachine11:~ # ls -ld /dev/null

crw——- 1 root root 1, 3 Apr 22  2012 /dev/null

It is a character file, The permissions should be  666 for this one. So , change the permission to
666. after that you wont see that message.

testmachine11:~ # chmod 666 /dev/null

testmachine11:~ # ls -ld /dev/null

crw-rw-rw- 1 root root 1, 3 Apr 22  2012 /dev/null

(OR)

You can delete it and recreate the /dev/null file. But first solution is little bit faster.

To Remove it..

#rm -f /dev/null

To create the special file for /dev/null

#mknod /dev/null c 1 3
This creates the /dev/null special file that is a special character file with the major device number
1 and the minor device  number 3.

Then start the sshd service

# /etc/init.d/sshd start

# /etc/init.d/sshd status

1. What is LVM and what is its role?

LVM stands for Logical Volume Manager. It is used to resize the file system online.

2. What is the role of Ivextend and


Ivreduce?

They are commands used to extend or reduce the volume.

3. What is umask?

umask stands for “user file creation mask”. It is used to determine those settings of a mask that control file
permission data and directory data.
4. In the context of Linux, what does
POSIX stand for?

POSIX stands for Portable Operating System Interface for Computer Environments. It is the de facto standard
for ensuring compatibility between UNIX versions.

5. How is Linux connected to UNIX?

The kernel that Linux uses resembles that of UNIX but does not require UNIX code.

6. In the context of Linux, what is


GPL?

GPL stands for General Public License. It was originally created to protect the GNU project.

7. Explain the GNU project.

GNU is a project that was initiated by Richard Stallman in 1983 at MIT. The project began with the idea of
providing control and freedom to the users in using software. As part of the GNU project, users are free to
use, run, copy and share software.
8. How do you turn a Linux system
into a proxy server?

Using the Squid service, you can turn a Linux system into a proxy server.

9. What is LILO in the context of


Linux?

LILO is a boot loader for Linux. It is used for loading the Linux operating system into the main system
memory before beginning operations.

1 0 . D e fi n e B I O S , M B R a n d G R U B .

BIOS stands for Basic Input/Output System. MBR is Master Boot Record and GRUB is Graand Unified
Bootloader.

1 1 . W h a t i s t h e d i ff e r e n c e b e t w e e n
home directory and working
directory?

Home directory is the default directory when a user logs in whereas working directory is the user’s current
working directory.
12. In Linux, how do you track
system events?

To track events, a daemon called syslogd is used.

13. What do you do when you


encounter a suspicious IP?

We should first block the suspicious IP by integrating tcp_wrapper. Next, we need to enable the
“tcp_wrapper=YES” parameter in the configuration file at ‘/etc/vsftpd.conf’. Final step – include the
suspicious IP in the ‘host.deny’ file in ‘/etc/host.deny’.

14. Describe Telnet and SSH.

Both Telnet and SSH are communication protocols that are used to manage systems remotely. While SSH
requires exchange of keys, Telnet transmits data in plain text. Hence, SSH is said to be more secure than
Telnet.

1 5 . S t a t e t h e d i ff e r e n c e b e t w e e n t h e
locate and slocate commands.

Locate searches for a file with the latest entries while slocate searches for files that users have accessed
most recently.
16. How many partitions do you need
to install Linux?

You need at least two partitions to install Linux on your system.

17. How do you review boot


messages in Linux?

By using the dmesg command. Dmesg will pull out boot messages stored in the kernel ring buffer.

18. What are symbolic links?

Symbolic links are “shortcut keys” in Linux. These links point to specific programs, files or directories.

19. What do Hard Links do?

Hard links point directly to the physical file located on the disk, and not on the path name.

20. What does pwd stand for?

In Linux, it stands for print working directory.


2 1 . E x p l a i n t h e t h r e e d i ff e r e n t
permissions in Linux.

– Read: Gives users the permission to read files or list directories


– Write: Gives users the permission to write to the file of new files and directories
– Execute: Gives users the permission to run the file or lookup a specific file within a directory

22. What is the # symbol used for?

# is used for creating new comments.

Das könnte Ihnen auch gefallen