Trending Linux Interview Questions And Answers 2019

  • By Sameer Maner
  • November 5, 2019
  • Linux
Trending Linux Interview Questions And Answers 2019

Linux Interview Questions And Answers Blog [Part 2]

1: Which command find your hardware configuration and description of the local machine?

Answer:

You can see your system hardware and configuration using the DMI table decoder (dmidecode).

 

2: How to mount an NTFS partition on Linux?

Answer:

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

 

3: What is the LD_LIBRARY_PATH environment variable?

Answer:

It is used to give the RT Shared library loader extra directories to look for when searching for shared libraries.

 

4: Which command to use to get the Access, Modify and Change date & time of the file “myFile1”?

Answer:

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

 

5: You want to save “mySQLDB” database to a file “mySQLDB.sql”, how can you do it?

Answer:

You can use – mysqldump -u username -p mySQLDB > mySQLDB.sql

 

6: How to prioritize system resources per running process?

Answer:

You need to run renice level <process id>, to change the nice of a specific process.

 

7: Which command is used to get the NS records of the domain “google.com” from the terminal command line?

Answer:

Use “dig google.com NS” command.

dig command allows you to get specific domain information, such as Host, A, AAAA, NS, etc’ records.

 

8: 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”, how can you do it?

Answer:

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

 

9: 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.

 

10: Which file needs to be edited to allow a user to run superuser commands without knowing the root password?

Answer:

You can add that user specific (or all) access using /etc/sudoers file when you want to allow a user to run superuser commands without having superuser (or root) access.

 

For Free Demo classes Call:7798058777

Registration Link: Click Here!

 

11: Which command is used to check which libraries are being used and needed for the binary file /bin/vi?

Answer:

The shared libraries needed to run the binary application /bin/vi will be shown by command “ldd /bin/vi”

 

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

Answer:

You can install new modules using the command “install Group::Module”. PERL has its management console cpan that allows you to do so.

 

13: How to enable jumbo-frame (9000) on a network interface eth0 in Linux?

Answer:

In order to make it permanent you will need to add it to the ifcfg-eth0 file, for temporary purpose use ifconfig eth0 mtu 9000.

 

14: What is the use of following command “iptables -A OUTPUT -p icmp –icmp-type echo-request -j DROP”

Answer:

It is iptables rule added that will drop all PING requests to the server.

 

15: What is the use of the wine application on Linux system?

Answer:

You can run windows applications on a Linux server/workstation using the wine application.

 

16: What is the Nagios system?

Answer:

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

 

17: You want to generate a random number in the terminal, how can you do it?

Answer:

Generate a number string from the /dev/urandom – od -N3 -tu2 -vAn < /dev/urandom | sed ‘s/ //g’

 

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

Answer:

Use command shred -n 10 -z TOP-SECRET.txt.

 

19: 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, how can you do it with python?

Answer:

The Python allows a quick httpd service called SimpleHTTPServer, and you can share the local directory you’re in using the command python -m SimpleHTTPServer

 

20: How do you send the command into background while running a command interactively?

Answer:

To send a command to the background, use Ctrl+Z,  then type bg %JOBID in order to send that command to background.

 

21: Which command is used to compile a regular c application “myprog.c” and create a binary “myprog”?

Answer:

In order to compile a c file to a binary file. run “gcc myprog.c -o myprog”

 

22: You have an application that creates a log file “myApplication.log” that grows 1GB a day. Which configuration will save only the last 3 days, on 100MB file each?

Answer:

You will need to add a new configuration (/etc/logrotate.conf) to the logrotate service with 30 files of 100M each – 100M * 10 day * 3 days

 

23: How can you change in one command all the letters to lower case and output it to formattedLetters.txt given a file unformattedLetters.txt containing text in the form of “tHiS iS AN UnForMatteD tEXt”, ?

Answer:

use cat unformattedLetters.txt | tr “[:lower:]” “[:upper:] > formattedLetters.txt”.

 

24: Which command is used to connect the files first.txt, second.txt and third.txt to one file all.txt?

Answer:

You can cat the files together into an output file – cat first.txt second.txt third.txt > all.txt.

 

