10 Interview Questions and Answers on Various Commands in Linux

Our last article, “10 Useful SSH Interview Questions” was highly appreciated on various Social Networking sites as well as on Tecmint. This time we are presenting you with “10 Questions on various Linux commands“. These questions will prove to be brainstorming to you and will add to your knowledge which surely will help you in day-to-day interaction with Linux and in Interviews.

Linux Questions on Commands
Questions on Various Commands
Q1. You have a file (say virgin.txt). You want this file to be alter-proof so that no one can edit or delete this file, not even root. What will you do?
Answer : In order to make this file immune to editing and deleting we need to use command “chattr”. Chattr changes the attributes of a file on Linux System.

The Syntax of command chattr, for the above purpose is:

# chattr +i virgin.txt

Now try to remove the file using normal user.

$ rm -r virgin.txt 

rm: remove write-protected regular empty file `virgin.txt'? Y 
rm: cannot remove `virgin.txt': Operation not permitted

Now try to remove the file using root user.

# rm -r virgin.txt 

cannot remove `virgin.txt': Operation not permitted
Q2. If several users are using your Linux Server, how will you find the usage time of all the users, individually on your server?
Answer : To fulfill the above task, we need to execute command ‘ac’. The Linux command ‘ac’ may not be installed, in your Linux box, by default. On a Debian based System you need a package ‘acct’ installed to run ac.
# apt-get install acct
# ac -p 

(unknown)                     14.18 
server                             235.23 
total      249.42
Q3. Which is preferred tool to create Network Statistics for your server?
Answer : A mrtg stands for Multi Router Traffic Grapher is one of the most commonly used tool to monitor network Statistics. mrtg is most widely recommended FOSS tool, which is very powerful. mrtg may not be installed on your Linux Box, by default and you need to install it manually from repo.
# apt-get install mrtg
Q4. It is possible to send query to BIOS from Linux Command Line?
Answer : Yes! it is possible to send query and signals to BIOS, directly from the command line. For this you need a tool called “biosdecode”. On my Debian wheezy (7.4), it is already installed.
# biosdecode 

# biosdecode 2.11 

ACPI 2.0 present. 
	OEM Identifier: LENOVO 
	RSD Table 32-bit Address: 0xDDFCA028 
	XSD Table 64-bit Address: 0x00000000DDFCA078 
SMBIOS 2.7 present. 
	Structure Table Length: 3446 bytes 
	Structure Table Address: 0x000ED9D0 
	Number Of Structures: 89 
	Maximum Structure Size: 184 bytes 
PNP BIOS 1.0 present. 
	Event Notification: Not Supported 
	Real Mode 16-bit Code Address: F000:BD76 
	Real Mode 16-bit Data Address: F000:0000 
	16-bit Protected Mode Code Address: 0x000FBD9E 
	16-bit Protected Mode Data Address: 0x000F0000 
PCI Interrupt Routing 1.0 present. 
	Router ID: 00:1f.0 
	Exclusive IRQs: None 
	Compatible Router: 8086:27b8 
	Slot Entry 1: ID 00:1f, on-board 
	...
	Slot Entry 15: ID 02:0c, slot number 2
Q5. Most of the Linux Server are headless, i.e., they run in command mode only. No GUI is installed. How will you find hardware description and configuration of your box?
Answer : It is easy to find Hardware description and configuration of a headless Linux Server using command “dmidecode”, which is the DMI table decoder.
# dmidecode

The output of dmidecode is extensive. It will be a nice idea to redirect its output to a file.

# dmidecode > /path/to/text/file/text_file.txt
Q6. You need to know all the libraries being used and needed by a binary, say ‘/bin/echo’. How will you achieve desirable output?
Answer : The command ‘ldd’, which print shared library dependencies of a binary in Linux.
$ ldd /bin/echo 

linux-gate.so.1 =>  (0xb76f1000) 
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7575000) 
/lib/ld-linux.so.2 (0xb76f2000)
Q7. You are working for the country’s army. You have a file (say “topsecret.txt”) which contains confidential and country’s security Information, Nuclear missiles, etc. What will be your preferred method to delete this file?
Answer : The file, being so confidential needs special deletion technique which can not be recovered by any means. For this, to implement practically we need to utilize an application “shred”. Shred tool overwrites a file repeatedly several times, thus making file recovery for any illegal activity almost nil and practically impossible.
# shred -n 15 -z topsecret.txt

shread – overwrite a file to hide its contents, and optionally delete it.

  1. -n – Overwrites the files n times
  2. -z – Add a final overwrite with zeros to hide shredding.

Note: The above command overwrites the file 15 times before overwriting with zero, to hide shredding.

Q8. Is it possible to mount an NTFS partition on Linux?
Answer : Yes! We can mount an NTFS partition/disk on Linux system using application ‘mount.ntfs’ which optionally is called as ‘ntfs-3g’ in order to mount ntfs partition on Linux System.

For more information, read article on how to monitor an NTFS Partition on Linux.

Q9. What and where you need to edit so that the default desktop at login will be KDE, which at present is GNOME.
Answer : We need to edit a file ‘/etc/sysconfig/desktop’ and add/edit the below lines to load KDE by default and not GNOME.
DESKTOP=”KDE”
DISPLAYMANAGER=”KDE”

Save the file with above content. Next time when machine boots, it automatically will load KDE as default display manager.

Q10. What does an intrid image file refers to?
Answer : An intrid is Initial Ram Disk Image that loads into Memory after Power On Self Test (POST) in order to improve machine I/O performance. intrid contains temporary root file system.

That’s all for now. I’ll be here again with another interesting topic, worth knowing. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in comment section.

Avishek
A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

16 thoughts on “10 Interview Questions and Answers on Various Commands in Linux”

  1. If several users are using my centos Server, how will i find the usage time of all the users, individually on my server? what is the package name that i have to install on centos?

    Reply
  2. Dear Sir,
    W.r.t
    We have question for that …. If user was forget his passwd

    Q1: How can we identify ???????? How many times user has being tried into server for login.

    This question was faced at interview time please do the needful.

    Awaiting for your response

    Thank you,
    Regards,

    Sathish

    Reply
  3. Hi,

    I really like your blog and the posts published by you are all great and informative.

    Keep going and help us grow do put some more informative question answeres it needs to updated every month with latest technical questions … :)

    Reply
  4. Hi, I gave 2 interviews for linux admin and 1 topic bothered me both the time. That is Linux boot process. For just the Boot process it’e ok but questions in between the boot process re really scaring.me. Please help newbies with the questions in between the boot process.
    Thanks for all the questions and answers.

    Reply
  5. Hi,

    I really like your site and the posts published by you are all great and informative.

    Keep going and help us grow … :)

    Reply

Leave a Reply to kundan singh Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.