Linux Interview Questions And Answered Part-2

Q.1 What are the different types of permissions for a file in Linux?
. Read (r)
. Write (w)
. Executable (x)
Q.2 Which permission allow a user to run an executable file (script)?
we need to provide executable(x) permission to the user.
Q.3 How to write the output of a command into a file?
#command > file_name

Q.4 How to write something in a file without deleting the existing content?
#command >> file_name

Q.5 How to redirect an error of a command into a file?
To redirect an error we need to use 2>
To redirect both error and output, 2<&1

Q.6 How to Automate any task or script?
Using cron jobs
For which we have crontab and at command.
Q.7 How to check scheduled jobs?
#crontab -l
Q.8 What is the meaning of this cron job? * * * * *

Q.9 If your cron job didn't work, how would you check?
check system time,
crontab entry,
check /var/log/messages
Q.10 What is daemon service?
Service that keep running in background
Example: httpd, sshd, chronyd.
Q.11 How to check if a service is running or not?
#systemctl status service_name

Q.12 How to start/stop any service?
#systemctl start service_name
#systemctl stop service_name
Q.13 How to check for free disk space?
#df

Q.14 How to check the size of a directory's content?
#du

Q.15 How to check CPU usage for a process?
#top

Q.16 What is a process in Linux?
An instance of a running program.
Whenever you start a program/application or execute a command, a process is created.
For every process a unique no. is assigned which is called PID(Process ID).
Q.17 How to check if a process is running or not?
#ps

Q.18 How to kill a process?
#kill
Q.19 How to check if a IP/Server is accessible or not?
We can use #ping or #telnet command
Q.20 Which command to use to get info about ports?
#netstat

Q.21 How to check open port on Linux system?

Q.22 How to check network interfaces in Linux?
#ifconfig

Q.23 Difference between Telnet and SSH?
SSH is secured and telnet is not.
Q.24 Which service should be running on server to allow you to connect remotely?
#ssh or #sshd
Q.25 What is SSH?
SSH or Secure Shell is a network communication protocol that enables two computers/devices to communicate and share data.
Q.26 Why it is called as Secure Shell?
Communication between hosts and client will be in encrypted format.
Q.27 What id default port for SSH?
22
Q.28 Which command is used to access a linux system from a terminal or another linux server?
#ssh user@192.168.X.X