17 Linux Interview Questions and Answers Related Articles
17 Linux Interview Questions and Answers Related Articles
Related Articles
100 Linux Commands Video Tutorial
ps command in detailed
ps command Linux
To see every process on the system using standard syntax
[root@ArkITShell ~]# ps -e
[root@ArkITShell ~]# ps -ef
[root@ArkITShell ~]# ps ax
Security info
[root@ArkITShell ~]# ps -eo euser,ruser,suser,fuser,f,comm,label
To see every process running as root (real & effective ID) in user format:
Related Articles
analyze Linux system performance
20 ssh interview questions and answers
Linux directory structure changed in RHEL7 – FHS file hierarchy standard
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
Q8: Is it possible to Login to remote SSH server without password.?
Ans: Yes, we can do by setting up Key based authentication (password less
authentication setup)
AddressFamily 192.168.4.0/24
Q11: How to restrict SSH server to use only protocol version 2 Or 1..?
Edit default configuration file and un-comment below shown line and restart
service
#Protocol 2
Q12: What do you mean by SSH cipher.? Tell me different types of ciphers..?
Cipher is an algorithm to perform encryption and decryption.
Types of cipher supported by SSH are
1. 3des
2. blowfish
3. des
Q13: How do you access GUI using SSH connection ..?
SSH will also support of transferring X11 forwarding, we have to use options calle
-XY to open server GUI app from client.
Q14: What the best procedure to troubleshoot SSH connection error .?
To Enable Debugging in ssh command use -v option which gives more appropriate
and deep analysis. Secure Shell Linux Interview Questions
Q15: How to Check ssh version .?
ssh -6 [email protected]
If you’ve forgotten to enter some critical data or misconfigured things, Nagios will
spit out a warning or error message that should point you to the location of the
problem. Error messages generally print out the line in the configuration file that
seems to be the source of the problem. On errors, Nagios will often exit the pre-flight
check and return to the command prompt after printing only the first error that it has
encountered.
NagiosXI includes lot of features which we can modify using web interface. Nagios
Core default not include all the features we have to implement by installing plugins.
A.Soft States:
When a service or host check results in a non-OK or non-UP state and the service
check has not yet been (re)checked the number of times specified by the
max_check_attempts directive in the service or host definition. This is called a soft
error.
When a service or host recovers from a soft error. This is considered a soft recovery.
The following things occur when hosts or services experience SOFT state changes:
The SOFT state is logged. Event handlers are executed to handle the SOFT state.
SOFT states are only logged if you enabled the log_service_retries or log_host_retries
options in your main configuration file.
The only important thing that really happens during a soft state is the execution of
event handlers. Using event handlers can be particularly useful if you want to try and
proactively fix a problem before it turns into a HARD state. The
$HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of
“SOFT” when event handlers are executed, which allows your event handler scripts to
know when they should take corrective action.
B.Hard states :
occur for hosts and services in the following situations:
When a host or service check results in a non-UP or non-OK state and it has
been (re)checked the number of times specified by the max_check_attempts
option in the host or service definition. This is a hard error state.
When a host or service transitions from one hard error state to another error
state (e.g. WARNING to CRITICAL).
When a service check results in a non-OK state and its corresponding host is
either DOWN or UNREACHABLE.
When a host or service recovers from a hard error state. This is considered to be
a hard recovery.
When a passive host check is received. Passive host checks are treated as
HARD unless the passive_host_checks_are_soft option is enabled.
The following things occur when hosts or services experience HARD state changes:
The HARD state is logged.
Event handlers are executed to handle the HARD state.
Contacts are notifified of the host or service problem or recovery.
The $HOSTSTATETYPE$ or $SERVICESTATETYPE$ macros will have a value of
“HARD” when event handlers are executed, which allows your event handler scripts
to know when they should take corrective action.
1. Storing the results of the last 21 checks of the host or ser vice
2. Analyzing the historical check results and determine where state
changes/transitions occur
3. Using the state transitions to determine a percent state change value (a measure
of change) for the host or service
4. Comparing the percent state change value against low and high flapping
thresholds
5. A host or service is determined to have started flapping when its percent state
change first exceeds a high flapping threshold.
6. A host or service is determined to have stopped flapping when its percent state
goes below a low flapping threshold (assuming that is was previously flapping).
7. The historical service check results are examined to determine where state
changes/transitions occur. State changes occur when an archived state is different
from the archived state that immediately precedes it chronologically. Since we
keep the results of the last 21 service checks in the array, there is a possibility of
having at most 20 state changes. In this example there are 7 state changes,
indicated by blue arrows in the image above.
The flap detection logic uses the state changes to determine an overall percent state
change for the service. This is a measure of volatility/change for the service. Services
that never change state will have a 0% state change value, while services that change
state each time they’re checked will have 100% state change. Most services will have
a percent state change somewhere in between.
find command
./resolvedbugs.txt
./resolvedbugs.txt
find -name
3. Search Only files out of all
Only files i want to list out of all directories and files. We have an option -type
f to fetch only files, here f means file
/root/find/file1.txt
mention range from in between 24hours + ten minutes to 24 Hours -20 minutes
/var/spool/mail/admin
Conclusion: There are N number of examples, lot many options with find
command is available in single article can’t be fit. We try to elaborate in upcoming
posts.
Local File Systems are used to format partitions into usable without making file
system in partitions we can’t store data. Just making the partitions will turn them as
RAW. Partitions are used to organize users data on a Hard Disk.
When you make an Extended File System it will create an different types off
blocks to segregate data store
1. Master Blocks / Boot Blocks
2. Super Blocks
3. Inode Blocks
4. Data Blocks
Master Blocks / Boot Blocks : Only boot partitions contain
master blocks data. Remaining partitions master blocks are empty.
Super Blocks : Just like an index to the book and it works holds to the
information as follows
Utilized inode numbers
Free inode numbers
Utilized data blocks
Free data blocks
Inode table (index table) which holds all the information about
files/directories like permissions, owner, group name, size and time stamps.
4096 bytes default block size
15 data blocks = inode
If data size is more than 100MB block size is 4096bytes. If data size is less than
100MB block size is 1024bytes.
Data block storage of files
Below is the File System comparison in brief
File Max File Max Partition
Journal-ling Notes
System Size Size
Fat16 2 GB 2 GB No Legacy
Fat32 4 GB 8 TB No Legacy
(For Windows Compatibility) NTFS-3g
NTFS 2 TB 256 TB Yes is installed by default in Ubuntu, allowing Read/W
support
ext2 2 TB 32 TB No Legacy
Standard linux filesystem for many
ext3 2 TB 32 TB Yes
years. Best choice for super-standard installatio
Modern iteration of ext3. Best choice
ext4 16 TB 1 EB Yes for new installations where super-standard isn’
necessary
reiserFS 8 TB 16 TB Yes No longer well-maintained
Yes
JFS 4PB 32PB Created by IBM – Not well maintained
(metadata)
Yes Created by SGI. Best choice for a mix
XFS 8 EB 8 EB
(metadata) of stability and advanced journaling
GB= Gigabyte (1024 MB) TB = Terabyte (1024 GB) PB = Petabyte (1024 TB) EB = Exabyte (1024 PB)
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
WARNING: Re-reading the partition table failed with error 16: Device or resource
busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
by default when you create an extended partition it will not update kernel to update
kernel we have to execute below command
# partprobe /dev/sdc
Mount partition
Partition has been formatted with EXT4, to mount it permanently we have to add
an entry in /etc/fstab file.
#
# /etc/fstab
# Created by anaconda on Wed Jun 22 11:14:58 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=5b0f4ed0-592e-4114-9a8e-10a7b99d2cd3 /boot xfs
defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/sdc1 /data ext4 defaults 0 0
[root@Techtutorials ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 3.3G 15G 19% /
devtmpfs 1.2G 0 1.2G 0% /dev
tmpfs 1.2G 80K 1.2G 1% /dev/shm
tmpfs 1.2G 8.9M 1.2G 1% /run
tmpfs 1.2G 0 1.2G 0% /sys/fs/cgroup
/dev/sda1 497M 124M 373M 25% /boot
Conclusion
Standard partition can be created using fdisk utility. Standard Linux File system
can’t be increased/decreased which is not flexible for production environment.
20 Good Linux Interview Questions
and Answers
BY ARK · PUBLISHED SEPTEMBER 1, 2016 · UPDATED SEPTEMBER 2, 2016
In this article we are going to see Interview questions and answers, which are
asked in one of the company interview. Exclusive Interview questions and answers
for you. 20 Good Linux interview questions and answers.
3. What are the default ports used for SMTP,DNS,FTP,DHCP, SSH and
HTTP.?
Ans:
SMTP = 25
DNS = 53
FTP = 20 and 21
DHCP = 67 and 68
SSH = 22
HTTP = 80 and HTTPS = 443
4. How to check which ports are listening in my Linux Server.?
Ans: Using nmap, netstat and lsof commands we can check which are
the ports listening in local host
Command Examples:
# ss -tunlap
# netstat -anp
# crontab -e
* * * * * cat /etc/passwd; ls -l /etc/ >> /tmp/etcfiles
9. Write a command that will look for files with an extension “c”, the string “apple” in
it.?
Ans:
# cat /etc/passwd
Related Articles
Nagios Admin interview Questions and Answers
Few More Interview Questions and Answers
Linux Interview Questions and
Answers
BY ANKAM RAVI KUMAR · PUBLISHED OCTOBER 11, 2015 · UPDATED OCTOBER 11, 2015
2. A technician uses the ps command to see what processes are running. When the
current running processes are shown, he notices a process that he terminated 10
minutes ago by using the kill command is still running. What command should he use
next to terminate this process?
Ans:- He should use -9 argument with kill command that will send a kill signal to the
process. This will terminate the specific process immediately.
3. A technician quickly notices a kernel error message on the screen during the boot
process. Unfortunately, the error message disappear so quickly for the technician to
read it all. What log directory can the technician use to examine boot-time messages?
Ans:- Linux system keeps almost all log files under the /var/log directory. Most of the
boot messages are kept in buffer, which can be accessed by using the dmesg
command. He can examine the /var/log/dmesg.log file. For boot time message he can
also check the /var/log/boot.log file.
4. A technician wants to view a list of all running processes on the server. How can he
do this?
Ans:- He should use the ps command with -ef argument. ps -ef command will show a
list of all running process.
6. A technician want to boot the system in CLI mode on start up. Which runlevel
should he assign and in which file ?
Ans:- He could assign runlevel 3 as the default runlevel in /etc/inittab file.
7. What program a technician can use to analyze program’s core dump files and to
debug the application while it is actually running?
Ans:- He can use gdb program to analyze program’s core dump files and also debug
the application while it is actually running.
8. As a technician you want to shutdown the Linux system. What command should
you use?
Ans:- You could use shutdown command.
9. As a technician you need to perform a scheduled shutdown that will occur in 10
minutes. What should you use to shut down the server in 10 minutes.?
Ans:- You can use -h argument with shutdown command which allows you to specify
the time in second. To shutdown the system in 10 minute you should run shutdown -h
600 command.
11. As a technician you need to restart the Apache Web Server. What command
should you use.?
Ans:- You could use following command to restart the Apache web server.
13. What line printer control command is used to control the operation of the line
printer system?
Ans:- lpc command is used with various argument to control the operations of line
printer system.
14. A technician wants to terminate an active spooling daemon on the local host
immediately and then disables printing for the specified printers. What command
should he use?
Ans:- He should use lpc command with abort options. lpc abort lpc abort terminates
an active spooling daemon on the local host immediately and then disables printing
for the specified printers,
15. What print command stops a spooling daemon after the current job completes and
disables printing?
Ans:- The lpc stop command stops a spooling daemon after the current job completes
and disables printing
16. What command allows you to directly see what jobs are currently in a printer
queue?
Ans:- The lpc command allows you to directly see what jobs are currently in a printer
queue
17. A technician wants to halt the Linux server. What command should he use ?
Ans:- He can use init 0 command to halt the Linux server.
18. What line printer command lets you remove print jobs from the printer queue?
Ans:- The lprm command will let you remove print jobs from the printer queue.
19. What is the default text editor of Linux which include almost every version of
Linux?
Ans:- Default editor of Linux is vi editor that can used to edit any ASCII text.
20. What command is used for combining a large number of files into one single file
for archival to tape?
Ans:- vi is a text editor that can be used to edit any ASCII text. It is especially useful
for editing programs.
21. Where do all your configurations for your services, programs, and daemons reside
by default?
By default, all configurations for your services, programs, and daemons reside in
the /etc directory.
22. What type of backup tape will only back up files that have changed since the
previous backup and clear the archive bit?
Ans:- An Incremental backup will backup only files that have changed since the
previous backup and clear the archive bit.
23. Which argument is used with tar command to create a new archive file?
-c argument is used to create new archive file.
24. Which argument is used with tar command to extract the files from archive ?
Ans:- -x argument is used with tar command to extract the files form archive.
26. A technician is going to install Linux on a workstation. The technician wants to
customize the installation. What type of installation will the technician use to
customize the installation?
Ans:- Only a custom installation can be used to customize what is installed during an
installation. A custom installation will allow you to choose what packages you want to
install and what packages you don’t want to install.
28. Which program is mostly used for remote login securely in Linux?
Ans:- SSH is used for secure login. SSH is the replacement of old unsecure services
like telnet.
29. What file contains a list of user names that is not allowed to log in to the FTP
server?
Ans:- The ftpusers file contains a list of usernames that a Linux administrator has
previously set to not allow specific users to login to the FTP server. ftpusers file is
located in /etc/vsftpd directory.
31. In which directory Linux store crontab files for particular users?
Ans:- The /var/spool/cron is the directory where user’s crontabs are saved with a
directory for each user in which all user’s cron jobs are stored.
34. A technician wants to assign IP addresses to all the systems that will connect to
the server automatically. What type of server he should set up?
Ans:- He should set up DHCP Server which assigns IP address to client automatically
on start up.
35. A technician wants to add a new user to the current domain. What command will
the technician use to accomplish this?
Ans:- He should use useradd command followed by the username will create a new
user or update default new user information. You need to specify the password
separately with the passwd command.
36. What option a technician can use with usermod command to unlock to user’s
password?
Ans:- The -U option is used with usermod command to unlock the user’s password.
37. What option of the mkfs command should you use to check the device for bad
blocks before building the file system?
Ans:- The –c option when used with the mkfs command will check the device for bad
blocks before building the file system.
38. What at command argument will send mail to the user when the job has
completed, even if there was no output?
Ans:- -m argument with at command will send mail to the users when the job has
completed even if there was no output.
39. A user wants to verify the current active shell. Which command will he use?
Ans:- He should use the env command to verify the current active shell
40. What command can a technician use to search for a specific file?
Ans:- He can use either find or locate command to search for a specific file.
41. How can you send the output of a file to another file?
Ans:- The > option is used to send the output of a file to another file.
43. Which utility should you use to display the CPU processes?
Ans:- top utility lets you see all on one screen how much memory and CPU usage that
you are currently using, and also the resource usage by each program and process.
44. What command can you use to obtain information about your serial port resource
usage, such as IRQ and IO addresses?
setserial is a utility that you can use to obtain information about serial port resource
usage, such as IRQ and IO addresses.
45. A technician wants to delete the a user account. Which command should he use?
Ans:- The userdel command is used to delete a user from the system.
47. A user wants to copy a file from the /tmp directory to the his home directory.
Which command would he use?
Ans:- He can use cp command to copy the files from one directory other directory.
52. A technician is having problems connecting to a mail server. What command can
he use to test if the mail server is on the network?
Ans:- He can use ping command to test connectivity between local system and remote
server
success
success
Default port of squid proxy is 3128 that’s why we have to allow port 3128.
# cat /etc/squid/badsites
.facebook.com
.twitter.com
.youtube.com
.linkedin
.msn.com
.myspace.com
.flickr.com
.google
# cat /etc/squid/blockfiles.acl
\.torrent$
\.mp3.*$
\.mp4.*$
\.3gp.*$
\.[Aa][Vv][Ii]$
\.[Mm][Pp][Gg]$
\.[Mm][Pp][Ee][Gg]$
\.[Mm][Pp]3$
\.[Ff][Ll][Vv].*$
Time based access, which deny internet access from morning 10 Hours to 19
Hours
Go to Client Side
Change the proxy address in your browser then try to access the website
IE Settings > Internet options > Connections > Lan Settings >
provide IP address and port number
Now see the logs watch the squid logs
/var/log/squid/ log file directory
The logs are a valuable source of information about Squid workloads and
performance. The logs record not only access information, but also system
configuration errors and resource consumption (eg, memory, disk space). There are
several log file maintained by Squid. Some have to be explicitly activated during
compile time, others can safely be deactivated during.
/var/log/squid/access.log : Most log file analysis program are based on the
entries in access.log. You can use this file to find out who is using squid server
and what they are doing etc
/var/log/squid/cache.log : The cache.log file contains the debug and error
messages that Squid generates. If you start your Squid using the default
RunCache script, or start it with the -s command line option, a copy of certain
messages will go into your syslog facilities. It is a matter of personal
preferences to use a separate file for the squid log data.
/var/log/squid/store.log : The store.log file covers the objects currently kept
on disk or removed ones. As a kind of transaction log it is ususally used for
debugging purposes. A definitive statement, whether an object resides on your
disks is only possible after analysing the complete log file. The release
(deletion) of an object may be logged at a later time than the swap out (save to
disk).
HOW DO I VIEW SQUID LOG FILES /
LOGS?
You can use standard UNIX / Linux command such as grep / tail to view log files.
You must login as root or sudo command to view log files.
Display log files in real time
Use tail command as follows:
OR
Related Articles
Installation and configuration of FTP server in RHEL7
Collect system information using shell script in second
Time server installation and configuration
Audit Linux Machine Extremely helpfull
Network File system shares configuration NFS
Maria DB installation alternate to MySQL
Firewalld Installation and Configuration RHEL7
Analyse server performance RHEL7
Search Strings
squid proxy server installation and configuration
squid proxy in rhel7
restricted internet access using proxy
control internet download speed
URL Filtering using Linux proxy server