1) What Is GRUB
1) What Is GRUB
GNU GRUB is a Multiboot boot loader. It is derive from GRUB, the GRand Unified Bootloader,
which was originally designed and implemented by Erich Stefan Boleyn.
Briefly, a boot loader is the first software program that runs when a computer starts. It is
responsible for loading and transferring control to the operating system kernel software
(such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating
system (e.g. GNU)
Press the power button on your system, and after few moments, you see the Linux login prompt.
Have you ever wondered what happens behind the scenes from the time you press the power button
until the Linux login prompt appears?
The following are the 6 high level stages of a typical Linux boot process.
a. BIOS
b. MBR
c. GRUB
Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample
grub.conf of CentOS.
As you notice from the above info, it contains kernel and initrd image.
So, in simple terms GRUB just loads and executes Kernel and initrd images.
d. Kernel
e. Init
Looks at the /etc/inittab file to decide the Linux run level. Rhel 7>> /etc/system/system/
Following are the available run levels
o 0 – halt
o 1 – Single user mode
o 2 – Multiuser, without NFS
o 3 – Full multiuser mode
o 4 – unused
o 5 – X11
o 6 – reboot
Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate
program.
Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what
0 and 6 means, probably you might not do that.
Typically you would set the default run level to either 3 or 5.
f. Runlevel programs
When the Linux system is booting up, you might see various services getting started. For
example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed
from the run level directory as defined by your run level.
Depending on your default init level setting, the system will execute the programs from one of
the following directories.
o Run level 0 – /etc/rc.d/rc0.d/
o Run level 1 – /etc/rc.d/rc1.d/
o Run level 2 – /etc/rc.d/rc2.d/
o Run level 3 – /etc/rc.d/rc3.d/
o Run level 4 – /etc/rc.d/rc4.d/
o Run level 5 – /etc/rc.d/rc5.d/
o Run level 6 – /etc/rc.d/rc6.d/
Please note that there are also symbolic links available for these directory under /etc directly.
So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
Programs starts with S are used during startup. S for startup.
Programs starts with K are used during shutdown. K for kill.
There are numbers right next to S and K in the program names. Those are the sequence number
in which the programs should be started or killed.
For example, S12syslog is to start the syslog deamon, which has the sequence number of 12.
S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog
program will be started before sendmail.
There you have it. That is what happens during the Linux boot process.
Change run level in rhel 7:
#systemctl get-default
# systemctl get-default
multi-user.target
3) Which files are called for user profile by default when a user gets login
$HOME/.bash_profile, $HOME/.bash_bashrc
id:5:initdefault: to id:3:initdefault:
5) What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell
etc..
An inode is a data structure on a traditional Unix-style file system such as UFS or ext3. An
inode stores basic information about a regular file, directory, or other file system object
Group
File Size
File access, change and modification time (remember UNIX or Linux never stores file creation
time, this is favorite question asked in UNIX/Linux sys admin job interview)
Extended attribute such as append only or no one can delete file including root user
(immutability)
ls -i
Following command will show complete info about any file or folders with inode number
stat file/folder
Files/Folders can also be deleted using inode numbers with following command:
find out the inode number using ‘ls -il’ command then run below command
blockdev command
# Before test
256
real 0m6.845s
user 0m0.004s
sys 0m0.865s
# After test
2435+1 records in
real 0m0.370s
user 0m0.001s
sys 0m0.370s
CHAGE
usermod -L username
10) How many default number of Shells available and what are their names?
11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while adding
user
/etc/login.defs
12) …… command used for changing authentication of linux system to LDAP/NIS/SMB/KERBOS
authconfig
chattr
/etc/sysconfig/network-scripts/ethX
15) How can we change speed and make full duplex settings for eth0
OR
mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD
/etc/resolve.conf
17) Main configuration file and command used for exporting NFS directories and it’s deamons
/etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status
netstat -antp
nmap
Soft Links => 1) Soft link files will have different inode numbers then source file
Hard Links => 1) Hard links will have the same inode number as source file
22) Restricting insertion into file if full permission are assigned to all
chattr +i filename
23) Display or Kill all processes which are accessing any folder/file
killall -u username
25) How can we have daily system analysis and reports over mail
Use logwatch
26) How can we rotate logs using logrotate without performing any operation like move and gzip’ng
over original file and then creating new file (which is very lengthy process)
We can use “logrotate”‘s “copytruncate” option which will simply copy original file and truncate original
file
27) Command to collect detailed information about the hardware and setup of your system
dmidecode , sysreport
Cron :
every minute)
2) Cron job can be scheduled by any normal user ( if not restricted by super
user )
5) Use cron when a job has to be executed at a particular hour and minute
Anacron :
2) Anacron can be used only by super user ( but there are workarounds to
and system is down during that time, it start the jobs when the system
minute
SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465, POP3/POP3S 110/995, IMAP/IMAPS
143/993
31) How to setup ACLs in following case:
1) Create a file FILE1 and this should be read,write,executable for all user but Read only for user USER1
Run test on device [TEST: offline short long conveyance select,M-N pending,N
http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/
or
SYN Flood : A SYN flood occurs when a host sends a flood of TCP/SYN packets, often with a
fake/forged sender address. Each of these packets is handled like a connection request, causing the
waiting for a packet in response from the sender address(response to the ACK Packet). However,
because the sender address is forged, the response never comes. These half-open connections
saturate the number of available connections the server is able to make, keeping it from responding to
http://www.thegeekstuff.com/2012/01/linux-unix-kernel/
Use “ssh-keygen -t dsa or rsa” at local system for creating public and private keys
“grubby –default-kernel”
who -r
File System is a method to store and organize files and directories on disk. A file system can have
different formats called file system types. These formats determine how the information is stored as
files and directories.
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: – USB disk, CDROM, Hard Disk (sda, sdb, sdc etc….)
tune2fs -j /dev/{device-name}
/etc/sysctl.conf
47) Commands used to install, list and remove modules from kernel
Installing/adding a module:
insmod mod_name
modprobe mod_name
Adding swap :
mkswap /opt/myswap
swapon -a
For adding this myswap at boot time, add following in /etc/fstab file:
Deleting Swap :
vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays
summary information about operating system memory, processes, interrupts, paging and block I/O
Reference : http://en.wikipedia.org/wiki/Tmpfs
tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is
intended to appear as a mounted file system, but stored in volatile memory instead of a persistent
storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a
disk file system.
Everything stored in tmpfs is temporary in the sense that no files will be created on the hard drive;
however, swap space is used as backing store in case of low memory situations. On reboot, everything in
tmpfs will be lost.
The memory used by tmpfs grows and shrinks to accommodate the files it contains and can be swapped
out to swap space.
Screen is an screen manager with VT100/ANSI terminal emulation and used to take GNU screen session
remotely or locally and while Script make typescript of terminal session
Script : creates a file and store all the terminal output to this file
Ans Run “ps -elFL” and find out the PSR column which is showing the processor number to the process
53) How can we check vendor, version, release date, size, package information etc… of any installed
rpm?