50 Multiple Choice Questions (MCQ) on Linux

Overview of Linux Operating System

Linux is a widely used independent portable operating system that provides a variety of features including virtual memory, shared library, memory management, TCP/IP networking, and commercial OS support. It is composed of a collection of software based on the Linux Kernel known as Linux distribution.

Features of Linux

  • Multi-user operating system
  • Multitasking open source wisdom
  • Highly secure operating system
  • Freely distributed or downloadable
  • Portable operating system that can be used with Spark Alpha processor
  • Virtual memory provided by swap in and swap out technique

Linux Kernel

The kernel forms the core of the Linux-based operating system, virtualizes computer hardware resources, and provides virtual resources to each process. The Linux kernel is responsible for preventing conflicts between processes. There are four types of kernels such as Monolithic kernel, Hybrid kernel, Exo kernel, and Microkernel.

System Library and Shell

The system library includes different functions to implement operating system functionality. The shell acts as an interface and interacts with the user and kernel functions to execute the commands provided by the user.

Hardware Layer

The hardware layer consists of peripheral devices like RAM, HDD, CPU, etc.

Advantages of Linux

  • Open-source operating system with available source code
  • More secure than other operating systems
  • Large community support
  • High stability with no frequent need to reboot the system
  • Network friendly
  • Offers privacy to the user

Linux MCQs

There are no MCQs provided in this context.

Counting lines, words, and characters in a file using the command 'wc'

In Unix-based operating systems, the command 'wc' is used to count the total number of lines, words, and characters present in a file.

command: wc file_name

Here, 'file_name' is the name of the file whose lines, words, and characters needs to be counted.

For example:

wc myfile.txt

This command will return the total number of lines, words, and characters present in myfile.txt file.

Note that 'wc' stands for 'word count' but it also counts the total number of lines and characters in a file.

Command to Remove Files in Linux

In Linux, the command used to remove files is "rm". This command stands for "remove". It is used to delete files or directories from the file system. Using this command without proper caution can lead to data loss or system corruption. Therefore, it's important to be careful while using this command.

To remove a file using the "rm" command, the syntax is:

rm file_name

This will remove the specified file from the file system. If the file is write-protected or is a directory, you will be prompted for confirmation before it is removed.

In summary, the "rm" command is the correct option for removing files in Linux.

Identifying Unsupported Hardware Structure in Red Hat

To determine the hardware structure not supported by Red Hat, we need to analyze all the given options and know which one is incompatible and not functional in the said system.


Option A) IBM-compatible - Supported by Red Hat
Option B) Alpha - Not supported by Red Hat
Option C) SPARC - Supported by Red Hat
Option D) Macintosh - Not supported by Red Hat

From the above analysis, we can conclude that Option D) Macintosh is the hardware structure that is not supported by Red Hat.

Deleting a Single Character in vi Editor

In vi editor, to delete a single character, the command used is:

x

Therefore, option B is the correct answer.

TCP/IP Protocol for Remote Terminal Connection Service

In TCP/IP protocol, the TELNET is used for remote terminal connection service.

TELNET stands for "teletype network", and it is a protocol that allows a user to establish a remote terminal connection to another computer or device over a network.

Identifying the Service Used for Domain Name to IP Address Translation


// The answer is DNS (Domain Name System)

The DNS (Domain Name System) service is utilized to convert domain names into IP addresses. Therefore, when users enter a website address into their browser, the Domain Name System is what translates the domain name into an IP address that the browser can utilize to access the website and display its contents.

Other options listed, such as NIS (Network Information Service), NFS (Network File System), and SMB (Server Message Block), are network protocols employed for different purposes, and are not employed for translating domain names to IP addresses.

Adding a new user to the system

In Linux, there are multiple ways to add a new user to the system, some of which include:

  • Through the graphical user interface using tools like 'Linuxconf'
  • Using the 'adduser' command in the terminal
  • Using the 'useradd' command in the terminal

Therefore, the correct answer is D) All of the above.

Example:

To add a new user 'john' using the 'adduser' command:

sudo adduser john

The system will then prompt you to create a password and provide additional information about the user.

Determining the Total Number of Primary Partitions on a Drive

The maximum number of primary partitions that can exist on a single drive is four, as per the guidelines set by the Windows operating system.

Code:


int totalPrimaryPartitions = 4;

Here, the variable

totalPrimaryPartitions

stores the maximum number of primary partitions that can be created on a single drive, which is equal to 4.

What is FSF?

FSF stands for Free Software Foundation.

The Free Software Foundation (FSF) is a non-profit organization that advocates for the importance of free software and works to promote the use and development of free software for the benefit of all users.

Free software refers to software that enables users to run, share, and modify the software without any restrictions. This is different from proprietary software, which is controlled by the software's creators and often restricts users in how they can use and access the software.

Command to Remove Files in Windows

In Windows, the command used to remove directories is

rmdir

. This is known as the "remove directory" command.

To delete a file, you can use the

del

or

erase

command in Command Prompt.

Example:

rmdir /s foldername

will remove the directory along with all the subdirectories within it.

Creating Linux File Systems with mkfs Command

In the Linux operating system, the command used to create file systems is `mkfs`. This command helps to create different types of file systems by formatting partitions.

To create a file system with `mkfs`, first, you need to specify the device or partition on which you want to create the file system. For example, to create an ext4 file system on the `/dev/sda1` partition, the command would be:


mkfs.ext4 /dev/sda1

This command will create an ext4 file system on the `sda1` partition. You can use other options with `mkfs` command based on the type of file system you want to create and your specific requirements.

In summary, `mkfs` command is used to create Linux file systems and offers a variety of options to customize the file system creation according to your specific needs.

Identifying Non-Communication Command

In the given options,

grep

is not a communication command.

A communication command is a command that is used to send messages or communicate with other users on the system. The

mail

,

mesg

, and

write

commands are all examples of communication commands.

On the other hand,

grep

is a command-line utility for searching plain-text data sets for lines that match a regular expression pattern. It is not used for communication.

Code:
python
# No code provided as it is a theoretical question with an answer

Backing up Typing Errors in vi Editor

In vi editor, the "#" symbol is used to backup over typing errors. This will move the cursor back to the last character on the current line, enabling you to correct typing mistakes.

Example: typing error in vi editor
hello wrld #notice the typing error
Using # to backup and correct the typing error
hello world #corrected typing error using #

Command to Add Printing Jobs to the Queue

The command used to add printing jobs to the queue is

lpr

.

Server used with BIND package

The server used with the BIND package is called named.


  # Example configuration file for a BIND DNS server
  options {
      directory "/var/named";
      // Add any necessary options here
  };
  zone "example.com" {
      type master;
      file "/var/named/example.com.zone";
      // Add any necessary options here
  };

In the above configuration file, you can see that the server is referred to as "named" within the options block.

Default Port for Squid

The default port that Squid listens to is 3128.


# Sample Squid configuration file
http_port 3128

This can be modified in the Squid configuration file if necessary.

Displaying Octal Values with od Command

To display the octal value of text in Linux, you can use the "od" command. The "od" command stands for "octal dump" and it is used to display the octal values of binary data.

The correct command to display octal value of the text is:

od

Optionally, you can combine "od" with other options to specify the formatting of the output. For example, the "-c" option can be used to display the octal values as characters:

od -c

This will display the octal values in the left column and the corresponding characters in the right column.

Understanding GNU

In the world of computers, GNU is a commonly heard term, especially among software developers. GNU refers to an operating system that is free and open-source. Created by Richard Stallman, this system is known for its Unix-like features, which led to a misconception that GNU stands for "General Unix." However, the actual expansion of GNU is "GNU's Not Unix."

 // No code to optimize or add comments as it is not applicable for this type of content.


Core of Linux Operating System

The core of the Linux operating system is comprised of a kernel.

// Example code showcasing how to access the kernel in Linux using system calls
#include <linux/kernel.h>
#include <sys/syscall.h>
#include <unistd.h>
int main() {
long int var = syscall(SYS_getpid);
printf("The current process ID is: %ld", var);
return 0;
}

The above code uses the system call SYS_getpid to access the current process ID, which is an example of directly interacting with the kernel in a Linux system.

Directory for Configuration Files in Linux

The configuration files in Linux are generally stored in the

/etc/

directory.

Checking Maximum File Size in Linux

The statement "The maximum file size in Linux is 255 bytes" is false.

The maximum file size in Linux depends on the file system used. In the ext2 and ext3 file systems, the maximum file size is 2 terabytes. In the ext4 file system, the maximum file size is even higher, up to 16 terabytes.

Therefore, the statement is false because the maximum file size in Linux is not limited to 255 bytes.

Code:
bash
# Check file system type
df -T /

# Output example:
# Filesystem     Type     1K-blocks     Used Available Use% Mounted on
# /dev/sda1      ext4      30720000 10916520  18007616  38% /

You can check the file system type of your Linux system using the

df -T /

command in the terminal.

Identifying Operating Systems that are not based on Linux

The Linux operating system has many distributions based on it, but there are other operating systems that are not derived from Linux. One of the operating systems that are not based on Linux is BSD.

Here are the options:

- Ubuntu: Based on Debian and Linux kernel - BSD: Not based on Linux - CentOS: Based on Red Hat Enterprise Linux and Linux kernel - Red Hat: Based on Linux kernel

Therefore, the correct answer is B) BSD.

Recording Sessions in Linux

To record sessions in Linux, you can use the "script" command. This command will create a typescript file where all your terminal sessions will be recorded. You can use the following command syntax:

script [options] [file]

For example, to start recording a session in a file called "session.txt", you can run:

script session.txt

To stop recording the session, you can press "Ctrl+d" or run the "exit" command.

So, the correct answer to the given question is option C - "Both a and b are used to record session in Linux."

Where is the user password stored?

The user password is stored in

/etc/passwd

.

Default File System Type in Linux

In Linux, the default file system type is ext3.

The options B, C, and D are not the default file system types of Linux.

<br>if (defaultFileSystemType == "ext3") {<br>
      console.log("Default file system type is ext3");<br>
} else {<br>
      console.log("Invalid file system type");<br>
}


Displaying Operating System Name using uname command

In order to display the name of the operating system, you can use the "uname" command in the terminal. This command works in Linux, Unix, and macOS systems.

uname

The above command will output the name of the operating system.

It is important to note that you can also use "uname" with various options to display additional information about the operating system, such as:

  • -a: Displays all information
  • -s: Displays the kernel name
  • -n: Displays the hostname
  • -r: Displays the kernel release
  • -m: Displays the machine architecture

Here's an example:

uname -a

This command will display all available information about the operating system, including the version number, release date, and architecture.

Printing a File using lp Command in Linux

In Linux, the lp command is commonly used to print files. The correct option from the given list to answer the question "Which command is used to print a file" is C) lp.

The syntax for using the lp command to print a file is as follows:


lp [options] filename

Here, `[options]` is optional and can be used to specify various options for printing.

For example, to print a file named "example.txt", you can use the following command:


lp example.txt

This will send the file to the default printer configured on your system.

You can also specify options to change printer settings, set the number of copies, select a specific printer, and more. To learn more about the lp command and its options, you can use the man pages by typing the following command in the terminal:


man lp

Overall, the lp command is a useful tool for printing files in Linux systems.

Viewing File Inode Number Using the ls Command

To view the inode number of a file using the ls command, you need to use the -i option. So, the correct answer is option B, "-i".

The ls command is used to list the files and directories in a file system. The -i option displays the inode number of the files along with other information such as file permissions, owner, group, size, and creation/modification timestamps.

Here's the syntax to use the ls command with the -i option:


ls -i filename

This command will list the inode number of the file "filename".

For example, to view the inode number of a file named "file.txt", you can use the following command:


ls -i file.txt

This command will display the inode number of the file "file.txt" on the terminal.

Viewing Hidden Files in Linux

In Linux, hidden files are those files whose name starts with a dot(.). By default, these files are not listed in the directory by the ls command. However, we can view them by using the following command:

ls -a

This command lists all the files including the hidden files. Here, the "-a" option stands for all files, including hidden files. By using this option, we can view all the files in the directory.

So, the correct answer is B) ls -a is used to view hidden files.

Representing User Home Directory

In Unix-based systems, the tilde symbol (~) is used to represent the home directory of the current user. It can also be used to represent the home directories of other users by appending the other user's username after the tilde symbol, such as ~username.

// Example usage
String homeDirectory = System.getProperty("user.home");
System.out.println("Home directory: " + homeDirectory);

The above code retrieves the home directory of the current user and prints it to the console.

Setting Terminal IO Characteristics with "stty" Command

The "stty" command is used to set terminal IO characteristics in the Linux terminal. This command allows users to configure various parameters related to the terminal input and output.

For example, one can use the "stty" command to set the baud rate, stop and start bits, and other settings for a serial port.

Optionally, one can include the "ioctl" function calls in a C program to customize the terminal IO characteristics.

Therefore, the correct answer is option B) stty.

Displaying Unix Version using Command

In Unix, the "uname" command is used to display information about the system. The option "-r" prints the kernel release for the current system. Therefore, the correct command to display the version of Unix installed on a system is:

uname -r

This will give the kernel release number, which can be used to determine the version of Unix installed.

Note: The "-t" option prints the system type (ex: GNU/Linux), and the "-n" option prints the network node hostname.

Directory Type

It is true that a directory is a type of file.

true


Identifying the Top-Level Directory

In Unix/Linux systems, the top-level directory is represented by a forward slash (/) character. This character is used as a delimiter to separate different directories and subdirectories in the file system hierarchy.

Therefore, the correct answer to the given question is D) /.

Example:

To access the top-level directory in the terminal, simply type the following command:

cd /

This will take you to the root directory, which contains all of the files and directories in the file system.

Responsibilities of Dialogue Control and Token Management in Network Layer

The dialogue control and token management have responsibilities in the Network layer of the OSI model. They are responsible for ensuring that the communication between two devices is synchronized and efficient. This is done through the management of tokens that allow devices to take turns transmitting data.

In other words, Dialogue Control is responsible for regulating the communication flow of data packets between two devices, while Token Management is responsible for handling the access of devices to a shared communication channel.

Therefore, the correct answer is D) The dialogue control and token management are responsible for the Network layer.

Main Apache Configuration File

The main configuration file for Apache is located at

/etc/httpd/conf/httpd.conf

.

It is essential to locate and modify this file to customize the Apache web server and configure the settings for your website or web application.

Identifying Services Running on an NFS Server

To check the services running on an NFS server, you can use the command serverinfo. This command helps to list all the running services of an NFS server.

Alternatively, you can also use the command rpcinfo to check the status of the remote procedure call (RPC) on the NFS server. The RPC service is responsible for communication between the NFS client and server.

Therefore, the correct option would be A) serverinfo to view the services running in the NFS server.

Sorting Lines of Data in a File using the 'sort' Command

The correct command to sort the lines of data in a file in alphabetical order is

sort

. The option

-r

is used to sort the lines in reverse order. Here's an example:

sort filename.txt

This will sort the lines in the file "filename.txt" in alphabetical order. If you want to sort the lines in reverse order, use the following command:

sort -r filename.txt

It's important to note that the

sort

