Linux Interview Questions

Q. What is the difference between Telnet and SSH?
Although Telnet and SSH are both communication protocols to manage a remote system, the SSH is the secured version of the telnet, and will require key exchange unlike Telnet which sends the data on clear-text.

Q. When you need to edit a file by a system command (like crontab -e) how do you change the default editor that the system opens the file with to nano?
The system will use the editor defined in your EDITOR environment variable and can be set by export EDITOR=nano

Q. While using X, you encounter issues and cannot quit the X server, how can you force it to restart?
Linux has a solution for restarting X server with the combination of Alt-Ctrl-Backspace which will force X Restart.

Q. What would be the result of the key combination ALT +9 then pressing m?
This would print the letter iii times into your STDIN.

Q. Which TCP ports do you need to keep open for FTP, SSH, SMTP, POP3, HITP and H TIPS respectively?
For the mentioned services you will need to keep the following TCP ports free: 21, 22, 25,110, 80, 443.

Q. What is the difference between the commands ping and ping 6?
The commands ending with 6 – ping6, traceroute6. Tracepath6 have the same meaning, but are intended to use on ipv6 IP addresses.

Q. What does an open mail relay server means?
An Open mail relay server, means that this is a server that everyone can send emails through it without the need to identify first or be a part of the domain group.

Learn how to use Linux, from beginner basics to advanced techniques, with online video tutorials taught by industry experts. Enroll for Free Linux Training Demo!

