Linux Interview questions and answers for experienced users


Written by - Deepak Prasad

Here I have consolidated some of the advanced Linux interview questions and answers for experienced professionals working into Linux background to help you practice and prepare for the interview. In my last article I had shared shell scripting interview questions and answers.

linux-interview-questions-and-answers-for-experienced-users

 

Linux interview questions and answers examples:

Question:
How can you make the file untouchable.txt to be immutable (un-alterable) so that it will not be able to be changed or deleted by any user including root?

Answer:
To achieve this you can use attributes to change the file to be immutable using below command

chattr +i untouchable.txt

 

Question:
How can you run a PHP statement from the command line without creating a file?

Answer:
You can use the PHP interactive input

php -r ‘echo “Hello Worldrn”;’

 

Question:
How can you find the usage time of all the users on the machine (individually)?

Answer:
You can use the command ac in order to get login information about users

ac -p

 

Question:
How can you use variables as a part of your command? For example, set pipeline=”|” and run ps aux $pipeline grep root

Answer:
You can use the eval command to use variables literally -

eval ps aux $pipeline grep root

will be the same as

eval ps aux | grep root

 

Question:
You want to create network statistics and graphs for your server so which tool would you use (most common)?

Answer:
The most common network statistics tool is called mrtg (Multi Router Traffic Grapher) and usually is the most recommended open-source tool.

 

Question:
How can you send the BIOS a query message directly from the command line?

Answer:
In order to query the BIOS, you can send it a message from the console by using the biosdecode tool.

 

Question:
How can you manipulate partitions on a Linux system?

Answer:
Linux provides two applications for partition manipulation - fdisk and parted.

 

Question:
What is the result of the lsmod command?

Answer:
The lsmod command will show you the status of modules that are loaded into the Linux kernel hence this is a nice way to see /proc/modules.

 

Question:
How can you find your hardware configuration and description of the local machine?

Answer:
Using the DMI table decoder (dmidecode) you can see your system hardware and configuration.

 

Question:
How can you mount an NTFS partition on Linux?

Answer:
You need to use an external application “ntfs-3g” also called “mount.ntfs” in order to mount ntfs.

 

Question:
What is the LD_LIBRARY_PATH environment variable?

Answer:
It is an environment variable set to give the RT Shared library loader extra directories to look for when searching for shared libraries.

 

Question:
How can you get the Access, Modify and Change date & time of the file “myFile”?

Answer:
In order to get those times, you need to use stat myFile and look for the Access/Modify/Change information.

 

Question:
You want to save the mysql DB “mySQLDB” to a file “mySQLDB.sql” so how can you do it?

Answer:
You can use the mysqldump command to dump a database –

mysqldump -u username -p mySQLDB > mySQLDB.sql

 

Question:
How can you prioritize system resources per running process?

Answer:
The system allocate and prioritize resources for processes on the system using nice levels, and in order to change the nice of a specific process, you need to run

renice level <process id>

 

Question:
How can you get the NS records of the domain “google.com” from the terminal command line?

Answer:
The command dig allows you to get specific domain information, such as A, AAAA, NS, etc’ records - you can use

dig google.com NS.

 

Question:
You are running a tail -f on /var/log/messages file and looking for specific error, you want only the log that you saw to be printed into a local file “found.log” in order to search it later on a smaller file so how can you do it?

Answer:
The tee command allows you to save data from the standard I/O to a file, you can use it as

tail -f /var/log/messages | tee found.log

and thus it will save you only the data that you saw on the tail.

 

Question:
How do you check all the services that start/stop on each runlevel?

Answer:
In order to check the runlevel services information for the run levels you need to use the chkconfig:

chkconfig –list

 

Question:
How can you allow a user to run superuser commands without knowing the root password?

Answer:
If you want to allow a user to run superuser commands without having superuser (or root) access then you can add him specific (or all) access using sudoers file after which the user can run all superuser commands using sudo.

 

Question:
How can you check which libraries are being used and needed for the binary file /bin/vi?

Answer:
Running the tool “ldd /bin/vi” will show you the shared libraries needed to run the binary application /bin/vi.

 

Question:
You want to install a new PERL module, what is the correct way to do it?

Answer:
PERL has its management console cpan that allows you to install new modules using the command

install Group::Module

 

Question:
How can you enable jumbo-frame (9000) on a network interface eth0 in Linux?

Answer:
You can use ifconfig eth0 mtu 9000, but in order to make it permanent you will need to add it to the ifcfg-eth0 file.

 

Question:
Explain the following command: “iptables -A OUTPUT -p icmp --icmp-type echo-request -j DROP

Answer:
The command will add a rule to the iptables that will drop all PING requests to the server.

 

Question:
What does the wine application does on Linux system?

Answer:
The wine application allows you to run windows applications on a Linux server/workstation.

 

Question:
What is the Nagios system?

Answer:
The Nagios is an open-source monitoring tool/application that helps identify and resolve infrastructure/network problems.

 

Question:
You need to generate a random number in the console so how can you do it without any random application?

Answer:
Generate a number string from the

/dev/urandom - od -N3 -tu2 -vAn < /dev/urandom | sed 's/ //g'

 

Question:
You have a very secret file “TOP-SECRET.txt”, which needs to be deleted “for good” so how can you do it?

Answer:
You can use the shred tool to overwrite the file X times so it will not be able to recover -

shred -n 10 -z TOP-SECRET.txt

 

Question:
You are in a directory /home/user/downloaded/ and you want to share the files in this directory quickly over web without configuring an httpd server so how can you do it with python?

Answer:
The Python script language allows a quick httpd service called SimpleHTTPServer using which you can share the local directory you’re in using the command, for example

python -m SimpleHTTPServer

 

Question:
While running a command interactively so how do you send the command into background?

Answer:
To send a command to the background, click Ctrl+Z, it will send you to the command line and pause the application, then type bg in order to send that command to background.

 

Question:
How can you compile a regular c application “myprog.c” and create a binary “myprog”?

Answer:
The most common way to compile is with the “gcc” compiler, and in order to compile a c file to a binary file you run

gcc myprog.c -o myprog

 

I hope this article with Linux interview questions and answers was useful, please let me know your feedback using the comment box below.

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

2 thoughts on “Linux Interview questions and answers for experienced users”

  1. I have not checked in here for some time because I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂

    Reply

Leave a Comment

X