Unix/Linux interview question set 2/Unix/Lunux Interview Questions and Answers for Freshers & Experienced

What is the use of ‘tac’ command?

Tac command as the name suggests is the reverse of ‘cat’ command. It displays the content of the file in reverse order – line by line, displaying the last line first and moving up till the first line.

Posted Date:- 2021-08-26 08:18:01

What is ‘awk’?

AWK named after the initials of its authors “Aho, Weinberger, and Kernighan”, is an interpreted programming language for text processing. Usage-

#To display the content of file using awk
awk '{print}' fileA.txt

Posted Date:- 2021-08-26 08:17:08

How to print the content of line 5 to 10 from one file to another?

Using ‘sed’

#'p' to print and '-n' to not print each line
sed -n 5,10p fileA.txt > fileB.txt

Posted Date:- 2021-08-26 08:15:37

What is ‘sed’ in Linux?

Sed stands for Stream Editor. It is used to edit a file or input from a pipeline. Example-

#Prints first 5 lines
sed -n 1,5p fileA.txt

Posted Date:- 2021-08-26 08:14:50

Explain the usage of ‘head’ and ‘tail’ commands.

Head command is used to display the first few lines(default 10) of a file. Whereas, the tail is used to display the last few lines(default 10) of a file. Usage-

#Display first 10 lines of a file
head fileA

#Display first 5 lines of a file
head -5 fileA

#Display last 10 lines of a file
tail fileA

#Display last 5 lines of a file
tail -5 fileA

Posted Date:- 2021-08-26 08:14:02

What is the purpose of the ‘touch’ command?

Touch command serves two purposes in Linux-

1. With a new file name, touch is used to create an empty file .touch newFile
2. For existing files or directories, touch will change the last access time to the current time.

Posted Date:- 2021-08-26 08:13:14

What is the significance of file extensions like .txt, .png, etc in Linux?

Unlike Windows, file extensions have no significance in Linux. Linux does not rely on the file extensions instead the file type is determined by some content in the file header.

Posted Date:- 2021-08-26 08:12:05

What are the different file ownerships in Linux?

Each file and directory in Linux can have following 3 owners-

1. User – The user or owner permission class belongs to the user who created the file.
2. Group – The group permission class belongs to the members of the file’s group.
3. Other – User or other permission class refers to each user who has access to the file.

Posted Date:- 2021-08-26 08:10:54

In Linux, how do you stop a running process?

Every process has its own identifier. We must first locate the process id in order to terminate it. The “ps” command displays a list of all currently active processes, along with their ids. The “kill” command is then used to end the process.

Posted Date:- 2021-08-26 08:09:02

Explain the /proc file system?

The /proc file system is a virtual file system that provides detailed information about Linux Kernel, hardware, and running processes. Files under the /proc directory are named as virtual files.
Since /proc contains virtual files, it is called a virtual file system. These virtual files have unique qualities. Most of them are listed as zero bytes in size. Virtual files such as /proc/interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an up-to-the-moment glimpse of the system’s hardware. Others, such as the /proc/filesystems file and the /proc/sys/ directory, provide system configuration information and interfaces.

Posted Date:- 2021-08-26 08:08:10

What is the role of Kudzu?

Kudzu is used to detect new hardware. Red Hat Linux runs a hardware discoverer, called Kudzu. When attempting to identify a serial port, Kudzu resets the serial port. This stops the serial console. Kudzu is configured from the following file:

Kudzu can be prevented from resetting hardware, by setting the configuration parameter SAFE to ‘yes.’

Posted Date:- 2021-08-26 08:06:28

What is YUM?

YUM stands for Yellow dog Updater, Modified because it is based on YUP, the Yellow dog Updater. Yellow Dog is a version of Linux for the Power Architecture hardware and is RPM-based, just like Red Hat Enterprise Linux and Fedora. YUP, and later YUM, were written by the Linux community as a way to maintain an RPM-based system.

Posted Date:- 2021-08-26 08:05:31

If a volume group named VG0 already exists and we need to extend this volume group up to 4 GB, how do we do it?

First, we would create a physical volume (/dev/sda7) of size 4 GB.
Then, we would run the following command:
vgextend VG0 /dev/sda7

Posted Date:- 2021-08-26 08:04:44

List out some Linux distributors?

