You are on page 1of 8

40 Linux Interview Questions for Freshers Part-2

Q:1 What will happen when you execute the command “mv *” in your current directory ?

Ans : It will move all the contents of directory to the directory which is created in the last in your current
working directory, In Case if a file is created in last then it will through an error.

Q:2 Tell me the main difference between SCP and Telnet command ?

Ans : In Case of SCP data is transferred in an encrypted form between the client and server but in the telnet
data is transferred in plain text. Intruder can easily extract the confidential info in case of telnet.

Q:3 What is RAID and why it is required ?

Ans : RAID Stands for Redundancy Array inexpensive Disk, it is required to provide high availability and
redundancy in case of hard disk failure in physical servers.

Q:4 How to check when was the particular rpm installed on your server ?

Ans : Use the rpm command “rpm -q {rpm_name} –last”

eg

[root@tgt ssh]# rpm -q nautilus-extensions -last


nautilus-extensions-2.28.4-19.el6.x86_64 Tue 31 Mar 2015 04:19:33 PM IST
[root@tgt ssh]#

Q:5 How to check number of open files of a particular user ?

Ans : Using lsof command we find number of files associated to particular user.

# lsof -u apache
# lsof -u apache | wc -l
Q:6 How to check what is your current working shell ?

Ans : echo $SHELL

Q:7 Is it possible to do a dry-run installation of a RPM ?

Ans : Yes, it is possible with option “–test” with rpm command like

“rpm -ivh <rpm_package> –test“,

this command will not install rpm package but it will check whether rpm installation will be successful or not.

Q:8 How to check whether a local linux user account is locked or not ?

Ans : Using the passwd command “passwd -S <user_name>” we can check whether the password is set or not.
Moreover we can also see the login failed attempts using “pam_tally2 -u {user_name}“. If login failed attempts
cross the limit then account will be locked.

Q:9 How to check when was the password changed for local Linux user ?

Ans : Use the chage command “chage -l {user_name}“, there is entry in the output “Last password change”
from there we can check the date.

Q:10 What are the different fields of /etc/passwd file ?

Ans : There are 7 fields in /etc/passwd file

 User Name
 Password

 UID

 GID

 Comments for the User


 Home directory

 Shell

Q:11 what is the toggle id for LVM partition in Linux ?

Ans : “8e” is the toggle id in fdisk command for Linux LVM partition.

Q:12 How to find access and modify time of a file and directory in linux ?

Ans : Using the ‘stat’ command we can find the access and modify time of a file and directory. Example is
shown below :

# stat {file_name}
# stat {Directory_name}

Q:13 List all the files of /var file system which are not accessed more than 30 days ?

Ans : Use the find command to list all files which are not accessed more than 30 days in /var.

# find /var -type f -atime +30 -exec ls -ltr {} \;

Q:14 How to recreate initrd image file in Linux ?

Ans : In Case of RHEL 4 & 5 , we can use ‘mkinitrd‘ command to recreate initrd file. In RHEL 6 & 7 ‘dracut’
command is used to rebuild initrd file.

Q:15 How to list inodes of a file system in linux ?

Ans : Use ‘-i’ option in df command to view the inode of the file system, Example “df -i /var”
Q:16 How to increase of ‘number of open files’ limit for a particular user in Linux ?

Ans : ‘Number of open files’ limit for a particular user can be increased by modifying the file
“/etc/security/limits.conf”. Add the following line in the file.

<user_name> soft nofile 4096 (Change this value as per requirement)


<user_name> hard nofile 4096 (Change this value as per requirement)

Q:17 How you will find the default ulimit values for a user in Linux ?

Ans : To check the default ulimit values of local user, first login to system with that user name and type the
command “ulimit -a”.

Q:18 How to send a mail from terminal or console ?

Ans : There are two ways to send mail from the terminal

 mail command , example : # echo “body of mail” | mail -s {subject_of_mail} — {email_id}

 telnet command

Q:19 How to set proxy settings on Linux terminal ?

Ans : We can set the proxy settings on Linux terminal using the variables like http_proxy, https_proxy and
ftp_proxy.

