Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Thursday, 28 September 2017

Thumb Rules – AIX ADMIN


1.    Collect System Information before doing any change on your server.

2.    Ensure the current OS level is consistent:     “oslevel -s;oslevel -r;instfix -i|grep ML;instfix -i|grep SP;lppchk -v” [If the os is inconsistent, then first bring the os level to consistent state and then proceed with the change].

3.    Check the lv/filesystems consistency “df -k”(df should not hang); all lvs should be in sync state “lsvg -o|lsvg -il”.

4.    Check errpt & ‘alog -t console -o’ to see if there are any errors.

5.    Perform ‘pwdck’ & ‘grpck’ to verify password & group file consistency.

6.    Ensure the root user has not expired.

7.    Ensure your id on the server is working.

8.    Ensure mksysb(OS image backup) is taken. Verify mksysb with “lsmksysb -l -f /mksysbimg”(check size).

9.    Check the /etc/exclude.rootvg to see if any important filesystem/dir is excluded from the mksysb backup.

10.    Take the TSM backup of mksysb as well.

11.    Ensure the scheduled TSM backup of filesystems is done.

12.    Verify boot list & boot device:   “bootlist -m normal -o”  “ipl_varyon -i”

13.    Ensure hd5(bootlv) is 32MB (contigous PPs)  [very important for migration]

14.    Remember Application/Database team are responsible for their Application/Database backup and restore. Therefore alert the application teams so that they take their backups and other precautions before we perform our change.

15.    Ensure the ‘console’ for the server is working.

16.    Initiate the change on console. If there is any network disconnection during the change, you can reconnect to the console and get the menus back.

17.    Remember three essential things are in place before you perform any change “backup(mksysb); system information; console”

18.    Ensure you are on right server(hostname;ifconfig -a) before you perform change.

19.    Remember one change at one time; multiple changes could cause problem & can complicate troubleshooting.

20.    Pre-inform the monitoring team about your change; so that there are no vague alerts/PRs.

21.    Ensure there is enough free filesystem space(/usr, /var, / ), required for the change.

22.    Before and After the change, ensure the filesystems are well below the thresholds(75%).
23.    Perform changes only for the approved CRs(change requests).

24.    Check the history of the servers(PRs or CRs)…to see if there were any issues or change failures for these servers.

25.    Ensure that there is no clash of SAs over changes; one change being performed by multiple SAs. Its better to verify with the ‘who -u’ command, to see if there are any SAs already working on the server.

26.    If there are two disks in rootvg, then perform alt disk clone for one disk. This is fastest & safest backout method in case of any failure. Though you perform alt disk clone, ensure you as well take mksysb.

27.    For migration change, check if there is SAN(IBM/EMC..) used, if so, then you have to follow the procedure of exporting vgs, uninstall sdd* fileset;and after migration reinstall sdd* fileset, reimport vgs etc.

28.    Ensure hd5(bootlv) is 32MB (contigous PPs)  [very important for migration]

29.    EXPECT THE UNEXPECTED : Ensure you have the clear backout plan in place.

30.    Have the patches/filesets pre-downloaded and verified.

31.    Check/verify the repositories on NIM/central server; check if these repositories were tested/used earlier.

32.    Verify the connectivity between the client and NIM server. In some accounts the admin network is to be exclusively enabled(cabled) for the changes.

33.    Take care of the network zones(public, private, behind firewall); each zone may have their separate NIM server.

34.    Take care of the static routes(which may differ across zones). Ensure the static routes are not disturbed after the change.

35.    Ensure there are no other conflicting changes from other departments such as SAN, network, firewall, application.. which could dampen your change.

36.    Maintain/record the commands run/console output in the notepad(named after the change).

37.    Update the change record with the output/artefact. You can execute the commands with date command, so that the date & time when the command is run is recorded “date;uptime;oslevel -r”.

38.    If the system has not rebooted from longtime(> 100 days); then perform ‘bosboot’ & then reboot the machine(verify the fs/appln. after reboot), & then commence with the migration/upgrade. [Donot reboot the machine if the bosboot fails!]