We have a lot of Linux distributors, so we’ll go through a few of the more significant ones.

a) Linux Mint is a stable and reliable operating system. Mate desktop and cinnamon are used in Linux Mint.
b) Debian is a Linux distribution that stands for stability, reliability, and a well-oiled release process.
c) Manjaro: It provides a pleasurable experience for both novice and seasoned users.
d) Ubuntu: Ubuntu is based on Debian and is available in desktop and server variants.
d) openSUSE: It is a fantastic choice for both novice and experienced users.

Posted Date:- 2021-08-26 08:03:42

How are shadow passwords given in Linux?

In Linux, the pwconv command is used for providing the shadow passwords. Shadow passwords are given for better system security. This command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file.

First, the entries in the shadowed file, which don’t exist in the main file, are removed. Then, the shadowed entries that don’t have ‘x’ as the password in the main file are updated. Any missing shadowed entries are also added. Finally, passwords in the main file are replaced with ‘x’. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand.

Posted Date:- 2021-08-26 08:02:03

What is the name and path of the main system log?

By default, the main system log is /var/log/messages. This file contains all messages and scripts written by a user. By default, all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to dmesg. The dmesg file is a system file that is written upon the system boot.

Posted Date:- 2021-08-26 07:56:12

How will you setup Password Aging in Linux?

The chage command allows the system administrators in Linux to enforce password aging. The command is used to change the number of days between mandatory password resets. The /etc/login.defs file is responsible for handling system-wide configuration. It can be edited for:

PASS_MAX_DAYS – Defines the maximum number of days a password may be used.
PASS_MIN_DAYS – Defines the minimum number of days allowed between password changes.
PASS_WARN_AGE – Defines the number of days warning is given before a password expires.

Posted Date:- 2021-08-26 07:55:36

Can we terminate an ongoing process in LINUX?

Yes, we can terminate an ongoing process in LINUX by using the Kill command, which is followed by the pid to terminate the particular process. The use of Kill 0 can be made to terminate all processes.

Posted Date:- 2021-08-26 07:54:55

Are there any Environmental variables in LINUX?

Yes, there are various environmental variables in LINUX, which include shell function, which is also known as global shell variables.

Posted Date:- 2021-08-26 07:54:23

How are drives represented in LINUX?

Drives such as floppy drives, hard drive, and others are not represented in drive letters but with different designations such as /dev/fd0 or fd1 for floppy drives 1 and 2. For hard drives, it is referred to as /dev/hda or hdb or hdc, etc.

Posted Date:- 2021-08-26 07:53:51

How can we refer to the parallel ports in LINUX?

The parallel ports include the printers, scanners, and various other electronic devices attached to the computer system. In Linux, these parallel ports are referred to as /dev/lp0 for LPT1, /dev/lp1 for LPT2, and so on.

Posted Date:- 2021-08-26 07:53:19

What is the size of a Swap Partition in LINUX?

The size of the Swap Partition in LINUX is double the amount of the physical memory available with the system. The minimum size is, however, the amount of memory installed.

Posted Date:- 2021-08-26 07:52:50

What are absolute and relative paths?

Absolute path – Absolute path is the path of a file or directory from the root directory i.e. from ‘/’.
Relative path – Relative path is the path of a file or directory from the present working directory.

Posted Date:- 2021-08-26 07:51:53

What are the advantages of the GNU project?

The GNU project is a free software that offers various advantages as follows.

1. It offers the freedom to run the programs for any purpose.
2. It helps in studying and modifying the program as per the user needs.
3. It allows the redistribution of copies of the software to people.
4. It helps in improving the software.
5. It supports the release of the software to the public.

Posted Date:- 2021-08-26 07:51:01

Explain various file permissions in Linux?

In Linux, each file and directory has three categories of owners which are User, Group, and Others. For all three owners, there are three sorts of permissions defined as mentioned below:

Read: This read permission will give the access to open the file and read it and also to list the directory’s contents.

Write: This permission gives you the ability to change the contents of a file as well as add, remove, and rename files in directories.

Execute: The file in the directory can be accessed and run by the user. The execute permission must be established before a file may be run.

Posted Date:- 2021-08-26 07:49:15

How to change directory in Linux? How to move to the parent directory, home directory, and previous directory?

Using cd command, we can change the directory in Linux. Usage-