25: You have a file (myfriends.txt) with names list, and you want to know how many unique names you have in that file, how can you do that?

Answer:

You can count unique names with: uniq myfriends.txt | wc -l

 

26: You want to run a binary file,  but it gives you “Access Denied”, what do you need to do?

Answer:

In order to change a file mode, you need to add executable permission to the file using the chmod with the required parameters – chmod +x <filename>.

 

For Free Demo classes Call:7798058777

Registration Link: Click Here!

 

27: How can you get the first column of all the rows from a CSV file “a.csv” into a new file called “result.log”?

Answer:

cat a.csv | awk -F’,’ ‘{print $1}’ >> result.log.

 

28: You want to create 100 log files with the same text “Hello World” in it, how can you do it?

Answer:

For i in `seq 1 100` ; do echo “Hello World” > $i.log ; done.

 

29: You have an xml file (myXML.xml) which is all in one line, how do you convert the xml into a well-formatted XML ?

Answer:

use “xmllint” application – xmllint –format myXML.xml.

 

30: Which command is used to find and display only the differences between myconfig.new and myconfig.old?

Answer:

use sdiff -s myconfig.new myconfig.old

 

31: Which configuration file is edited to set KDE to be the default desktop manager?

Answer:

/etc/sysconfig/desktop file is edited to set KDE to be the default desktop manager.

DESKTOP=”KDE”

DISPLAYMANAGER=”KDE”

 

32: In what conditions you will encounter a kernel panic issue?

Answer:

When the system had found a critical error like – an error communicating with the hardware or a missing OS file, you will encounter a kernel panic issue.

 

33: What is an initrd image?

Answer:

An initrd image is the initial ram disk image that is loaded into the memory after the POST in order to improve the machine’s I/O performance; it will contain a temporary root file system.

 

34: Which minimum partitions do you need for a Linux installation?

Answer:

The minimum partitions that you need in order to install a Linux installation is two(2), root and swap.

 

For Free Demo classes Call:7798058777

Registration Link: Click Here!

 

35: What is the recommended size for the swap partition to be (minimum size) if you have 2GB RAM?

Answer:

The SWAP partition minimum recommended size is double to RAM and it can not be less than 32MB, therefore for 2GB RAM you should have 4GB SWAP.

 

36: After the init process has been completed, how can you add special commands to run?

Answer:

In order to add a command that will run after the system finishes its initialization, you can add the command to /etc/rc.local.

 

37: How to set global environment and startup programs for all users?

Answer:

You can add your configuration in the /etc/profile configuration file which holds the global profile parameters and is inherited by the users on login.

 

38: How to set the user prompt automatically to all bash users to look like [[email protected]][~]#

Answer:

You can edit the /etc/bashrc configuration file to set bash configuration for all the users.

 

39: What would be the output of the command “ls -d /root” as a regular user?

Answer:

The command will give you error message to access to the /root directory, permission denied.

 

40: What will happen if you run  “#reboot now” command?

Answer:

the command “reboot now” would be ignored as the “#” sign states a comment.

 

41: Which command will run when you use “!l” after running “ls” then “id” then “who”?

Answer:

It will run the latest command matching “l*” therefore it will run “ls”

 

42: What will happen if you type “for”?

Answer:

It will be detected as a shell keyword. “for” is a shell internal command

 

43: How can you identify which shell are you currently using?

Answer:

The system holds your shell name in $SHELL environment variable and you can print it using echo $SHELL.

 

44: What will be the effect of commands  “su root” and “su – root”?

Answer:

When running “su root” you only change the UID and GUID and stay in the previous user current working directory, if you use the minus sign “su – root” you also initiate root user’s login and your current working directory will be in /root directory which will make the same as a real login.

 

45: What will be the effect of commands “cd /tmp && pwd” and “(cd /tmp && pwd)”?

Answer:

the effect of first command, you will move to the /tmp folder, and stay there when the command ends, the effect of second command, where you go back to the starting directory.

 

For Free Demo classes Call:7798058777

Registration Link: Click Here!

Call the Trainer and Book your free demo Class for now!!!

call icon

© Copyright 2019 | Sevenmentor Pvt Ltd.

Submit Comment

Your email address will not be published. Required fields are marked *

*
*