39.    Check filesystems count “df -k|wc -l”  ; verify the count after migration or reboot.

40.    Ensure there are no schedule reboots in crontab. If there is any then comment it before you proceed with the change.

41.    Look for the log messages carefully; donot ignore warnings.

42.    Perform preview(TL/SP upgrade) before you perform actual change; see if there are any errors reported in preview(look for keyword ‘error’ / ‘fail’); look for the tail/summary of messages;

43.    Though the preview may report as ‘ok’ at the header, still you have to look in the messages and read the tail/summary of preview.

44.    If preview reports any dependency/requisite fileset missing then have those downloaded as well.

45.    Ensure you have enough free space in rootvg. Min of 1-2 GB to be free in rootvg(TL upgrade/OS migration).

46.    Ensure application team have tested their application on the new TL/SP/OS to which you are upgrading your system.

47.    If you have multiple putty sessions opened; then name the sessions accordingly [Putty -> under behaviour -> window title]; this will help you in quickly getting to the right session.

48.    On sev1 issues, update the SDM in the ST multichat at regular intervals.

49.    Over the conf voice call, if they verbally request you to perform any change, get the confirmation in writing in the multi ST chat.

50.    Update the PR in regular intervals.

51.    Update your team with the issue status(via mail).

52.    Document any new learnings(from issues/changes) and share it with team.

53.    Ensure proper validated CR procedure is in place;  Precheck -> Installation -> Backout -> Verification

54.    Save the severity multichats; enable autologging of multichats in Sametime.

55.    If the junior SA resource is performing the change for first time(first time in any account); then let the techlead club him with a senior SA.

56.    SAs First time execution (or first time in an account) or to say any first time had to be dealt carefully. Techleads have to take extra precautions.

57.    Any important information/document, please ensure that you update it in your account teamroom.

58.    Ensure for TL upgrades, you go by TL by TL, shortcut to direct TL could sometimes cause problem.

59.    Check if the server is running any cluster (HACMP), if so then you have to follow different procedure.


Thumb Rules for HACMP


1) Check the status of cluster “clstat -o;clRGinfo”, the cluster & the resource groups should be in stable state. Cluster commands/utilities directory –
‘/usr/es/sbin/cluster/utilities’.  “lssrc -a|grep -i clst”: to check if the cluster is running.   “lssrc -ls clstrmgr”

2) Use ‘clshowres’ to check the resource group configuration; with this info you can identify the volume group, serviceip, application server(appln.
start/stop scripts) associated with the resource group.

3) When you bring the RG(Resource Group) offline, after the RG is offline, verify the associated resources(service ip, vg, application) are down/offline as
well.

4) Use ‘cllsserv’ to find out the application start/stop scripts. Ensure the appln. start/stop scripts are in sync across nodes[you can use ‘cksum’ and verify].

