Basic Linux Interview Questions and Answers – Part II

Q: What is the purpose of the sudo command?

A: The sudo command is used to execute a command as a superuser or another user. It is used to provide temporary access to privileged commands that would otherwise be inaccessible to a user. It is also used to provide an additional layer of security by prompting for a password before executing a command.

Continuing the Interview Series, we are giving 10 Questions here, in this article. These questions and the questions in the future articles doesn’t necessarily means they were asked in any interview. We are presenting you an interactive learning platform through these kind of posts, which surely will be helpful.

Basic Linux  Interview Questions
Basic Linux Interview Questions – 2

Upon the analysis of comments in different forums on last article 11 Basic Linux Interview Questions of this series, it is important to mention here that to bring up a quality article to our readers. We give our time and money, and in return what we expect from you? Nothing. If you can’t praise our work, please don’t demoralize us from your negative comments.

If you find nothing new in a post, don’t forget that for someone it was helpful, and for that he/she was thankful. We can’t make everyone happy in each of our article. Hope you readers would take pain to understand this.

Q.1: Which command is used to record a user login session in a file?
  1. macro
  2. read
  3. script
  4. record
  5. sessionrecord

Answer : The ‘script’ command is used to record a user’s login session in a file. Script command can be implemented in a shell script or can directly be used in terminal. Here is an example which records everything between script and exit.

Let’s record the user’s login session with script command as shown.

[[email protected] ~]# script my-session-record.txt

Script started, file is my-session-record.txt

The content of log file ‘my-session-record.txt’ can be views as:

[[email protected] ~]# nano my-session-record.txt

script started on Friday 22 November 2013 08:19:01 PM IST
[r[email protected] ~]# ls
^[[0m^[[01;34mBinary^[[0m ^[[01;34mDocuments^[[0m ^[[01;34mMusic^[[0m $
^[[01;34mDesktop^[[0m ^[[01;34mDownloads^[[0m my-session-record.txt ^[[01;34$
Q.2: The kernel log message can be viewed using which of the following command?
  1. dmesg
  2. kernel
  3. ls -i
  4. uname
  5. None of the above

Answer : The kernel log message can be viewed by executing ‘dmesg’ command. In the list kernel is not a valid Linux command, ‘ls -i’ lists the file with inode within the working directory and ‘uname’ command shows os.

[[email protected] ~]# dmesg

Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-279.el6.i686 ([email protected]) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 10:59:55 UTC 2012
KERNEL supported cpus:
  Intel GenuineIntel
  AMD AuthenticAMD
  NSC Geode by NSC
  Cyrix CyrixInstead
  Centaur CentaurHauls
  Transmeta GenuineTMx86
  Transmeta TransmetaCPU
Disabled fast string operations
BIOS-provided physical RAM map:
Q.3: Which command is used to display the release of Linux Kernel?
  1. uname -v
  2. uname -r
  3. uname -m
  4. uname -n
  5. uname -o

Answer : The command ‘uname -r’ display the kernel release information. The switch ‘-v’ , ‘-m’ , ‘-n’ , ‘o’ display kernel version, machine hardware name, network node, hostname and operating system, respectively.

[[email protected] ~]# uname -r

Q.4: Which command is used to identify the types of file?
  1. type
  2. info
  3. file
  4. which
  5. ls

Answer : The ‘file’ command is used to identify the types of file. The syntax is ‘file [option] File_name’.

[[email protected] ~]# file wtop

wtop: POSIX shell script text executable
Q.5: Which command locate the binary, source and man page of a command?

Answer : The ‘whereis’ command comes to rescue here. The ‘whereis’ command locate the binary, source, and manual page files for a command.

[[email protected] ~]# whereis /usr/bin/ftp

ftp: /usr/bin/ftp /usr/share/man/man1/ftp.1.gz
Q.6: When a user login, which files are called for user profile, by default??

Answer : The ‘.profile’ and ‘.bashrc’ present under home directory are called for user profile by default.

[[email protected] ~]# ls -al
-rw-r--r--.  1 tecmint     tecmint            176 May 11  2012 .bash_profile
-rw-r--r--.  1 tecmint     tecmint            124 May 11  2012 .bashrc
Q.7: The ‘resolv.conf’ file is a configuration file for?

Answer : The ‘/etc/resolv.conf’ is the configuration file for DNS at client side.

[[email protected] ~]# cat /etc/resolv.conf

Q.8: Which command is used to create soft link of a file?
  1. ln
  2. ln -s
  3. link
  4. link -soft
  5. None of the above

Answer : The ‘ln -s’ command is used to create soft link of a file in Linux Environment.

[[email protected] ~]# ln -s /etc/httpd/conf/httpd.conf httpd.original.conf
Q.9: The command ‘pwd’ is an alias of command ‘passwd’ in Linux?

Answer : No! The command ‘pwd’ is not an alias of command ‘passwd’ by default. ‘pwd’ stands for ‘print working directory’, which shows current directory and ‘passwd is used to change the password of user account in Linux.

[[email protected] ~]# pwd

[[email protected] ~]# passwd
Changing password for user root.
New password:
Retype new password:
Q.10: How will you check pci devices vendor and version on a Linux?

Answer : The Linux command ‘lspci’ comes to rescue here.

[[email protected] ~]# lspci

00:00.0 Host bridge: Intel Corporation 5000P Chipset Memory Controller Hub (rev b1)
00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 2-3 (rev b1)
00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 4-5 (rev b1)
00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 6-7 (rev b1)
00:08.0 System peripheral: Intel Corporation 5000 Series Chipset DMA Engine (rev b1)

That’s all for now. I hope these above questions might be very helpful to you. In our next weekend we again come-up with some new set of questions. Till then stay healthy, tuned and connected to Tecmint.


Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.


Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00