Linux Interview Questions And Answers by Sevenmentor Institute

  • By
  • November 29, 2019
  • Linux
Linux Interview Questions And Answers by Sevenmentor Institute

Linux Interview Questions And Answers Blog

 

1: While installing a source tarball, Which steps are required?

Answer:

  1. a) extract the tarball
  2. b) ./configure
  3. c) make
  4. d) make install

For Free Demo classes Call:7798058777

Registration Link: Click Here!

2: In the bash shell, how can you change your command prompt of root to look like [User]@[Host]{path} #

Answer:

You can change the PS1 environment variable: export PS1='[\u]@[\h]{\w} # ‘

 

3: Which command is used to delete a file called “–test”?

Answer:

As “–test” may be considered as an argument, you need to add “–“ before the fie name: rm — –test

 

4: How do you format a file system using a command?

Answer:

You can format a file system with the mkfs command.

5: Which wildcards you can use in Linux?

Answer:

You can use following wildcards: ? and *

6: How to send a command into the background?

Answer:

Use Ampersand in the end of the command: i.e. ./run_file_exec &

7: Which command is used to redirect a command STDERR response into STDOUT

Answer:

In order to direct the STDERR into the STDOUT, you need to add the redirection parameters to the command – <Command> 2>&1.113: What is the difference between `echo Hello > tmp.log` and `echo Hello >> tmp.log`?

Answer:

When using > you truncate the file and insert a new row, when using >> you add new line at the end of the file.

8: What is the limit of maximum characters for a Linux file name?

Answer:

You can use maximum 256 characters for a Linux file name.

9: How to send a SIGKILL signal to a process?

Answer:

kill -9 <process_id>

10: What is a Linux ISO?

Answer:

Linux ISO is a downloadable binary file containing a CD/DVD disc image of a Linux distribution used for Installation.

11: Given the text files “fileone.sh filetwo.sh filethree.sh filefour.sh”, you need to delete all of the .sh files with those names, how can you do it with brace expansion?

Answer:

you can use brace expansion, using command,

rm -f {fileone,filetwo,filethree,filefour}.sh.

12: You have a directory called /scripts and you want to add it temporarily to your executable path, how can you do that?

Answer:

Your executable path are extracted from the environment $PATH, you can add temporary item to it on the current shell using –

export PATH=$PATH:/scripts.

13: If I have configured the parameter TTL in my domain configuration file &#40;named&#41; to 14400, what does it mean?

Answer:

The domain TTL configuration is setting the time which name-servers querying the name server will cache the results in their DB before asking the server for new configuration.

14400 seconds is 4 hours.

14: You want to encrypt and password-protect a password file “mysecret.txt”, how can you do it with GPG and then decrypt it to view the contents?

Answer:

to gpg encrypt a file, you can use command “gpg -c mysecret.txt” and choose your desired password.

to decrypt it and view the contents, you can use command “gpg -d mysecret.txt.gpg”

15: You want to traceroute a remote server with an interactive interface and fast resolution (more than traceroute), how can you do it?

Answer:

You can use mtr tool which allows you a fast and much more interactive solution for the server administrator than traceroute.

For Free Demo classes Call:7798058777

Registration Link: Click Here!

16: How can you find which of the users (residing in /home/) are using the most HD space?

Answer:

You can use the du command to get the HDD usage and find the most heavy directories –

du -hs /home/* | sort -nr | head -10.

17: How can you change your server timezone to a Europe/France timezone?

Answer:

You can link the file /usr/share/zoneinfo/Europe/Paris to /etc/localtime.

18: How do you change the user andy’s login shell to /bin/sh?

Answer:

You need to use the command chsh -s /bin/sh andy.

19: Explain commands “kill <PID>” and “kill -9 <PID>”?

Answer:

When using “kill -9 <PID>” command, it tells the PID to exit immediately instead of exiting in the correct way.

20: Which command is used to add a virtual network interface on eth0 with the ip 10.10.10.1 on class C?

Answer:

You can add virtual interfaces on eth cards that will hold additional system IPs – ifconfig eth0:0 10.10.10.1 netmask 255.255.255.0.

21: Which configuration file is used to define the log level of the messages that are written to /var/log/messages?

Answer:

The logs that are being sent to the messages log are being managed by the rsyslogd which is configured in /etc/rsyslog.conf.

22: Which command is used to  turn your Linux server into a router?

Answer:

In order to configure the Linux server to allow routing, you need to allow ip forwarding on it by:

echo “1” > /proc/sys/net/ipv4/ip_forward

and add configuration “net.ipv4.ip_forward = 1” in /etc/sysctl.conf

23: Explain the difference between a swap file and a swap partition?

Answer:

The swap partition is a standalone partition and can be used by multiple OS whereas A swap file is a local file on your partition and can be used by the current system.

24: You have installed RPM file “xinetd-2.3.14-10.el5” Which command is used to know which files on the system belong to this RPM?

Answer:

RPM command allows you to query an RPM Package and identify its files by: rpm -ql xinetd-2.3.14-10.el5.

25: Given the local file /usr/bin/pstree” on the HD, how can you identify if it came from an RPM?

Answer:

RPM allows you to reverse-query the RPM DB and search its files by: rpm -qf /usr/bin/pstree

26: Explain what is the LVM and where can you find its configuration?

Answer:

The LVM full form is the Linux Volume Manager and its configuration is found under /etc/lvm/lvm.conf.

For Free Demo classes Call:7798058777

Registration Link: Click Here!

27: Which command is used to get the status of all the services configured on your Linux machine?

Answer:

You can use the service or systemctl command to stop/start and get information about the services – service –status-all.

28: Which command is used to change the system library paths?

Answer:

You can change the system library paths, you need to edit the file /etc/ld.so.conf and then run ldconfig to reload the changes.

29:  Which command is used to disable all ping responses from the Linux machine?

Answer:

You need to use command – echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

30: Is it possible to force the user john to change his password after 90 days, how can you do that?

Answer:

The chage tool allows you to force a user to change his password after X days – chage -M 90 john

31: Which command is used to list all of the USB buses and devices that are connected?

Answer:

You can use the command “lsusb” to give you the bus information and who is using it.

32: Your hardware clock and your system clock are showing different times, how can you sync between your system clock and the hardware clock?

Answer:

The hardware clock can be configured by the hwclock and in order to sync them you can use the command hwclock –systohc to copy the system to hw to hwclock –hctosys to copy the hw to system.

33: Which application can be used to check the status of bad blocks on your hard drive?

Answer:

You can use badblocks application that gives you information about the HD bad blocks – badblocks -s /dev/sda

34: Which command is used to show all the current mounts and their stats?

Answer:

Using the command df -ah you can get information about your current mounts including available/used space

35: Which command is used to check the memory and paging status (free, used, cached)?

Answer:

Using free -m you will get the current memory status, including free, used, cached both for the physical and swap memory.

36: How can you get cpu and harddrive activities average report?

Answer:

iostat command gives you information and averages about your system I/O for the CPU and HD.

37: Which command is used to get statistical information about your server for the previous days?

Answer:

You can use sar command to get statistical information about your server.

38: Which command is used to get CPU statistics, per CPU or Core?

Answer:

You can use “mpstat -P ALL” to get statistical information of per CPU/Core.

39: Which command is used to find which of the directories (top level) on the current directory is the heaviest (kb)?

Answer:

You can use du command to get the size of each top level dir, and sort it.

du -k –max-depth=1 | sort -nr

40: How do you check which linux distribution you’re using?

Answer:

In order to find the Linux distro information, you can use: cat/etc/*release

 

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 *

*
*