cd directoryName
Move to the parent directory or one level up-

cd ..
Move to user’s home directory-


cd ~
Move to the previous directory-

cd -

Posted Date:- 2021-08-26 07:48:45

How to delete a non-empty directory?

On trying to delete a non-empty directory with ‘rmdir directoryName’ command, we will get an error – “rmdir: failed to remove ‘newFolder’: Directory not empty”.
For removing a non-empty directory, we need to use the ‘-r’ option of ‘rm’ command that recursively deletes the directory and its contents.

rm -r directoryName

Posted Date:- 2021-08-26 07:47:54

Mention some Linux file content commands?

Following are some file content commands:

head: Display the top lines of the file.
tail: Display the last lines of the file.
cat: Concatenate more than two files.
more: Display the content in pager form to view in the terminal.

Posted Date:- 2021-08-26 07:46:45

What is the role of the cp command in Linux?

cp command in Linux is used to copy files and directories. We can also use it for the backup of files or directories.

Syntax: $ cp file name

Posted Date:- 2021-08-26 07:46:14

How can we lock the user account in Linux?

We can lock user account for the security of users so that unauthorized users cannot log in. There are a few ways to lock the user account:

Disable the password with the help of passwd command.
Delete the user account with the help of usermod command or change command.
Switching the shell using nologin command ( /sbin/nologin ).

Posted Date:- 2021-08-26 07:45:20

Please explain how you will run a Linux program in the background together with starting the Linux Server.

You need to use the nohup command first. It will stop the process receiving the NOHUP signal. The termination will log you out of the program that was invoked. Then start the Linux server, and enter the name of the Linux program followed by the & symbol to run the process in the background.

Posted Date:- 2021-08-26 07:41:38

Please explain how to enable curl on Ubuntu LAMP stack and root logging in Ubuntu?

To enable curl on Ubuntu LAMP stack:

1. Install libcurl
2. Use the command:sudo/etc/init .d /apache2 restartORsudo service apache2 restart
To enable root logging in Ubuntu, use the command:

#sudo sh-c 'echo "greater-show-manual-login=true" >>/etc/lightdm/lightdm.conf'

Posted Date:- 2021-08-26 07:40:38

Can you tell what does a nameless directory represents in Linux?

The empty directory name serves as the nameless base of the Linux file system. It serves as an attachment for all other devices, directories, drives, and files present on the system.

Posted Date:- 2021-08-26 07:39:34

Tell us how you will execute more than one command or program from a single command line entry.

Linux allows for combining several commands in a single line. Each of the commands is separated by a semicolon (:). The execution is carried in the order the commands are specified, from left to right.

Posted Date:- 2021-08-26 07:37:56

What are the contents of /usr/local?

The /usr/local directory contains the locally installed files. The importance of the directory is when files are stored on some network. Moreover, the directory is used for storing software packages installed from a source or software not officially accompanying the distribution.

Posted Date:- 2021-08-26 07:37:20

How to check the OS version in Linux?

The “uname” command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel etc.

Posted Date:- 2021-08-26 07:35:52

How to download the file using CLI?

wget command is used to download the files from the internet.

Posted Date:- 2021-08-26 07:35:23

What is the procedure to set the umask permanently for a user?

If the umask command is used without any arguments, it means it will display the current mask.

There are two types to set the umask permanently:

1. Ocotal representation.
2. Symbolic representation.

Posted Date:- 2021-08-26 07:34:57

What is the difference between the home directory and the working directory?

The home directory is the default working directory when a user logs in.

The working directory is the user’s current directory.

Posted Date:- 2021-08-26 07:33:43

What is the root account in Linux?

The root account is like a systems administrator account and allows full control of the system.

Posted Date:- 2021-08-26 07:32:23

How to print the current working directory in Linux?

Pwd command is used to display the current directory (Print Working Directory)-

$ pwd

Posted Date:- 2021-08-26 07:30:52

Can you tell us about the various kinds of permission under Linux? Also, explain how to change permissions.

There are three types of permissions under Linux:

Read – Users are allowed to read the files or list the directory
Write – Users are allowed to write to the file or add new files to the directory
Execute – Users are allowed to run the file or lookup for a specific file within a directory
A system administrator or the owner of the file or directory can grant permission to others using the chmod command. It is followed by specifying the receiver(s) of the permission followed by whether permission is granted or denied, then type of permission, and finally having the name of the file.

