Linux Interview Questions and Answers
Prepare for your Linux job interview with this list of top Linux Interview Questions and Answers for Freshers and Experienced which is Prepared by 10+ Years Experienced Linux Experts.
Linux Interview Questions and Answers
Linux Interview Questions and answers for beginners and experts. List of frequently asked Linux Interview Questions with answers by Besant Technologies. We hope these Linux Interview Questions and answers are useful and will help you to get the best job in the networking industry. This Linux Interview Questions and answers are prepared by Linux Professionals based on MNC Companies expectation. Stay tuned we will update New Linux Interview questions with Answers Frequently. If you want to learn Practical Linux Training then please go through this Linux Training in Chennai and Linux Training in Bangalore
Best Linux Interview Questions and answers
Besant Technologies supports the students by providing Linux Interview Questions and answers for the job placements and job purposes. Linux is the leading important course in the present situation because more job openings and the high salary pay for this Linux and more related jobs. We provide Linux online training also for all students around the world through the Gangboard medium. These are top Linux Interview Questions and answers, prepared by our institute experienced trainers.
Linux Interview Questions and answers for the job placements
Here is the list of most frequently asked Linux Interview Questions and answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced Linux professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.
Linux Interview Question and Answer
Chmod change the file/directory permission
The Chown to change the ownership of a file or directory and ownership away to someone else.
Cat /etc/inittab or who –r
LVM Id: 8e
Ping remote server IP. (to check alive or not)
Make sure remote server sshd service enabled
If everything is ok, login remote server ILO, open the remote console and check the status
nmap
Setfacl –m u:username:permission filename
Getfacl username (to check the user permissions)
Netstat –anultp service name or port number
Chkconfig –level 2 off
Hard Mount : After restarting the server keep on search nfs mount partition until found the device, if the device not found server not will not boot,.
Soft mount: if device not found it will skip
Rpm: need local rpm file and dependencies
Yum: need repository (collections of rpm) local or internet
du –sh <file/dir>
/tmp
Lsof
ps aux |grep “defunct” and ps aux |grep Z to Kill: In order to kill these processes, you need to find the parent process first.
pstree –paul and find parent process id, use kill -9
rpm2cpio
Remount –o rw,remount
/et/passwd (!!)
/etc/hosts.deny à sshd: ALL except Node IP
Chage –l username
# pwunconv (It creates the users according /etc/passwd file and deletes the /etc/shadow file)
# passwd -x -1 <user login name> How to put never expiry to a user?
# passwd -x -1 <user login name>
# fuser -cu (to see who are login)
#fuser -ck <user login name>(to kill the specified user)
# chkconfig <service name> on
# nmap -p 22 <IP address of the remote host> (to see the ssh is running or not on remote system)
Nmap servername portname
Hardware error, Kernel error
Lsof |wc –l (list of open files)
If more than 65k, open /etc/sysctl.conf increase the file.mx value and execute below command
Sysctl –p
Using /etc/ssh/sshd_congig
/tmp
fsck <device or partition name>command we can check the integrity of the file system.
The before running the fsck command first unmount that partition and then run fsck command.
- Disk is full.
- Disk is failing or failed.
- File system corrupted or crashed.
- O/S is not recognizing the remote luns when scanning, …etc.,
The default run level command is /etc/inittab file in most Linux operating systems.
- May be there is no access to outside.
- May be outside is in a different network from the local.
- May be permission is denied for that system to access outside.
- If there is access, but router or modem or network switch or NIC may not be working to access the outside.
Permission check and disk space getting full
The ping command is used to determine connectivity between hosts on a network
$ ping google.com
Crontab –l –u rbtadmin
/boot/grub/grub.cong
.so
# ifconfig
There are Three types of class
- class A 1-126
- class B 128-191
- class c 192-221
:wq
# systemctl restart network
# useradd linux
# passwd linux
# su linux
# cat /etc/passwd
# groupadd my group
# cat /etc/my group
#useradd -d/root/abi abhi
The date command displays/sets the system date and time like this.
$ date
$ date –set=”8 JUN 2017 13:00:00”
It reflects the status of previous command
- If 0 – Success
- If Non-Zero – Not Success
It considers the script as a PHP script
YES
getenforce
Two ways
- echo “‘hi’”
- echo \’hi\’
It’s the average of the usage of each CPU
It can be found with 4 commands
- w
- uptime
- top
- cat /proc/loadavg
pstree -pua
ps ax –forest
This command is the task manager of linux. We could able to find load average, memory usage, swap usage, total number of processes, CPU, Memory usage of each processes in sorted format.
It is shortcut of a big command, we can do this using the command ‘ln’
Eg: ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
We can directly use the command redis-cli
All process identification is stored in this folder
- It will list all process id as folders /proc/12435
- It will show the command used by the process
- It will show the files used by the process
- Memory dump etc
Use ‘grep’ command
Eg: cat /proc/meminfo | grep MemFree
Use command
who -Hu
Find it using ‘tty’ command or who command
Fix it by adding atleast the system binary path, so that basic command
export PATH=/sbin:/usr/bin:/usr/sbin
Use command
ip a
command &
semanage user -l
Edit /etc/selinux/config anf change the enforcement to disabled and reboot the server.
fdisk, parted
Yes, use LVM
LVM is a utility for dynamically extent or shrink a volume. ext3, ext4, it is not possible.
Once the above command is executed, the new volgroup will be available to use.
Then mount to a location like
mount /dev/mapper/VolGroup/pv /mnt
4
8e
rpm -qi <package>
It gives the package in which the provided binary associated.
ntpd -q
Firewall-cmd –list-ports
(firewall-cmd –zone external –permanent –add-forward-port port=25:proto=tcp:toaddr=10.10.1.80)
It will forward the inward traffic of SMTP to the IP mentioned.
kadmin, ktadd, authconfig, kinit
- Open /etc/rsyslog.conf and add the following line.
- *.* @@IP:514
- systemctl restart rsyslog
DocumentRoot
It defines the file to be considered as index file. Eg ‘DirectoryIndex index.php index.html’ : In this it will find index.php first when the URL is accessed, if this file is not available, it will search for index.html as index page.
- Passwd is used for setting the password for a System User.
- Htpasswd is used for setting the password for Apache Web User.
- For web files, httpd_sys_content_t is used
- For NFS mount files, httpd_use_nfs
apachectl
- apachectl -t : Checks Syntax
- apachectl start/stop/restart : For handling service
Use command : httpd -D DUMP_VHOSTS
Execute command : postconf -e inet_interfaces=all
Use : alternatives –config mta (mta is mail transfer agent)
Its is Pointer Record for reverse lookup : Inorder to get hostname if IP is queried.
- named-checkzone
- named-checkconf
dig @8.8.8.8 domainname
dig -x IP-Address
Use command : mysqldump -hHOST -uUSER -pPASSWORD DB_NAME > DB_NAME.sql
mysql -hHOST -uUSER -pPASSWORD DB_NAME < DB_NAME.sql (Create DB prior using ‘create database db_name’)
Use Init command : init 6 (6 option is for reboot in Linux Runlevels)
setgid
chmod g+s /usr/bin/wall
A.Both b and c
B.Parent directory
C.Sub directory
D None of above”]
A.Both b and c
A.cd /root
B.cd ..
C.cd /boot
D.cd /”]
B.cd ..
They are
A.pushd
B.Popd
C .both
D.none
C .both
A.Touch -t 201812190820 file
B.touch -t yyyymmddhrmin file
C.touch file
D.none”]
B.touch -t yyyymmddhrmin file
A.Rm -i
B.Rm -rf
C.Rm
D.none of above”]
A.Rm -i
A.cp -p
B.cp -s
C.cp -d
D.none of above”]
A.cp -p
A.cat file reverse
B.concate file
C.tac file
D.none”]
C.tac file
A./
B./root
C./srv
D./proc”]
C./srv
A.ctrld
B.exit
C.logout
D.all of above”]
D.all of above
A.Ls – -color
B.Ugoa rwx
C.421 rwx
D.Chmod u=rwx,g+x file name.”]
A.Ls – -color
A.5
B 101
C.401
D.1001″]
B. 101
A.find /dirpath -mtime 15-20
B.find /dirpath -mtime +15 -mtime -20
C.find /dirpath |grep mtime 15-20
D.all”]
B.find /dirpath -mtime +15 -mtime -20
A.cat
B.more/less
C. head/tail
D.all”]
D.all
A.dfgp
B.hjkl
C.rpmn
D.none”]
B.hjkl
A.none
B.vimdiff
C.sdiff
D.all”]
D.all
A.-i
B. -c
C.-v
D..none of above.”]
B. -c
A.2>&1
B.2>
C. 1&2>
D.None”]
A.2>&1
Job in Monday will be”]
A.0
B.2
C.6
D.1″]
D.1
A.Setup user login environment similar as that of direct user
B.we need to use because it’s the only format to use su cmd
C.none of above
D.both a &b”]
A.Setup user login environment similar as that of direct user
A./Dev/null
B./Dev/tty
C./sbin
D./Mnt”]
B./Dev/tty
A.0
B.1-499
C.500 to 65534
D.only root user have uid’s”]
B.1-499
A.Hard link
B.Source file cannot be delated
C.Soft link
D.Destination file is independent of source file”]
A.Hard link
A.ext3
B.ext2
C.nfs
D.a&b”]
C.nfs
A.Master and superblock
B.Data and inode block
C.Both a&b
D.None
C.Both a&b
A.-d
B.-dv
C.-q
D.-ev”]
D.-ev
A .ture
B.False”]
A .ture
A .free -ram
B.free -m
C.none
D.both”]
B.free -m
A./etc/config
B./etc/sudoers
C./etc/proc
D./etc/visudo”]
B./etc/sudoers
A.Passed user
B.Passwd -x 99999 user
C.Psswwd -e user
D.None”]
B.Passwd -x 99999 user
A.scp filename user@server:/destination
B.winscp filename user@server:/destination
C.cp -v filename user@server:/destination
D.None”]
A.scp filename user@server:/destination
A.resize2fs ext
B.mkfs ext
C.pvcreate ext
D.lvcreate ext”]
B.mkfs ext
A./Var/log/messages
B./var/log/secure
C./var/log/auth.log
D./var/log/dmseg”]
C./var/log/auth.log
A.reboot
B.init 6
C.init 0
D.Both a&b”]
D.Both a&b
A./etc/config
B..ssh
C.ssh
D./etc/security”]
B..ssh
A.sed
B.pipe
C.export
D.cat”]
C.export
A.crontab
B.at cmd
C.both a and b
D.sudoers file”]
C.both a and b
A.time
B.server time
C.uptime
D.reboot time”]
C.uptime
chattr +i filename
A.Ifconfig
B.traceroute
C.netstat -m
D.all”]
D.all
A.nice
B.ps
C.renice
D.all of above”]
C.renice
A.top
B.ps
C.vmstat
D.only a b
E.all”]
E.all
A.fuser
B.vmstat
C.chroot
D.all”]
D.all
A.bootloader
B.Master boot record
C.Kernel
D.None of them.”]
B.Master boot record
A./etc/crontab
B./etc/config
C./etc/fstab
D.None”]
C./etc/fstab
A./Var/lib/
B./Var/lib/db/rpm
C./Var/rpm
D.Var/lib/rpm”]
D.Var/lib/rpm
A.sysctl kernal.host=Rakesh
B.sysctl kernal.hostname=Rakesh
C.both b and a”]
D.None
B.sysctl kernal.hostname=Rakesh
A.service iptables status
B.service network status
C.both of them
D.none of them.”]
A.service iptables status
A.smbpassword -a user
B.passwd user
C.sambapasswd user
D.None of them.”]
A.smbpassword -a user
A.to provide secure channel
B.no one can intercept the communication
C.authentication info are less secure.
D.a &b”]
D.a &b
A.subscription-manager –remove –serial=serial number
B.subscription-manager remove –serialnumber
C.subscription-manager remove –serial=serial number
D.none”]
C.subscription-manager remove –serial=serial number
- Ls –s <souce > <target>
- Ls <source> <target>
It will give 9 fileds file type, dir/file, file permissions, file owner, file group, file size, file access time, file name
By using lsof
Using ftp, sftp
Find . –type f -size +100M
Grep –c “pattern” <fle_name?
Kill -9 , Kill -9 and kill -15 difference
Using sed
Sed –n 90 filename
SCP command stands for secure copy. It is used to copy/download data from one machine to another machine.
the telnet command is used to check the connectivity to other servers. It helps you to check whether you are able to talk to another server or now. Ex: telnet 192.0.0.1 22 where 22 is the port number.
A bastion host is also known as jump server. It is used to connect from one machine to another machine securely. Bastion hosts are used to connecting to private servers securely.
Some of the common text editors that are available in Linux are vi/vim, nano, subl, gedit, atom, emacs. Vi is the default editor that you have in Linux machines.
The different zip formats in Linux are zip, gzip and bzip.
cp command stands for copy and is used to copy data from one location to another. mv stands for the move and is used to move data from one location to another.
You can run a process in the background by pressing ctrl+z command.
chown stands for ‘change ownership’ and is used to change the ownership of a file or directory. Eg: chown username.username <filename>.
- A server is a tool which does the activity like storing, load balancing, running the application process ( Mobile/laptop which has more memory)
- whatever if accessible in the network, we may name that as differently, But all are servers only. Exam: routers, LDAP, switch, etc
- OS is supporting between the hardware and the user request in every Application. this will do backround processes
- hardware don’t understand what the user needs
- mkdir – create the directory
- cd – to go Path for directory
- rm,rf removing the directory or files
- scp – file moving from one server to another server
- using SSH, we can connect
- we have to keep the public k
- ey of A server to B server
- then we can connect A server from B server
- RAM
- ROM
- Cache
for an application (depends on the requirement ) needs below:
- Apache
- tomcat
- Database
- Load balancer
- SSO – Single Sign-On
- LDAP
- After finding the IP address of an Application will search with that
- for that Subnet will help on that
- In this OSI model will come
physical,Data(MAC) ,network(IP), transport(TCP/UDP), Session, Presentation, Application
while finding the destination IP Address then it will go to many topics
- Firewall
- Types of networks (Private/Public)
- Routers
- Ports, SFTP,FTP,HTTP
- Ethernet
- ISP – Internet Service Provider
- Wi-Fi
In the destination server,via Apache, tomcat the request would be analyzed and based on the request that will reply to the user
nohup would be useful to run the process when the user logged off
free -m
/etc/passwd
/etc/groups
df -h
ifconfig
/etc/hosts
ssh
root
using SUDO
ps -ef
vi
grep
top
lsblk
ln -s
rm
chmod
useradd
mkdir
cat
touch
more
reboot
yum update -y
yum install -y httpd
srvctl start http
su – <username>
/tmp
generate the ssh keys and store it in .ssh/Authorizedkeys
Yes
cat test >> output.log
logfile
>
/etc/fstab
- whoami
- <OR>
- id
chown