5) Generate cluster snap; collect cluster information,
###############################
/usr/es/sbin/cluster/utilities/clsnapshot -c -i -n filename                                       /* generates 
filename.info in the
/usr/es/sbin/cluster/snapshots/’ directory.
/usr/es/sbin/cluster/clstat -o >> /usr/es/sbin/cluster/snapshots/
filename.info     /* clstat displays current status of cluster; clstat may not work on some clusters.
/usr/es/sbin/cluster/utilities/clRGinfo >> /usr/es/sbin/cluster/snapshots/
filename.info     /* displays the current status of resource groups.
/usr/es/sbin/cluster/utilities/cllsserv >> /usr/es/sbin/cluster/snapshots/
filename.info     /* shows the start & stop scripts of the application server.
###############################

6) Collect system information of cluster nodes. The system information will contain the ip/static route information and
other important information.

7) Cluster verification is run on daily basis; look for the ‘fail’ or ‘error’ keyword in the ‘/var/hacmp/clverify/clverify.log
8) Perform emulate(preview) “verification & synchronization” [smitty hacmp -> Extended Configuration -> Extended Verification and Synchronization-> select
emulate] and see if there are any errors.

9) If any errors reported, especially if it is the VG/lvm out of sync issue, then take downtime(resource groups down)(highly recommended), and then perform
actual sychronization(fixing of sync errors).
[Please note that it is not advised to perform actual sychronization with RG(resource group) being UP; because this could result in the disk lock issue and
could disrupt the future failover].

10) It is recommended that we donot perform direct ‘move’ operation of resource groups; instead perform offline of RG on one node, ensure all the associated
resources are offline, and then perform online of RG on other node. This will ensure that there are no resource conflict and there is clean movement of RG.

11) To monitor the RG online/offline/move:  “tail -f /tmp/hacmp.out

12) All the possible activities(VG/LVM/FS) to be performed via CSPOC(Cluster-single point of control).   smitty hacmp -> C-SPOC. Before you perform any C-SPOC activity ensure you do
synchronization(emulation) to see if there any errors. If there are any errors then first fix the errors(with RGs offline), and then proceed with C-SPOC.

13) HACMP logs: ‘/tmp/hacmp.out’  ‘/usr/es/adm/cluster.log’  ‘/var/hacmp/clverify/clverify.log

14) In case if you have performed the fs change outside C-SPOC, donot panic, we can synch it to other nodes(with RGs offline). In case if the customer
insists to do it online itself then there is procedure to do that as well. (1)

15) At some occasions: after the RG failover, serviceip may not ping/work; this could be due to arp cache, flush the serviceip entry in the arp cache on both nodes.
If the ip issue persists, then engage network team, they may have to refresh at switch level.

16) During the offline process if the RG status reports as ‘error’, then in majority of the cases it would be the filesystem unmount issue; HA maybe unable to unmount  filesystem of the RG(filesystem in use by other process), thus it reports error for the RG.  Stop the process/application using the filesystem, then unmount the filesystem and rerun RG offline.

17) During HACMP activities, clearly inform the application team that the ‘RG(Resource Group)’ online/startup does start the application(execute application start script automatically), and that they may need to just verify application. This precaution is because many of the application team members are unaware of HACMP/cluster functionality, due to which they may attempt to restart their application, which could harm their application.

18) In certain cases, where the HACMP is in unstable state, you may not be able to bring the RG offline gracefully, the turnaround is to execute the application stop script(‘cllsserv’), which will stop the application gracefully and then reboot the cluster node [this will ensure that the application is not corrupted due to abrupt shutdown].

19) Remember Resouce Group(RG) primarily consists of volume group, serviceip, application server(appln. start/stop scripts) resources.

20) Incase if the cluster is not functioning, and the application team demands their application to be UP asap, then in that adverse scenario, you can manually bring the resources online..that is activate vg, mount filesystems, activate serviceip, execute application start script [this shall bring UP their application(outside hacmp)].

21) If there are 2 or multiple resource groups in HACMP cluster, then verify the naming of mountpoints/filesystems of the volume groups of resource groups; the mountpoints/fsname/lvname should be unique across volume groups of RGs. It should not overlap.

22) You can recycle logs by ” clcycle hacmp.out and clcycle cluster.log”  before doing any major HACMP/AIX changes in cluster. This will give an exact error log to begin with. Clcycle will take backup of both log files and will name it as cluster.log.1 and hacmp.out.1 & so on.


23) The shared volume groups in HACMP cluster where nodes are VIO clients(using VIO disks), have to be in “Enhanced Concurrent mode(active/pasive)” to avoid the possibility of filesystems/data corruption.

Monday, 25 September 2017

Linux Interview Question & Answer part-4


41) Command to check last runlevel

Ans who -r

42) What do you mean by File System?

Ans 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.

43) What is the requirement of udev daemon?

Ans Create and remove device nodes or files in /dev/ directory

44) What are block and character devices?

Ans Both the devices are present in /dev directory

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....)


Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers (tty{0,1,2,3......})

45) How to Convert ext2 to ext3 File System?

Ans tune2fs -j /dev/{device-name}

46) File required to modify for setting up kernel parameters permanent

Ans /etc/sysctl.conf

47) Commands used to install, list and remove modules from kernel 

Ans Installing/adding a module: 
                                                    insmod mod_name
                                                    modprobe mod_name

        List installed modules :  lsmod
        Removing a module     : modprobe -r mod_name

48) How to create swap using a file and delete swap

Ans Adding swap :

dd if=/dev/zero of=/opt/myswap bs=1024 count=4

mkswap /opt/myswap

swapon -a

For adding this myswap at boot time, add following in /etc/fstab file:

/opt/myswap       swap     swap   defaults   0 0


Deleting Swap :

Run "swapoff /opt/myswap" command
Remove the entry from /etc/fstab file
Remove /opt/myswap file (using rm command)

49) What vmstat show

Ans 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



50) What is tmpfs File System

Ans 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.

51) What is the difference between screen and script commands?

Ans 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

Screen : needs to be detached, should not be exited to access remotely/locally
Script : creates a file and store all the terminal output to this file

52) How can we check which process is assigned to which processor?

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?

Ans) rpm -qi package-name , for example:

         rpm -qi ypbind-1.19-12.el5

Linux Interview Question & Answer part-1


1)  What is GRUB

Ans GNU GRUB is a Multiboot boot loader. It was derived 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)

2) Explain Linux Boot Process

Ans. Plz read our next blog to read boot process.

3) Which files are called for user profile by default when a user gets login

Ans $HOME/.bash_profile, $HOME/.bash_bashrc

4) Which file needs to update if srequired to change default runlevel 5 to 3

Ans File is /etc/inittab and required to change below lines:

id:5:initdefault: to id:3:initdefault:

5) What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc..

Ans FINGER command can be used i.g; finger username


6) What is inode number

Ans 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

iNode number also called as index number, it consists following attributes:

File type (executable, block special etc)
Permissions (read, write etc)
Owner
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)
File deletion time
Number of links (soft/hard)
Extended attribute such as append only or no one can delete file including root user
(immutability)
Access Control List (ACLs)

Following command will be used to show inodes of file and folders:

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

find . -inum inode_number -exec rm -i {} \;

7) How can we increase disk read performance in single command

Ans blockdev command

This is sample output - yours may be different.
# Before test
$ blockdev --getra /dev/sdb
256
$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2549+1 records in
2549+1 records out
668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s

real 0m6.845s
user 0m0.004s
sys 0m0.865s

# After test
$ blockdev --setra 1024 /dev/sdb

$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2435+1 records in
2435+1 records out
638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s

real 0m0.370s
user 0m0.001s
sys 0m0.370s

8) .... command to change user password expiration time

Ans CHAGE

9) Command used to lock user password

Ans usermod -L username

10) How many default number of Shells available and what are their names?

Ans SH, BASH, CSH, TCSH, NOLOGIN, KSH

11) Which file defines the attributes like UID, PASSWORD expiry, HOME Dir create or not while 
adding user

Ans /etc/login.defs

12) ...... command used for changing authentication of linux system to LDAP/NIS/SMB/KERBOS

Ans authconfig

13) ...... command used for changing the attributes of any file

Ans chattr

14) What is the path of network (ethX) configuration files

Ans /etc/sysconfig/network-scripts/ethX

15) How can we change speed and make full duplex settings for eth0

Ans We can do this with below given 2 methods:

ethtool -s eth0 speed 100 duplex full
ethtool -s eth0 speed 10 duplex half

OR

mii-tool -F 100baseTx-HD
mii-tool -F 10baseT-HD

16) File which stores the DNS configuration

Ans /etc/resolve.conf

17) Main configuration file and command used for NFS enabling exported directories and deamons

Ans /etc/exports and exportfs -av , deamons are quotad, portmapper, mountd, nfsd and nlockmgr/status

18) What is command to check ports running/used over local machine

Ans netstat -antp

19) What is the command to check open ports at remote machine

Ans nmap

20) What is the difference between soft and hard links

Ans Soft Links => 1) Soft link files will have different inode numbers then source file
2) If original file deleted then soft link file be of no use
3) Soft links are not updated
4) Can create links between directories
5) Can cross file system boundaries

Hard Links => 1) Hard links will have the same inode number as source file
2) Hard links can not link directories
3) Can not cross file system boundaries
4) Hard links always refers to the source, even if moved or removed

Linux Interview Question & Answer part-2


1) What is Linux and why is it so popular?
Linux is an operating system based on UNIX, and was first introduced by Linus Torvalds commonly used in servers.It is based on the Linux Kernel, and can run on different hardware platforms manufactured by Intel, MIPS, HP, IBM, SPARC and Motorola. Another popular element in Linux is its mascot, a penguin figure named Tux.

Popularity of Linux is because of the following reasons

It is free and open source. We can download Linux for free and customize it as per our needs.
It is very robust and adaptable.
Immense amount of libraries and utilities

2) 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.

3) 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.

4) What is Linux Kernel?
The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction.

5) 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.

6) 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.

7) 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.

8 ) 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.

9) 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.

10) 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.

11) 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.

12) 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.

13) 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.

14) 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.

15) 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.

16) 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.

17) 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.

18) 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.

19) 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.

20) 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.

21) 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.

22) How do you change permissions under Linux?
Assuming you are the system administrator or the owner of a file or directory, you can grant permission using the chmod command. Use + symbol to add permission or – symbol to deny permission, along with any of the following letters: u (user), g (group), o (others), a (all), r (read), w (write) and x (execute). For example the command chmod go+rw FILE1.TXT grants read and write access to the file FILE1.TXT, which is assigned to groups and others.

23) In Linux, what names are assigned to the different serial ports?
Serial ports are identified as /dev/ttyS0 to /dev/ttyS7. These are the equivalent names of COM1 to COM8 in Windows.

24) How do you access partitions under Linux?
Linux assigns numbers at the end of the drive identifier. For example, if the first IDE hard drive had three primary partitions, they would be named/numbered, /dev/hda1, /dev/hda2 and /dev/hda3.

25) What are hard links?
Hard links point directly to the physical file on disk, and not on the path name. This means that if you rename or move the original file, the link will not break, since the link is for the file itself, not the path where the file is located.

26) What is the maximum length for a filename under Linux?
Any filename can have a maximum of 255 characters. This limit does not include the path name, so therefore the entire pathname and filename could well exceed 255 characters.

27) What are the filenames that are preceded by a dot?
In general, filenames that are preceded by a dot are hidden files. These files can be configuration files that hold important data or setup info. Setting these files as hidden makes it less likely to be accidentally deleted.

28) Explain virtual desktop.
This serves as an alternative to minimizing and maximizing different windows on the current desktop. Using virtual desktops, each desktop is a clean slate where you can open one or more programs. Rather than minimizing/restoring all those programs as needed, you can simply shuffle between virtual desktops with programs intact in each one.

29) How do you share a program across different virtual desktops under Linux?
To share a program across different virtual desktops, in the upper left-hand corner of a program window look for an icon that looks like a pushpin. Pressing this button will “pin” that application in place, making it appear in all virtual desktops, in the same position onscreen.

30) What does a nameless (empty) directory represent?
This empty directory name serves as the nameless base of the Linux file system. This serves as an attachment for all other directories, files, drives and devices.

31) What is the pwd command?
The pwd command is short for print working directory command. It’s counterpart in DOS is the cd command, and is used to display the current location in the directory tree.

32) What are daemons?
Daemons are services that provide several functions that may not be available under the base operating system. Its main task is to listen for service request and at the same time to act on these requests. After the service is done, it is then disconnected and waits for further requests.

33) How do you switch from one desktop environment to another, such as switching from KDE to Gnome?
Assuming you have these two environments installed, just log out from the graphical interface. Then at the Log in screen, type your login ID and password and choose which session type you wish to load. This choice will remain your default until you change it to something else.

34) What are the kinds of permissions under Linux?
There are 3 kinds of permissions under Linux:
- Read: users may read the files or list the directory
- Write: users may write to the file of new files to the directory
- Execute: users may run the file or lookup a specific file within a directory

35) How does case sensitivity affect the way you use commands?
When we talk about case sensitivity, commands are considered identical only if every character is encoded as is, including lowercase and uppercase letters. This means that CD, cd and Cd are three different commands. Entering a command using uppercase letters, where it should be in lowercase, will produce different outputs.

36) What are environmental variables?
Environmental variables are global settings that control the shell’s function as well as that of other Linux programs. Another common term for environmental variables is global shell variables.

37) What are the different modes when using vi editor?
There are 3 modes under vi:
- Command mode – this is the mode where you start in
- Edit mode – this is the mode that allows you to do text editing
- Ex mode – this is the mode wherein you interact with vi with instructions to process a file

38) Is it possible to use shortcut for a long pathname?
Yes, there is. A feature known as filename expansion allows you do this using the TAB key. For example, if you have a path named /home/iceman/assignments directory, you would type as follows: /ho[tab]/ice[tab]/assi[tab] . This, however, assumes that the path is unique, and that the shell you’re using supports this feature.

39) What is redirection?
Redirection is the process of directing data from one output to another. It can also be used to direct an output as an input to another process.

40) What is grep command?
grep a search command that makes use of pattern-based searching. It makes use of options and parameters that is specified along the command line and applies this pattern into searching the required file output.

41) What could possibly be the problem when a command that was issued gave a different result from the last time it was used?
One highly possible reason for getting different results from what seems to be the same command has something to do with case sensitivity issues. Since Linux is case sensitive, a command that was previously used might have been entered in a different format from the present one. For example, to lists all files in the directory, you should type the command ls, and not LS. Typing LS would either result in an error message if there is no program by that exact name exist, or may produce a different output if there is a program named LS that performs another function.

42) What are the contents in /usr/local?
It contains locally installed files. This directory actually matters in environments where files are stored on the network. Specifically, locally-installed files go to /usr/local/bin, /usr/local/lib, etc.). Another application of this directory is that it is used for software packages installed from source, or software not officially shipped with the distribution.

43) How do you terminate an ongoing process?
Every process in the system is identified by a unique process id or pid. Use the kill command followed by the pid in order to terminate that process. To terminate all process at once, use kill 0.

44) How do you insert comments in the command line prompt?
Comments are created by typing the # symbol before the actual comment text. This tells the shell to completely ignore what follows. For example: “# This is just a comment that the shell will ignore.”

45) What is command grouping and how does it work?
You can use parentheses to group commands. For example, if you want to send the current date and time along with the contents of a file named OUTPUT to a second file named MYDATES, you can apply command grouping as follows: (date cat OUTPUT) > MYDATES

46) How do you execute more than one command or program from a single command line entry?
You can combine several commands by separating each command or program using a semicolon symbol. For example, you can issue such a series of commands in a single entry:
ls –l cd .. ls –a MYWORK
which is equivalent to 3 commands:
ls -l
cd..
ls -a MYWORK
**Note that this will be executed one after the other, in the order specified.

47) Write a command that will look for files with an extension “c”, and has the occurrence of the string “apple” in it.
Answer: Find ./ -name “*.c” | xargs grep –i “apple”

48) Write a command that will display all .txt files, including its individual permission.
Answer: ls -a -l *.txt

49) Write a command that will do the following:
-look for all files in the current and subsequent directories with an extension c,v
-strip the,v from the result (you can use sed command)
-use the result and use a grep command to search for all occurrences of the word ORANGE in the files.
Find ./ -name “*.c,v” | sed ‘s/,v//g’ | xargs grep “ORANGE”

50) What, if anything, is wrong with each of the following commands?
a) ls -l-s
b) cat file1, file2
c) ls – s Factdir
Answers:
a) there should be space between the 2 options: ls -l -s
b) do not use commas to separate arguments: cat file1 file2
c) there should be no space between hyphen and option label: ls –s Factdir

Linux Interview Question & Answer part-3


21) How to setup never expired user password

Ans chage -E never username

22) Restricting insertion into file if full permission are assigned to all

Ans chattr +i filename

23) Display or Kill all processes which are accessing any folder/file

Ans Display User who are using file/folder : fuser -u file/folder
Kill All Processes which are using file/folder: fuser -k file/folder

24) Kill any user's all processes

Ans killall -u username

25) How can we have system analysis and reports over mail

Ans Use logwatch

26) What we have to do if we do required to rotate logs without moving and creating new log file

Ans 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

Ans dmidecode , sysreport

28) Command to check PCI devices vendor or version

Ans lspci

29) What is the difference between cron and anacron

Ans  Cron :
                     1) Minimum granularity is minute (i.e Jobs can be scheduled to be executed
                         every minute)
                     2) Cron job can be scheduled by any normal user ( if not restricted by super
                          user )
                     3) Cron expects system to be running 24 x 7. If a job is scheduled, and
                         system is down during that time, job is not executed
                     4) Ideal for servers
                     5) Use cron when a job has to be executed at a particular hour and minute

      Anacron :
                     1) Minimum granularity is only in days
                     2) Anacron can be used only by super user ( but there are workarounds to
                         make it usable by normal user )
                     3) Anacron doesn’t expect system to be running 24 x 7. If a job is scheduled,
                         and system is down during that time, it start the jobs when the system
                         comes back up.
                     4) Ideal for desktops and laptops
                     5) Use anacron when a job has to be executed irrespective of hour and
                          minute

30)  Default Port numbers used by ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps

Ans 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
        2) Copy FILE1 ACLs to FILE2 ACL
        3) Delete a USER1's rule for FILE1 which were setup in step 1)

Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1
        2) getfacl FILE1 | setfacl --set-file=- FILE2
        3) setfacl -x u:USER1 FILE1

32)  How to make USB bootable?

Ans Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB

dd if=efidisk.img of=/dev/usb (usb device name)

33)  How can we check disk/device status/failure/errors using smartctl utility?

Ans Try following to check:

        Enable/Disable SMART on device/disk : smartctl -s on /dev/sda
        Check device SMART health : smartctl -H /dev/sda
        Check device SMART capabilities : smartctl -c /dev/sda
        Enable/Disable automatic offline testing on device : smartctl -o on/off /dev/sda
        Show device SMART vendor-specific Attributes and values : smartctl -A /dev/sda
        Show device log [TYPE : error, selftest, selective, directory,background, 
                                     scttemp[sts,hist]] : smartctl -l TYPE /dev/sda
        Run test on device [TEST: offline short long conveyance select,M-N pending,N 
                                     afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda

34)  What is the difference between ext2 vs ext3 vs ext4?

Ans - dear friends read our next blog to get diffrences.

35)  Disable ping to avoid network/ICMP flood

Ans Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1

      Then "sysctl -p"
  
      or 
   
   echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

36)  What is SYN Flood, ICMP Flood

Ans 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 
          server to spawn a half-open connection, by sending back a TCP/SYN-ACK packet(Acknowledge), and 
          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 
          legitimate requests until after the attack ends

      ICMP Flood : There are three types of ICMP Flood :
    
       1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack
       2) Ping Flood :  http://en.wikipedia.org/wiki/Ping_flood
       3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death

37)  What is the difference between Unix vs Linux Kernels?

Ans- wait for new update blog.

38) How to setup Password less remote login/ssh?

Ans Use "ssh-keygen -t dsa or rsa" at local system for creating public and private keys

        Then copy /root/.ssh/id_dsa.pub to remote_server by name /root/.ssh/authorized_keys
        Change permissions of /root/.ssh/authorized_keys file at remote_server "chmod 0600 ~/.ssh/authorized_keys"

        Now try to login from local system to remote_server "ssh root@remote_server"

39) Command to see default kernel image file

Ans "grubby --default-kernel"

40) How to create lvm mirror

Ans lvcreate -L 50G -m1 -n LVMmirror vg0