The general syntax is something like this:

chmod permissionreceiver+typeofpermissions file
The permission receiver can be a for all, g for group, o for others, and u for the user. Typeofpermissions can be r for read, w for write, and x for executing. For instance, a command:

chmod go+rwx DemoFile.TXT
will grant read, write, and execute permission to group and others for the file named DemoFile.

Posted Date:- 2021-08-26 07:28:42

Why should you avoid Telnet to administer a Linux system remotely?

Telnet uses the most insecure method for communication. It sends data across the network in plain text format, and anybody can easily find out the password using the network tool.
It includes the passing of the login credentials in plain text, i.e., anyone running a sniffer on the network can find the information he/she needs to take control of the device in a few seconds by eavesdropping on a Telnet login session.

Posted Date:- 2021-08-26 07:27:37

Suppose, your FTP Server is hacked and the entire server needs to be restored. How would you restore the original kernel system files?

We cannot restore the entire operating system from the tape backup device. Therefore, we should reinstall the core operating system and then restore the system configuration files and user data from the tape backup device.

Posted Date:- 2021-08-26 07:27:02

What are the three standard streams in Linux?

In Linux, standard streams are channel communication of input and output between a program and its environment. In the Linux system, input and output are spread among three standard streams which are:

1. Standard Input (stdin)
2. Standard Output (stdout)
3. Standard Error (stderr)

Posted Date:- 2021-08-26 07:25:48

How to kill a process?

If a process becomes unresponsive and you wish to kill that process. Get the pid of that process and kill using the below command.

Kill Sign option file1

Kill -9 file ( 9 forces programs to stop immediately)

you also need to know the process identification number (PID) of the program you want to kill. If you don’t know the PID, simply run the command ps ux.

Posted Date:- 2021-08-26 07:24:18

How to check first few and last few lines of any linux file?

The head command is used to view the first lines of any text file. By default, it will show the first ten lines,

but you can change this number to your liking.

For example, if you only want to show the first five lines.

head -n 5 filename.ext.

tail command

This one has a similar function to the head command, but instead of showing the first lines,

the tail command will display the last ten lines of a text file.

tail -n filename.ext.

Posted Date:- 2021-08-26 07:22:46

What is sudo command?

sudo stands for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions.

However, it is not recommended to use sudo command because most of the tasks would be performed as a particular user.

Posted Date:- 2021-08-26 07:21:53

What is the role of case sensitivity in affecting the way commands are used?

Linux is considered a case sensitive. Case sensitivity can sometimes serve as the reason for displaying different answers for the same command as you might enter the different formats of commands each time. In terms of case sensitivity, the command is the same but the only difference occurs with regard to uppercase and lowercase letters.

For Example,

cd, CD, Cd are different commands with different outputs.

Posted Date:- 2021-08-26 07:20:50

How can you enhance the security of the password file in Linux?

It is in the test file named ‘/etc/passwd’ that Linux usually keeps its user account details, including the one-way encrypted passwords. However, this file can be accessed with the help of different tools, which might throw security issues.

To minimize this risk, we will make use of the shadow password format that saves the account details in a regular file /etc/passwd as in the traditional method but with the password stored as a single ‘x’ character, i.e., it is not the original password that is actually stored in this file. Meanwhile, a second file /etc/shadow will have the encrypted password, along with the other relevant information, such as the account/password expiration date, etc. Most importantly, the latter file is readable only by the root account, and thus it minimizes the security risk.

Posted Date:- 2021-08-26 07:17:22

R4R Team
R4R provides Unix/Lunux Freshers questions and answers (Unix/Lunux Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Unix/Linux interview question set 2,Unix/Lunux Freshers & Experienced Interview Questions and Answers,Unix/Lunux Objetive choice questions and answers,Unix/Lunux Multiple choice questions and answers,Unix/Lunux objective, Unix/Lunux questions , Unix/Lunux answers,Unix/Lunux MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Unix/Lunux fresher interview questions ,Unix/Lunux Experienced interview questions,Unix/Lunux fresher interview questions and answers ,Unix/Lunux Experienced interview questions and answers,tricky Unix/Lunux queries for interview pdf,complex Unix/Lunux for practice with answers,Unix/Lunux for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .