FREE 50 Linux Interview Questions and Answers for Beginner Level

Desclainer: Please note that the answers to these questions are correct to my knowledge. Please feel free to comment if you find any incorrect answers. Your feedback is most welcome.


 

  1. What does the ‘&&’ operator do in a command?

a. Runs the second command if the first one fails.

b. Runs the second command regardless of the first one.

c. Runs the second command only if the first one is successful.

 

Ans. Runs the second command only if the first one is successful.

 

  1. What does the ‘ps’ command do?

a. Shows process status.

b. Shows disk usage.

c. Shows CPU usage.

 

Ans. Shows process status.

 

  1. What is the command to list all the files in a directory, including hidden files?

a. ls -a 

b. ls -h 

c. ls -l 

 

Ans. ls -a

 

  1. What does the ‘df’ command do?

a. Shows disk usage.

b. Shows directory files.

c. Shows disk format.

 

Ans. Shows disk usage.

 

  1. What does the ‘whoami’ command do?

a. Display the current user.

b. Display the current directory.

c. Display the current date and time.

 

Ans. Display the current user.

 

  1. How do you check the disk usage of a directory?

a. du -sh 

b. df -h 

c. ls -lh 

 

Ans. du -sh

 

  1. What does the ‘chmod 777’ command do?

a. Changes file permissions to read, write, and execute for all.

b. Deletes the file.

c. Changes the owner of the file.

 

Ans. Changes file permissions to read, write, and execute for all.

  

  1. What is the command to find the process running on a particular port?

a. lsof -i :port 

b. ps -ef | grep port 

c. netstat -an | grep port 

 

Ans. lsof -i :port

 

  1. How do you check the OS version in Linux?

a. uname -r 

b. cat /etc/os-release 

c. lsb_release -a 

 

Ans. cat /etc/os-release

 

  1. What is the purpose of the ‘chown’ command?

a. Change file permissions.

b. Change file ownership.

c. Change file group.

 

Ans. Change file ownership.

 

  1. What is the command to check the kernel version?

a. uname -r 

b. cat /proc/version 

c. lsb_release -a 

 

Ans. uname -r

 

  1. How do you search for a specific string in files?

a. grep "string" * 

b. find / -name "string" 

c. ls | grep "string" 

 

Ans. grep "string" *

 

  1. How do you check CPU usage?

a. top 

b. ps -ef 

c. vmstat 

 

Ans. top

 

  1. How do you check memory usage in Lunux?

a. free -m 

b. df -h 

c. top 

 

Ans. free -m

 

  1. What does the ‘kill’ command do in Linux?

a. Stops a running process.

b. Starts a process.

c. Pauses a process.

 

Ans. Stops a running process.

 

  1. How do you check the IP address on Linux?

a. ifconfig 

b. ip addr show 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What is the command to check the history of commands used in the terminal?

a. history 

b. ! 

c. !! 

 

Ans. history

 

  1. What does the ‘crontab’ command do?

a. Schedules tasks.

b. Lists running tasks.

c. Kills tasks.

 

Ans. Schedules tasks.

 

  1. How do you change the hostname in Linux?

a. hostnamectl set-hostname new_hostname 

b. hostname new_hostname 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘tar’ command do?

a. Compresses files.

b. Extracts files.

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘ping’ command do?

a. Checks network connectivity.

b. Checks disk usage.

c. Checks CPU usage.

 

Ans. Checks network connectivity.

 

  1. How do you set a ‘cron’ job to run every hour?

a. 0 * * * * command 

b. * * * * * command 

c. 1 * * * * command 

 

Ans. 0 * * * * command

 

  1. What does the ‘ssh’ command do?

a. Securely connect to a remote server.

b. Show system hardware.

c. Show system software.

 

Ans. Securely connect to a remote server.

 

  1. How do you list all installed packages?

a. dpkg --list 

b. apt list --installed 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘wget’ command do?

a. Download files from the internet.

b. Upload files to the internet.

c. Watch files on the internet.

 

Ans. Download files from the internet.

 

  1. How do you redirect stdout to a file?

a. command > file 

b. command >> file 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the redirect operator >> file do?

a. Redirect the output to a file and delete the existing content.

b. Redirect the output to a file and Append it to the existing content.

c. Redirect only the error to the file

 

Ans. Redirect the output to a file and Append it to the existing content.


  1. How do you find the size of a directory?

a. du -sh directory 

b. df -h directory 

c. ls -lh directory 

 

Ans. du -sh directory

 

  1. What does the ‘find’ command do?

a. Find files and directories.

b. Find text in files.

c. Find installed packages.

 

Ans. Find files and directories.

 

  1. How do you check the number of cores in Linux?

a. nproc 

b. lscpu 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘cat’ command do?

a. Concatenate and display file content.

b. Change file attributes.

c. Copy files.

 

Ans. Concatenate and display file content.

 

  1. How do you check the system uptime?

a. uptime 

b. top 

c. ps -ef 

 

Ans. uptime

 

  1. What does the ‘touch’ command do?

a. Change file timestamps.

b. Create an empty file.

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. How do you check the available disk space?

a. df -h 

b. du -sh 

c. ls -lh 

 

Ans. df -h

 

  1. What does the ‘mv’ command do?

a. Move or rename files.

b. Copy files.

c. Delete files.

 

Ans. Move or rename files.

 

  1. How do you check the running processes?

a. ps -ef 

b. top 

c. vmstat 

 

Ans. ps -ef

 

  1. What does the ‘rm’ command do?

a. Remove files or directories.

b. Rename files or directories.

c. Read files or directories.

 

Ans. Remove files or directories.

 

  1. How do you check the system load average?

a. uptime 

b. top 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘cp’ command do?

a. Copy files or directories.

b. Change file permissions.

c. Change file ownership.

 

Ans. Copy files or directories.

 

  1. How do you check the open files by a process?

a. lsof -p pid 

b. ps -ef | grep pid 

c. top -p pid 

 

Ans. lsof -p pid

 

  1. What does the ‘pwd’ command do?

a. Print the current directory.

b. Print the disk usage.

c. Print the system load average.

 

Ans. Print the current directory.

 

  1. How do you change the file permissions?

a. chmod 

b. chown 

c. chgrp 

 

Ans. chmod

 

  1. What does the ‘ln’ command do?

a. Create a symbolic link to a file.

b. List the number of lines in a file.

c. Load a new kernel.

 

Ans. Create a symbolic link to a file.

 

  1. How do you display the top of a file?

a. head 

b. tail 

c. cat 

 

Ans. head

 

  1. What does the ‘man’ command do?

a. Manage files.

b. Display the manual page of a command.

c. Manipulate text in files.

 

Ans. Display the manual page of a command.

 

  1. How do you display the bottom of a file?

a. head 

b. tail 

c. cat 

 

Ans. tail

 

  1. What does the ‘less’ command do?

a. Display less information about a file.

b. Display the contents of a file with navigation.

c. Display the less important files.

 

Ans. Display the contents of a file with navigation.

 

  1. How do you display the environment variables?

a. env 

b. set 

c. Both Option 1 and 2.

 

Ans. Both Option 1 and 2.

 

  1. What does the ‘sort’ command do?

a. Sort the contents of a file.

b. Sort the files in a directory.

c. Sort the processes by CPU usage.

 

Ans. Sort the contents of a file.

 

  1. How do you count the number of lines, words, and characters in a file?

a. wc 

b. count 

c. calc 

 

Ans. wc

 

 

Your feedback is valuable. Please comment below for any feedback and suggestions. Hope this helped you! 

FREE 50 Linux Interview Questions and Answers for Beginner Level

Desclainer: Please note that the answers to these questions are correct to my knowledge. Please feel free to comment if you find any incorre...