# export http_proxy=http://<ip_or_dns_name_of_proxy_server>:<port_no>
# export https_proxy=http://<ip_or_dns_name_of_proxy_server>:<port_no>
# export ftp_proxy=http://<ip_or_dns_name_of_proxy_server>:<port_no>

Q:20 Find all files under /opt which has 777 permissions and change it to 644.

Ans: Use the below find command :

# find /opt -type f -perm 777 -exec chmod 644 {} \;


Q:21 How to check which linux flavor and version is installed ?

Ans : Use the following command to get linux flavor and version :

# cat /etc/*-release

Q:22 What is the uid and gid of root user on Linux server ?

Ans : UID and GID of root is user is ‘0’

Q:23 What are default configuration files of postfix mail server ?

Ans : There are two main configuration files of postfix mail server.

 /etc/postfix/main.cf

 /etc/postfix/master.cf

Q:24 What is the default umask of root user on Linux servers ?

Ans : Default umask of root user is “0022”

Q:25 How to disable and enable swap memory ?

Ans: Command “swapoff -a” is used to disable swap memory and “swapon -a” is used to enable swap memory
on linux servers.
Q:26 What is default port of proxy server(Squid), SMTP, Apache Web Server(httpd) and MariaDB Database Server ?

Ans : Following ports are used for the respective servers.


Ports Services
3128 — proxy server(Squid)
25 — SMTP
80 and 443 — Apache Web Server(http and https)
3306 — MariaDB Database

Q:27 How to check kernel related logs on Linux server ?

Ans: ‘dmesg‘ command is used to display kernel related logs.

Q:28 How you will check ip address and routing table of a linux box ?

Ans : Using the commands ‘ifconfig’ and ‘ip address‘ we can view the ip address of a linux server. With the
commands like ‘netstat -nr’ and ‘route -n‘ we can view the current routing table.

Q:29 Tell me the default configuration file of linux ftp server (vsftp ) ?

Ans : “/etc/vsftpd/vsftpd.conf” is the default configuration file of vsftpd.

Q:30 How to merge the contents of two files into a single file from the command line ?

Ans: With the help of cat command we can merge the contents of two or more files into a single file.

# cat tech_file1 tech_file2 > merger_file

Q:31 Which command is used to check the permissions of a file and directory ?
Ans : “ls -l {path_file_name}” is used to check the permissions of a file. “ls -ld {path_directory_name}” is used
to check the permissions of a folder or directory.

Q:32 what is the role of /etc/mtab file ?

Ans : mtab file keeps the information of all the current mounted file system only.

Q:33 How to recover root password in Linux server ?

Ans: There is no way to recover the root password, the only way is to reset the root password from single user
mode.

Q:34 What can be the reasons that Oracle user is unable to run its cron jobs ?

Ans : There can be multiple reasons like :


a) Oracle User password might have expired.
b) Oracle user might not be allowed to run cron jobs
c) /var file system might be 100 % utilized.

Q:35 What are the different fields of crontab file ?

Ans : A Crontab file conatins following fields

* * * * * {Command_to_be_executed}
(minute) {hour} {day_of_month} {month} {day_of_week}

Q:36 Tell me the log file for cron jobs in linux server ?

Ans : All the cron job’s logs are stored in its log file “/var/log/cron”
Q:37 what will happen if i run the command ” kill -9 1″ ?

Ans: Nothing will happen

Q:38 What is default home directory of ftp user and how to change it ?

Ans: “/var/ftp” is the default home directory of ftp user. It can be changed using the usermod command like
“usermod -d /{path_new_directory} ftp“.

Q:39 How to create partitions on raw disk in Linux ?

Ans : Partitions can be created on raw disk either by using ‘fdisk’ command or by ‘parted’ command

Q:40 How to copy the files and directory from one Linux server to another remote Linux server ?

Ans :

With help of ‘scp‘ and ‘rsync‘ command we can copy the files of one linux server to another. Syntax of scp and
rsync is shown below :

# scp {files_to_be_copied} root@<remote_server_ip>:/{location_where_to_copy_files}

# rsync -av –progress {files_to_be_copied} root@<remote_server_ip>:/{location_where_to_copy_files}

You might also like