Linux Commands Interview Preparation Guide
Download PDF

Linux Commands job interview questions and answers guideline. Lean Linux Commands and get preparation for the job of Linux Commands

23 Linux Commands Questions and Answers:

1 :: Explain difference between nfs soft and hard mouniting points?

hard mount option:- If the client fails to access the
server,then connection hang it, after the system up then it
access the server.

Soft:- If the client failed to connect the server it
immediately gives the error report, and close the connection.

2 :: If we transfer 100 files by ftp to remote server, how to know the files are successfully transfer or some file are not transferred?

after transferring the files look into the present working
directory of the client machine for the transferred files
and cross check it.


else you can check the total number of files transferred to
the client machine in present working directory using this
command


ls -l | wc -l

3 :: Explain any one service which are working on UDP
only?

BOOTPS (67port number)
BOOTPC(68 port number)

belongs to DHCP

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

403 represent forbidden error, means if files misses some
selinux security context is missing.

404 represent that their is a cgi script missing or web
pages missing.

6 :: How to monitor ports in a linux machine, with single command?

nmap is not the default available command.we can use netstat
netstat -nl, netstat -nltp ,netstat -nulp

7 :: Explain Difference between swap partition and swap file?

Swap partition maintained seperate partition.
same swap partition can be used in two OS within single
machine.
If system crashes their is a chance to recover itor may not
be corrupt the partition.
Less fragmented.

where as swap file takes very less space. we can increase
the space very easily, compared to swap partition.
SWap file system fragmented.
If system crashes their is a huge chance to lost the swap
file system.

8 :: How to recover /etc/passwd file and /etc/shadow file?

## In that case you need to recover /etc/passwd file first.
For this you have to following steps,

-Start GRUB on boot (press ESC while booting)
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type: "cp /etc/passwd- /etc/passwd"
-reboot to GRUB again
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type "mount -o remount,rw /"
-Type "passwd YOURUSERNAMEHERE" (IF you don't know your user
name type "ls /home" (that is a Lower case L and lower case
S) for a list of users)
-Enter new password at prompt
-reboot to normal boot.

Hope that helps others like it did me!

### Then to recover /etc/shadow file, Use following command
pwconf

This command will generate /etc/shadow file from /etc/passwd

9 :: How to know linux os is 32 bit or 64 bit?

#uname -a
we get the information about os
and Regarding CPU
#grep flags /proc/cpuinfo
if cpu is in
Long mode - 64 bit CPU
Real mode 16 bit CPU
Protected Mode is 32-bit CPU

10 :: Suppose I lost a root password and i need to give it, I treid to change it through single usermode even though i am not get a password, then what is the other procedure to give a root password?

Login into single user mode and try below things:
1. passswd [ Change Password for root ]
2. rm -rf /etc/nologin
3. remove any "nologin" shell for root user in /etc/passwd file
4. chage -l root then chage -E root
5. passwd -u root
6. chattr -i /etc/passwd /etc/shadow
7. chmod 600 /etc/securetty
8. vim /etc/rc.local --> then remove any line like say "
/etc/nplogin "
9. chsh root [ /bin/bash ]