command will sort the lines based on the first character of each line. If you want to sort the lines based on a specific field, you need to specify the field delimiter using the

-t

option.

Which Layer Performs Routing?

In networking, routing refers to the process of selecting the best path for data packets to travel from their source to their destination. In which layer routing is done?

The correct answer is network layer, not session layer as stated in the given sentence.


Routing is performed by network layer.


Types of Installations Requiring a Special Boot Disk

In order to perform an installation via FTP, NFS or using a PCMCIA-based system, a special boot disk is needed. Therefore, the correct answer is D) All of the above require a special boot disk.


// No code to optimize or refactor for this prompt

Understanding RPM

RPM stands for Red Hat Package Manager. It is a powerful command-line package management system used in various Linux distributions. RPM is used to manage and install software packages in a Linux system. It allows for easy installation, upgrading, and removal of packages from the system.

Script for Setting Global Defaults for Users

The script that is run for setting global defaults for users is

/etc/profile

.

Founder of Linux Kernel

The founder of Linux Kernel is Linus Torvalds.

// Code not required for this question

Forcing Buffers to Disk using "sync"

To force all buffers to disk, the correct command is

sync

. This command causes all unwritten changes to file system metadata and cached file data to be written to the storage device. It's important to use this command before shutting down or rebooting the computer to prevent data loss or corruption.

Creating a Swap Partition using fdisk

In order to create a swap partition using fdisk, you should use Partition's system ID type 82.

Here is an example:

1. Open fdisk by typing sudo fdisk /dev/sda into the terminal. 
2. Press the n key to create a new partition. 
3. Choose the primary or extended partition type. 
4. Select the size of the partition. 
5. Choose partition ID type 82 for the swap partition. 
6. Press the w key to save the changes.


Change Working Directory with cd Command

The

cd

command is used to change the current working directory in the command line.

For example, if you want to change to the directory "Documents", you can use the following command:

cd Documents

This will change the working directory to "Documents".

What is LILO?

LILO is a bootloader for Linux operating systems. It stands for "Linux loader" and is responsible for loading the Linux kernel into memory to start the operating system.

LILO was one of the earliest bootloaders used in Linux, but it has largely been replaced by newer alternatives like GRUB (Grand Unified Bootloader).

Explanation:

NIS stands for Network Information Service, it is a directory service that is used for remote authentication of local network system users and also for configuration purposes such as password and group files. It was previously known as Yellow Pages.

Code:


// NIS stands for Network Information Service


Understanding OSS

In the tech industry, the acronym OSS stands for Open Source Software. This refers to software whose source code is openly available for anyone to view, modify, and distribute. This collaborative development model allows for greater innovation, flexibility, and transparency in software development.

It is important to note that OSS is different from proprietary software, which is controlled and owned by a single company or entity. OSS allows developers from all over the world to work together to create, improve, and maintain software, resulting in a robust and constantly evolving codebase.

Examples of popular OSS include the Linux operating system, the Apache web server, and the MySQL database management system.

Understanding OSS is important for anyone involved in software development or technology in general, as it represents a fundamental shift in how software is created and distributed.

Displaying and Creating Files using the Command Line

In Unix-based systems, there are several commands that can be used to display and create files. The most commonly used command is the

cat

command, which is used for displaying and creating files.

The syntax for displaying a file using the

cat

command:

cat filename

The syntax for creating a new file using the

cat

command:

cat > filename

Other commands that can be used for creating and editing files include:

  • vi
  • ed
  • nano
  • pico

However, these commands are more complex and are generally used by more experienced users.

Therefore, if you're new to the command line, it's recommended to start with the

cat

command.

Technical Interview Guides

Here are guides for technical interviews, categorized from introductory to advanced levels.

View All

Best MCQ

As part of their written examination, numerous tech companies necessitate candidates to complete multiple-choice questions (MCQs) assessing their technical aptitude.

View MCQ's
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.