Q. You want to find all of the “.tem” files in /home/* and delete them, how can you do it in a command?
First you need to find the files using find, then delete them using rm -find /home/ — name *tmp xargs rm —rf.

Q. How can you add an ‘auto correction’ that will automatically fix cd /homr” to cd /home”?
You can add the option cdspell to your shell options by typing “shopt -s cdspell”.

Q. How do you get additional information about a command – for example get information about mail?
If you want to learn about a command, you can use the commands man mail or info mail to learn more about mail.

Q. You are running a crontab command and doesnt want the command to send an output to the crontab serice, how can you handle it?
You can send all of the output from the command (STDOUT AND STDERR) to /dev/null – commnandName 2 >&1 >/dev/null

Q. How can you list the arp cache table of the current machine?
You can use the command arp to control and view the arp table.

Q. How can you eject your cdroni drive from the console?
In order to eject the cdrom drive, you can use the command eject.

Q. You see a process “./myApplication” with PID 44556, how can you know where was the file executed from?
You can identify the path where the PID was executed by running pwdx 44556 and you will get the command executing path as an output.

Q. You are doing an installation and want to record your commands and outputs for later review, how can you do that?
You can use the script application for this functionality – type script -a ;mysession.log and it will start recording your terminal to mvsession.log, when you want to exit, type exit.

Q. How can you get a view of the calendar of January 2004 on a Linux console?
You can get the view of month/year calendar with the command: cal 01 2004.

Q. You have 100 .txt files in a directory, you want to know in which file you have the string “Error Found”, how can you do it?
You will need to use the command grep” in order to find data in files – grep Error Found”.*txt

Q. What command is used to get the IP? Address (es) of the domain name in Linux?
In order to find the related IP Address(es) of the domain you can use “nslookup”

Q. What will be the outcome of the following command – touch -in my File?
If the file exists, it will only change the iizodfication time of the file, if the file doesn’t exist, it will create it.

Q. Given the directory myImportantFiles” how can you create a tar file myImportantTar.tar” containing this folder?
You need to use the tar command to create a tar file – tar -cfmylmportantTar.tar importantFiles.

Q. How caii you know. without checking the logs, which Kernel version is currently loaded to the system?
The unnamed tool allows you to get various system information – to get only the kernel data. You can use unnamed —rsv

Q. What is the equivalent of Norton commander” or ‘Windows Commander” for Linux console?
Linux provides the inc (Midnight Commander) tool to allow the user to have an interactive interface for file management in Linux Console.

Q. How call you change a password of a different user (john), when you have root access?
Using the passwd command with the destination username – passwd john

Q. How do you make sure that your computer date & time are always aligned?
You need to connect your server to an ntp server using ntpd, or run manually “ntptime”

Q. You have a tar file (mvFile.tar), how do you convert it to a gzip file on best compression?
If you need to compress the file on a best compression, you need to run the conunand “gzip -9 myFile.tar” and it will convert it to myFile.tar.gz.

Q. How can you disable cliii during runtime?
In order to disable a network card, for the current runtime , you can run the command
“ifdown eth1” or fconfig eth1 down”

Q. How can you get the current username that you are logged in with?
You can find the user that you are logged in with, using the commands “who am I” or “whoami’

Q. Using the apt-get application, how can you install gcc compiler?
The apt-get allows you to download and install new applications like gcc – apt-get install gcc

Q. How do you run the interiial bbre1ote_desJ(jop VNC application on Linux?
In order to run the vncserver daemon and connect to the server using a vncviewer on port 15000 + vnc instance number (15001,15002).

Q. How can you find all lines starting with the word Error” in the log file mylog.log”, with a single command?
The Linux command look allows you to find only lines beginning with the provided string – look Error iiiylog.log

Q. You have a file that you want to randomize its lines and create permutations of it for distinctive file list, how can you create a permutation of the file myfile” into “mynewfile’?
The Linux tool shuf allows you to create permutations of file and shuffle the lines, which will allow you to create new distinctive files – shuf myfile > mynewfile.

Learn how to use Linux, from beginner basics to advanced techniquesLearn Linux!

Q. You have moved a file from one server to another, but you are not sure that the file has been perfectly moved, how can you verify that the file has not been corrupted?
You can use the md5sum tool on both sides (both servers) on the file and match the result, if it is the same, the file has not been corrupted.

Q. How would you copy the file ‘file.txt” owned by root using secure ftp from On /root/ to your local folder in one command?
You need to use the scp tool (secure copy over sftp) which allows copying in one line scp root@ txt ./

Q. How will you change all the ownership of/home/useri to user2 (recursively)?
You need to use the chown command on the directory – chown user2:user2 /home/user1 —R.

Q. How can you check how long is the system running since the last restart amid the load average on it?
The uptime command can show you the current time, how long the system has been running since the last restart, how many users are currently logged on to the system, and the system load averages in the resolution of the last 1,5, and 15 minutes.

Q. How can you check what processes a specified user (torn) is currently running?
ps command will output the current processes of all or specific users – ps -U torn.

Q. How can you see all the rimning processes at the systern and their resources use on a live auto-refreshing view?
Top lets you see all the processes in the system and sort them by resources usage.

Q. What is the tool provided with gzip for decompression?
The gzip tool provides another tool gunzip for gzip files decompression.

Q. What command displays hardware related kernel messages?
command displays hardware related kernel messages is dmesg

Q. What command shows PCI card information?
PCI card information is Ispci

Q. What does the command ‘Ismod’ do?
Ismod is List currently loaded modules

Q. What does the command insmod do?
Insmod do Load an available module

    Check Out Linux Sample Resumes

Q. What is the device name for the first SATA drive on a server?
First SATA drive is /dev/sda

Q. What is the device name for the first IDE drive on a server?
first IDE drive server name is /dev/had

Q. Which two video card vendors require proprietary drivers for full hardware support?
two video card vendors are Nvidia/ATI

Q. Which device corresponds to the physical memory?
Corresponds physical memory is /dev/kmem

Q. Which damon checks the health status of hard drives?
Health status of hard drives is SMARTD

Q. What command will install the required drivers for a Realtek 8139 based network card?
insmod rt18139 or modprobe rtl8139

Q. What two values are needed in order to properly setup a monitor under X11?
hsync, vsync

Q. What is the maximum amount of addressable RAM that a 32-bit kernel will address?
Up to 64 GB, with PAE

Q. What is the most popular architecture, in use today?


Get Updates on Tech posts, Interview & Certification questions and training schedules