The Linux system is one of the most potent and fastest computer operating systems. Nearly 90% of the fastest computers worldwide have Linux OS installed. If you want to be hired as a Linux expert in a company, here are a few things that you must know and the interviewer can ask you. There are a wide variety of jobs available for people who are skilled in UNIX, as UNIX and its variants (such as Linux) are widely used in many different industries. The specific job responsibilities and requirements will vary depending on the organization and industry in which you work. We have listed the most frequently asked Linux interview questions and answers so that you can ace your next Linux interview.
UNIX is a widely-used and influential operating system that has shaped many of the computing technologies that are in use today, so learning about UNIX can provide a valuable foundation for understanding how computers and networks operate.
UNIX is also known for its strong emphasis on security and stability, which makes it a popular choice for use in servers and other critical systems. Additionally, many of the concepts and tools that were developed for UNIX have been widely adopted in other operating systems, so learning about UNIX through KnowledgeHut online programming certification can be useful even if you do not plan to use it directly.
This is a frequently asked question in UNIX interview questions.
The full form of UNIX is "UNiplexed Information and Computing Service". The name UNIX was originally intended to be a pun on the name "Multics", which was a project that was being developed at the same time as UNIX and was intended to be a more comprehensive operating system.
The "UNI" part of the name was intended to stand for "UNiplexed", to contrast with the "MULTI" in "Multics". "UNiplexed" refers to the fact that UNIX was designed to be used on a single computer, rather than a network of computers like Multics. The "X" in "UNIX" was originally a placeholder that was intended to indicate that the name was still under development, but it eventually became part of the official name of the operating system.", to contrast with the "MULTI" in "Multics". "UNiplexed" refers to the fact that Unix was designed to be used on a single computer, rather than a network of computers like Multics. The "X" in "Unix" was originally a placeholder that was intended to indicate that the name was still under development, but it eventually became part of the official name of the operating system.
UNIX is an operating system that was developed in the late 1960s, and it is written in the C programming language. However, UNIX is also designed to support other programming languages, such as Python, Perl, and Bourne Shell Scripting. Additionally, UNIX includes a set of tools and utilities that are written in various programming languages, so the "language of UNIX" is not just one specific programming language. Instead, UNIX is a platform that can support a wide range of programming languages.
Yes, Apple's operating system, macOS, is based on the UNIX operating system. Apple has incorporated many of the features and technologies that are found in UNIX into macOS, and as a result, macOS is sometimes referred to" as a "UNIX-like" operating system. Yes, Apple's operating system, macOS, is based on the Unix operating system. Apple has incorporated many of the features and technologies that are found in Unix into macOS, and as a result, macOS is sometimes referred to as a "Unix-like" operating system.
In addition to using UNIX as the foundation for macOS, Apple has also made significant contributions to the development of the UNIX operating system. For example, Apple has contributed code and technology to the open-source version of UNIX known as FreeBSD.
UNIX was developed in the late 1960s at AT&T's Bell Labs by a team of programmers led by Ken Thompson and Dennis Ritchie. Thompson and Ritchie were working on an operating system called Multics (Multiplexed Information and Computing Service), but they decided to create a new operating system that was simpler and more efficient. Unix was developed in the late 1960s at AT&T's Bell Labs by a team of programmers led by Ken Thompson and Dennis Ritchie. Thompson and Ritchie were working on an operating system called Multics (Multiplexed Information and Computing Service), but they decided to create a new operating system that was simpler and more efficient.
They named their new operating system UNIX, and it quickly became popular due to its portability and modular design. Over the years, UNIX has evolved and has been used as the foundation for many other operating systems, including Linux, macOS, and Android.
Expect to come across this popular question in Shell scripting interview questions.
Kernel is a master program that allows the user to control the computer resources. This section executes the resource allotment to different tasks and users.
Kernel is a central component of an OS that manages operations of hardware and computer. It helps manage the operations of memory and CPU time and is one of the most important components of an operating system.
Kernal act as a bridge between application and data processing performed at hardware level using inter-process communication. Kernel loads first in the memory ( when the operating system is loading) and stays in the memory till the operating system restarts. It is responsible for different tasks such as task management, memory management and disk management.
Kernel has a process table that contains a per process region table and also helps in loading an executable file in the memory. Some of the common objectives of Kernel are:
A must-know for anyone heading into a UNIX interview, this question is frequently asked in UNIX basic interview questions.
UNIX has a graphical user interface just like the Windows operating system, which makes it easy the navigation and a good supportive environment. The internal design view of this OS is called architecture. A general UNIX architecture comprises mainly four different layers: Kernel, Shell (system call interface) and User application libraries/tools, utilities.
A Kernel is called the core layer of an operating system that interacts with the system hardware. It provides API through the system calls to process the user's request. Kernel helps in signal handling, inter process communication, network services, file system services, synchronization, hardware monitoring and more. The kernel helps control the hardware of the computer and stays in the core of architecture. The system works as an interface between the kernel and other libraries. These libraries contain general functions and are at the top of the system calls.
Kernel: Kernel acts as a central core of the operating system that interacts with the hardware. The main functions of the Kernal are:
Shell: A shell is the interface between the kernel and the user. Users interact with the shell using different shell commands. A shell has two prime responsibilities like interpreting the commands given by the users and executing them using the Kernels, providing the programming ability to the users to write the shell commands for a shell script to do different tasks.
Commands: Some of the most important categories of commands used by the UNIX operating system are - ''sh'' - shell commands that provide a primary user interface. 'Utilities' forming the core toolkit of UNIX commands come with sub-categories like system utility supporting administrative tools and User utilities for environment management tools.
There are also few commands ( also mentioned in the UNIX Commands Interview questions) for general purpose applications like typesetting and document-formatting. There are some packages like Tex and Ghostscript, and provide support for the inter-system communications as well as inter-user communications. , and provide support for the inter-system communications as well as inter-user communications.
Single user operating system, also called a single-tasking operating system helps accessing the computer at the specific time. It allows permission to access the personal computer through the single user, but does support multiple profiles.
Single-user can also be used for doing official work and other environments, which means this supporting system doesn't need any memory protection, file protection and security system. The computer-based on this OS has a single processor that helps in executing the single program. Some of the features single-user operating system are:
Types of Single-user Operating Systems:
Single-User Single-Tasking: Single user operating systems allow a single user to execute the one program at one specific time. This OS is designed for wireless phones and two-way messaging.
Single User Multi-Tasking: This operating system allows single users to run multiple programs at the same time; single users can perform multiple tasks at the same time. This type of operating system is found in laptops and personal desktops. This single user multi-tasking can be cooperative and pre-emptive.
It's no surprise that this one pops up often in UNIX interview questions.
System Libraries are specialized programs or functions that allow system utilities or application programs to access the capabilities of Kernel. These libraries implement the functionalities of the operating systems and don't require permissions from kernel module code access. Libraries can be linked with another libraries and other object files to create executables. Libraries are of two types:
Static Libraries: To build a static library, you must compile all source files into .o files and then use the command ar to archive a library of .o files. You can also use man ar to check all the options, one set is described below:
For instance- ar cq libfoo.a *.o will create a new library ''libfoo.a from the .o files. You may also see the ar command in the makefile, which means you will use the makefile variable rather than the *.o.
Dynamic Libraries: Dynamic libraries work when the program runs not when the program is compiled. This helps decrease the size of the stored executables and allows new versions of the libraries to get linked to the run time. Creating a shared library is a two step process- first the source files should be compiled as sharable objects and for this you can use the -fPIC flag to g++, i.e. g++ -fPIC -o foo foo.cc
this will compile the foo.cc in the sharable foo.o.
To combine multiple sharable .o files into the shared library, you can use the following command:
Id -G*.o -o libfoo.so
This combines all the .o files into the one shared library called libfoo.so. The -o option specifies the output file, the -G option is to build the shared library.
UNIX Utilities is a well-defined set of commands used by portable shell scripts. It is also referred to as a command that performs operating-system-related tasks. Generally, system utilities are responsible for maintenance of computers and are used for supporting and enhancing the programs in the computer. Some of the most common examples of utilities are:
To find a file under the UNIX operating system, you need to use the ''find'' command. The Find command will search files and directories under the operating systems. You can also specify criteria for searching the files. If there are no criteria set, all the files will return to the current working directory.
Another way you can find the file is by using ''locate'' command. The locate command will find files by name; it will read the database prepared by the updatedb and will display the file name that is at least similar to the one pattern of the screen.
Here's the syntax to be followed:
A shell in UNIX is a collection of computer operating systems that let different users perform multiple tasks. A shell is a medium provider that helps interact with the kernel, which is a CLI ( Command Line Interface) to the UNIX system. The shell works by collecting the input from the users and executing the program based on their inputs and displaying the output after execution. A shell is of two types:
Bourne shell: If you are using this type of shell, the $ character is the default prompt. The Bourne shell is divided into following subcategories:
C-type shell: If you are using the C-type shell, the % character becomes the default prompt. Different types of C-type shells are:
Bourne shell is installed as /bin/sh on most versions of UNIX and this is why this shell is used for writing scripts that can be used on various versions of UNIX.
We need a UNIX shell because:
A common question in UNIX interview questions, don't miss this one.
Shell analyzes every line you type and makes the execution of the respective program, but it also has other responsibilities like:
Program execution: The shell is responsible for executing all programs that you request from your terminal. Every time you type in a line in the shell, it analyzes the line and identifies the other steps. Every line in the shell follows the same basic syntax:
The line that is typed with the shell is called the command line; the shell scans this line to identify which argument to pass to the program. The shell uses special characters to identify where the program starts and ends; these special characters are called Whitespace characters.
Variable and Filename Substitution: Just like any other programming language, you can assign values to the variable. Whenever you assign these variables to the command line, the shell substitutes the assigned value. The shell is also responsible for performing the filename substitution on the command line. It scans the command line to identify the filename substitution characters *, ?, or [...] before defining the file name.
Shell takes care of the input and output redirections on the command line and scans the command line to identify the occurrence of special characters like <, > or >>.
Just like the shell scans the command line to find special characters, it can also look for the pipe character |. For every such character it finds, the pipeline hookup connects the standard output from the command preceding the | with the standard one following the |. Later, it ran execution on both programs. This means, when you type:
who | wc -1
the shell automatically finds the pipe symbol that separates the who and wc. It connects the standard output to the input and executes both commands.
Shell also has certain commands that let you customize your environment. The environment includes a list of directories to be searched, home directory and the characters that shell displays to let you type in the command.
Interpreted Programming Language:
The shell comes with its own built-in interpreted programming language. This means that the shell analyzes every statement in the language and then executes it. Unlike C and FORTRAN, where the statements are compiled into the machine language before execution, programs developed in this are easy to debug and modify.
The command that can be used to print a file – Draft with 66 lines is
Syntax - pr – 160 draft
Note: The –I option states a specific length.
LD_Library_Path is widely known as an environment variable that users can utilize to debug a non-standard or a new library. In addition, users can also use it to recognize the directories that users need to search. The users can set the variable using the following command:
Syntax - setenv—LD_LIBRARY_PATH--$PATH
In UNIX LD_Library_Path is used to tell the dynamic link loader, which is a small program that starts your applications to identify where to look for the dynamic shared libraries. In this a colon (:) is used to separate the list of directories, which is checked even before the built-in search paths and conventional locations. Some of the most common uses of LD_Library_path are:
The users should disable "Finger Service" on the Linux Server as the remote user(s) can get crucial data using this command regarding the system.
some other applications that you may not need on your server are:
If you want to check the presently logged-in user on UNIX, you can use the whoami command as follows:
O/P - test (test as username). It gives the users a name utilizing which has been used for logging into the system.
Or you can use the following syntax:
To get the current user name, type:
Get the current user name and store in a shell variable called $u:
u="$USER" echo "User name $u"
To check all the logged-in users onto the UNIX Platform, you can insert the command - %who.
Also, following files keep all the login records on Linux and UNIX-like systems:
/var/run/utmp – Keeps and allows you to identify information about who is currently using the system. There may be more Linux and UNIX users currently using the system, because not all programs use utmp logging. In other words, poorly written apps, hidden programs, malware, and other bad stuff will not be useful to list logged in users.
/var/log/wtmp – Keeps records of all logins and logouts.
We simply cannot read these files using cat command/grep command/egrep command as file is in binary database format. Hence, we use the following commands to find currently logged in users in Linux and UNIX-like systems.
Linux Command To List Current Logged In Users
Using the command %pwd, we may determine where a user is located on the UNIX system.
This command will represent your current working directory.
For instance, check if the file you are working on is in the directory bin by simply typing the command line option -%pwd to pwd.
First, type the command %cp to copy the file.
Syntax: %cp file fileB (to copy the file within the same directory).
To Copy the file in different directories, enter the following command,
Syntax: %cp source/filename location (target location)
First, type the command %mv to move the file.
Syntax: %mv fileA fileB (to move the file within the same directory).
To Move the file to different directories, enter the following command,
Syntax: %mv source/filename location (target location)
To create a new file in UNIX and write to it, you can use the "echo" command and ">" operator. The echo command writes a specified message to the terminal, and ">" operator redirects the output of the echo command to a file.
Here is an example of how you can use these commands to create a new file called "newfile.txt" and write the message "Hello, world!" to it:
echo "Hello, world!"> newfile.txt
If the file "newfile.txt" already exists, the above command will overwrite the file with the new message. If you want to append the message to the end of the file instead of overwriting it, you can use ">>" operator instead of ">" operator. For example:
echo "Hello, world!" >> newfile.txt
This will add the message "Hello, world!" to the end of the file "newfile.txt", without overwriting any existing content.
Keep in mind that The "echo" command and ">" and ">>" operators are not specific to UNIX. They are also available on other operating systems, such as Linux and macOS.Keep in mind that The "echo" command and the ">" and ">>" operators are not specific to Unix. They are also available on other operating systems, such as Linux and macOS.
There are several commands that you can use to view the content in a file, including cat, more, less, tail, and head.
Usage – %cat filename
It will allow you to view all the content saved in a specific file. The command – CAT- combines and opens multiple data in a file.
The users are split into three different types:
Users will have three different access rights from a file point of view. I.e., Read, Write, then Execute.
With the ls command, one may view these permission privileges.
A simple way of changing a file's permission is using the SHMOD command.
Syntax: %chmod 777 filename
You can use the chmod command to set permissions in either of two modes:
UNIX platform includes two different wildcards, as explained below:
A wildcard is a symbol that takes the place of an unknown character or different characters. Some of the most commonly used wildcards are the (*) asterisk and (?) question mark.
The (*) asktrisk:
This wildcard represent the number of unknown characters; you can use it for searching files or documents which only have partial names. Let us say, you are looking for ''cheese'', you may get following results:
but, if you enter *cheese, you may get the following searches:
(?) The Questionmark:
The Questionmark shows one unknown character. You can use it when you have list of files with the same names. For instance, if you enter text?.txt as your search query, you may find these files:
One of the most frequently posed UNIX Shell scripting interview questions, be ready for it.
Users can compress a given file by entering a gzip command.
Syntax – %gzip filename
O/p. The file's size would have decreased significantly, and the file extension would now be text.txt.gz.
Users can decompress a given file by entering a gunzip command.
Syntax – %gunship filename
O/p. The file's size would have increased significantly, and the file extension would now be text.txt.
To check real-time logs and data in UNIX, users can utilize a tail command. This command will default showcase the last ten lines of the given file.
Usage – %tail test.log
If you want to monitor the latest updates in the log file, you can use the –f option to receive updates.
Usage – %tail –f test.log
LVM (Logical Volume Manager) is a disk partitioning system that allows for the creation, management, and resizing of logical disk volumes. It works by abstracting the physical storage devices, such as hard drives or SSDs, into logical storage pools called "volume groups". These volume groups can then be divided into smaller logical units called" "logical volumes", which can be used as if they were physical partitions.
One of the main benefits of LVM is that it allows for easy resizing of partitions. With traditional partitioning systems, resizing a partition typically requires backing up the data, deleting the partition, and then creating a new partition with the desired size. With LVM, you can resize logical volumes without having to delete them, and without having to take the system offline.
LVM also allows for the creation of snapshots, which are read-only copies of logical volumes. This can be useful for backups, or for testing and development purposes. It let you to use multiple physical storage devices as one large storage pool. This can be used to increase the storage capacity of your system, or to create a RAID-like setup for increased data redundancy.
Here are a few steps to shrink the LVM partition's size:
The maximum length (in bytes) of a UNIX Filename is 255 bytes. This filename does not include the pathname. So, the path name of total length can quickly suppress 255 characters.
A staple in UNIX interview questions and answers, be prepared to answer this one.
There are mainly two types of user modes in Linux,
This question is a regular feature in UNIX interview questions, be ready to tackle it.
Hard Links are defined as existing files in the Linux system. You can create limitless hard links for every file by entering the command - $ ln [original filename] [link name].
On the other hand, Soft Link is considered a symbolic link. In maximum cases, Soft Links act as a file that leads to another file. You can create soft links by entering the command – $ ln -s [original filename] [link name].
In a file system, a hard link is a directory entry that associates a name with a file on a file system. It is created using the ln command and allows multiple names to be associated with the same file. The file is not deleted until all hard links to it are removed.
A symbolic or soft link, on the other hand, is a special type of file that contains a reference to another file or directory. It is created using the ln -s command and allows you to create a link to a file or directory located in a different part of the file system. Unlike a hard link, a symbolic link does not contain the actual data of the target file, it simply points to it. If the target file is deleted or moved, the symbolic link will be broken.
In general, hard links are more efficient because they do not require the operating system to follow a link to find the target file. However, symbolic links offer more flexibility because they can be used to link to files and directories on other file systems or on remote servers.
On the Linux platform, there are three standard streams that are used to communicate with a program:
You can redirect these streams to or from files, or you can pipe them to other programs. This allows you to manipulate the data that is being sent to or received from a program.
Which Command Can Users Enter to Create a Tape Archive File of Home Directory and Send it to a Tape Device?
The command users can enter to create a tape archive file and send it to a tape device is tar -cvf /dev/tape /home.
The –xvf command is entered to extract a specific file from the archive.
Telnet is a network protocol that was commonly used in the past to provide a command-line interface for remotely managing a system over a network. It allows a user to log in to a remote system and execute commands as if they were sitting at the local console.
Although Telnet is still available on many systems, it is generally considered to be insecure because it transmits data, including passwords, in plaintext over the network. This makes it vulnerable to interception and abuse by attackers.
For this reason, it is generally recommended to use a secure alternative such as Secure Shell (SSH) for remote access to a Linux system. SSH encrypts all data transmitted over the network, including passwords, making it much more secure than Telnet.
Other alternatives to Telnet for remotely managing a Linux system include Remote Desktop Protocol (RDP) and Virtual Network Computing (VNC). These protocols allow you to remotely access the graphical user interface (GUI) of a system, rather than just the command-line interface.
In the Linux system, every directory and file has three different owner categories named User, Group, and Others. For these three owners, three different permissions are required as below:
This question is a regular feature in UNIX interview questions for experienced, be ready to tackle it.
The VI Editor is the most basic text editor tool that can be seen in the majority of Linux distributions. Here are some different types of VI Editor Modes:
Do you know which command is used for erasing all the files in the current directory and sub-directories?
Yes, rm-r* is used to erase all files from the current directories and subdirectories. You can use rm for deleting files, but with the ''-r'', you can delete all the files in the directories and subdirectories.
Expect to come across this popular question in UNIX basic interview questions.
A relative path is a file path that specifies the location of a file relative to the current working directory. For example, if the current working directory is /home/user/documents, a relative path to a file report.txt in the /home/user/documents/project1 directory would be project1/report.txt.
An absolute path, on the other hand, is a file path that specifies the location of a file relative to the root directory of the file system. The root directory is represented by a forward slash (/) and is the starting point for the entire file system.
An absolute path to the same file report.txt in the /home/user/documents/project1 directory would be /home/user/documents/project1/report.txt.
The main difference between relative and absolute paths is that an absolute path is independent of the current working directory, while a relative path is dependent on it. This means that if you change the current working directory, a relative path to a file will change, but the absolute path will remain the same.
In computing, a FIFO (First In, First Out) is a type of buffer or queue that stores a stream of data in which the first data that is added to the queue will be the first one to be removed. This is similar to a line at a grocery store, where the first person to get in line will be the first one to be served.
FIFO is often used to communicate between processes, where one process writes data to the FIFO and another process reads the data. Because the data is read in the same order that it was written, the FIFO ensures that the processes are synchronized and that the data is processed in the correct order.
In Linux and other UNIX-like operating systems, a FIFO is implemented as a special file type that has the same name as the FIFO and is created using the mkfifo command. Processes can then read from or write to the FIFO using standard file input/output functions.
In a UNIX-like operating system, a directory is a file that contains a list of other files and directories. Directories are used to organize and group files together, and can be nested within other directories to create a hierarchical file system.
The top-level directory in a UNIX-like system is the root directory, which is represented by a forward slash (/). All other directories and files in the system are contained within the root directory or one of its subdirectories.
Some common directories in a UNIX-like system include:
Also, you can use the ls command to list the contents of a directory, and the cd command to change the current working directory.
''-l'' command is used to list all the files and folders in alphabetical order.
A must-know for anyone heading into a UNIX interview, this question is frequently asked in UNIX interview questions.
Paging: Paging is a memory management technique that assigns the process to a non-contiguous address area. Paging is accomplished by dividing the RAM into different fixed-size sections called frames. A process's logical memory is further divided into identical fixed-size units called pages.
Paging is simply a memory management method that lets the system store and get data from the secondary storage to be used in RAM.
Swapping: Swapping is the memory management technique that removes inactive programs from the main memory of the computer. Swapping typically affect the performance and helps in executing large operations concurrently.
This is done to free up space in memory (also known as RAM) for other programs to use. It is used on systems with limited amounts of RAM to allow them to run programs that are larger than the available memory. When a program that is stored on the hard disk is needed, the OS will swap it into memory and execute it. When the program is no longer needed, the OS will swap it back out to the hard disk to make room for other programs.
The process of swapping can be slow, as accessing data from a hard disk or SSD is slower than accessing data from memory. This can cause a noticeable slowdown in the performance of the system, especially if a lot of swapping occurs.
To reduce the need for swapping, you can try to close unnecessary programs or increase the amount of available RAM on the system. On systems with a lot of RAM, swapping may not be necessary at all.
It's no surprise that this one pops up often in UNIX Shell scripting interview questions.
These are file management commands. These are used for:
$ chmod g+w testfile: changes permission for a user group to write.
$ chown sroy8091 testfile: changes the owner of testfile to sroy8091.
$ chgrp moderators testfile: changes a group of testfile to moderators.
nohup is a special command used to run a process in the background. This even works when a user logs off from the system. You can use it to create daemon processes or clean the script of logs.
In a UNIX-like operating system, a daemon is a background process that runs independently of the user's interaction with the system. Daemons perform a variety of functions, such as providing services to other programs, scheduling tasks, and collecting system data.
Unlike normal programs, daemons do not have a user interface and are not usually directly interacted with by the user. They run in the background and are typically started when the system boots up and continue to run until the system shuts down.
Some common examples of daemons include the sshd daemon, which provides secure remote access to the system, and the cron daemon, which is used to schedule tasks to run at specific times.
A filter is a program or function that processes input data and produces output data based on specific criteria. Filters are often used to modify or transform the data in some way, such as sorting it, searching for specific patterns, or converting it from one format to another.
In the context of a UNIX-like operating system, a filter is a command-line utility that reads data from standard input, processes it in some way, and writes the output to standard output. Filters can be used in combination with other commands using pipes (|), which allow the output of one command to be passed as the input to another.
For example, the grep command is a filter that searches for lines in its input that contain a specific pattern and writes the matching lines to standard output. You could use it to search for a specific word in a file like this:
grep "word" file.txt
You can also use the sort command to sort the lines of its input and the uniq command to remove duplicate lines. For example, to sort the lines of a file and remove duplicates, you could use the following command:
sort file.txt | uniq
There are many other filters available in a UNIX-like system, and you can also write your own custom filters using a programming language such as Python or C.
A common question in Shell scripting interview questions, don't miss this one.
MBR (Master Boot Record) is the boot sector of a hard disk or solid-state drive (SSD) in a computer. It is a small program that is stored in a specific location on the disk and is executed when the computer starts up.
The MBR is responsible for loading the operating system and transferring control to it. It contains a bootloader program that is responsible for loading the operating system kernel into memory and starting it. The MBR also stores a partition table that describes the layout of the disk's partitions and where they are located.
The MBR is usually created when a hard disk or SSD is formatted, and it is stored in the first sector of the disk. It is typically 512 bytes in size and is composed of three parts: the bootstrap code, the partition table, and the boot signature.
On modern systems that use the Unified Extensible Firmware Interface (UEFI) instead of the traditional BIOS, the MBR is replaced by the GUID Partition Table (GPT).
Following are the fundamental components of the file system:
One of the most frequently posed UNIX interview questions, be ready for it.
A staple in UNIX viva questions, be prepared to answer this one.
In the UNIX operating system, a "superblock" is a special block of data that is used to store important information about the file system. This information includes details about the size of the file system, the number of blocks it contains, the number of inodes (data structures used to store information about files and directories), and other important metadata.
The superblock is usually stored at a fixed location on the file system and is used by the operating system to locate and access other data structures and files on the file system. The superblock is a critical part of the UNIX file system, as it contains the information needed to mount the file system and make it accessible to users.
If the superblock is damaged or becomes corrupted, it can cause serious problems with the file system, including data loss and filesystem instability. Therefore, it is important to ensure that the superblock is protected and properly maintained. In some cases, it may be necessary to restore the superblock from a backup in order to repair a damaged file system.
There are basically two types of superblocks:
Some of most common manipulation commands I have read are:
kill() system call sends signals to any process which further takes suitable action according to the signal. It takes two arguments, first is PID, to which you want to send a signal and the signal you want to send is second. This method returns the following return values:
This question is a regular feature in UNIX commands for interview, be ready to tackle it.
In the UNIX operating system, the "mount" and "unmount" commands are used to attach and detach file systems from the file hierarchy. When you mount a file system, you are making it available for use on the system by attaching it to a directory (also known as a mount point) in the file hierarchy. Once a file system is mounted, you can access the files and directories on it as if they were part of the local file system.
The "mount" command is used to mount file systems, and it has the following syntax:
mount [-options] device mount_point
The "device" argument specifies the device that contains the file system to be mounted, and the "mount_point" argument specifies the directory where the file system will be attached.
The "unmount" command is used to detach a file system from the file hierarchy, and it has the following syntax:
The "mount_point" argument specifies the directory where the file system is currently attached.
Both the "mount" and "unmount" commands require superuser privileges to execute.
Zombie processes are those child processes that get finished before the parent process. So after finishing up, the process structure and address space are removed and freed back to the system but the entry in the process table still exists. To be able to get the status of the child process the parent calls wait(). In the interval between the child terminating and the parent calling wait(), the child is said to be a ''zombie''.
The "date" command is used to retrieve the current date.
sh-4.3$ more README.txt
This command is used to display the first part of the file README.txt which just fits on one screen.
A region is a continuous area of processes address space (text, data, and stack). Regions are shareable amongst the processes.
This is a frequently asked question in UNIX interview questions for experienced professionals.
In the UNIX operating system, the term "u-area" (also known as the user area or "user structure") refers to a data structure that is used to store information about a particular user or process.
The u-area typically contains information such as the user's ID, group ID, and other identifying information, as well as pointers to other data structures and resources associated with the user or process.
The u-area is used by the operating system to track and manage resources associated with a particular user or process, and is an important part of the UNIX system architecture. It is typically stored in memory and is accessed by the operating system kernel when performing various tasks related to user and process management.
When a file is created inside a directory, it accesses the two attributes, namely, file name and inode number. The file name is first mapped with Inode number and stored in the table and then this Inode number serves as a medium to access Inode. Thus, an inode can be defined as an entry created and set aside on a section of the disk for a file system. It serves as a data structure and nearly stores information that is required to be known about a file.
This information usually includes the following details;
Expect to come across this popular question in UNIX interview questions.
The Bourne shell (sh) is a command-line interpreter and programming language that is commonly used in the UNIX operating system. It was one of the first shells to be developed for UNIX, and it has served as the basis for many other shells that have been developed since. Some key features of the Bourne shell include:
Command substitution is the method that is performed when the commands that are enclosed in backquotes are processed by the shell. This process replaces the standard output and displays it on the command line.
Command substitution can perform the following tasks:
Here are some examples of command substitution using both methods:
Using the (backtick) character:
$ echo The current date is `date`
This command will execute the "date" command and substitute its output (the current date) into the "echo" command, resulting in output that looks like "The current date is Mon Jan 17 14:09:39 EST "2022""
Using the $(command) syntax:
$ echo The current date is $(date)
This command will execute the "date" command and substitute its output (the current date) into the" "echo" command, resulting in output that looks like "The current date is Mon Jan 17 14:09:39 EST "2022""
Another example is to use the command substitution to list the number of files in a directory
$ echo "There are $(ls -1 | wc -l) files in the current directory."
This command will execute the "ls -1" command which lists all files in the directory one per line, and then pipes the output to" "wc "-l" command which counts the number of lines, and substitute the output in the "echo" command, resulting in output that looks "like "There are 10 files in the current directory."
In the UNIX operating system, "piping" is a technique that allows the output of one command to be used as the input of another command. This is accomplished using the "pipe" operator, which is represented by the vertical bar character (|).
Here's an example of how piping works:
$ ls -l | grep ".txt"
In this example, the "ls" command is used to list the files in the current directory, and the output of this command is passed to the "grep" command using the pipe operator. The "grep" command searches the output of the "ls" command for lines that contain the string ".txt" and displays them to the user.
Piping is a powerful technique that allows users to chain together multiple commands and create complex command-line pipelines. It is often used in combination with other techniques such as input/output redirection and command substitution to create flexible and powerful command-line scripts and programs.
A must-know for anyone heading into a UNIX interview, this question is frequently asked in Shell scripting interview questions.
In the UNIX operating system, a "pid" (short for" "process "ID") is a unique numeric identifier that is assigned to every process that is created on the system. The pid is used to identify and track processes, and it is used by various system utilities and functions to operate on processes.
Each process on a UNIX system has a unique pid, which is automatically assigned by the operating system when the process is created. The pid of a process can be used to refer to the process in various contexts, such as when using the "kill" command to terminate a process or when using the" "ps" command to list processes on the system.
In addition to the pid, each process also has a "parent pid" (ppid), which is the pid of the process that created it. The ppid is used to track the process hierarchy on the system and can be used to identify the relationships between processes.
In the UNIX operating system, the "alias" mechanism is a feature that allows users to create short, user-defined names for frequently used commands. Aliases can be used to simplify complex commands, or to create custom commands that perform multiple tasks in a single command line.
To create an alias, you can use the "alias" command followed by the name of the alias and the command that it should execute. For example, to create an alias called" "ll" that executes the "ls -l" command, you could use the following command:
alias ll='ls -l'
Once the alias has been defined, you can use it just like any other command. For example, to list the files in the current directory in long format, you could use the following command:
Aliases are stored in the user's shell environment, and are available for use in any terminal window or shell session. They can be a useful tools for simplifying common tasks and streamlining workflows.
Here are some tips and tricks that may be useful for programmers for the UNIX operating system:
Here are some tips on UNIX basic commands for interview and how to prepare for the interview round:
Prepare to discuss your relevant experience: Be prepared to discuss any previous experience you have working with UNIX, including any projects you have worked on or challenges you have faced. You can start with the online Programming courses to know and read about UNIX Interview Questions.
In a UNIX interview, you can expect to be asked a variety of questions about your knowledge and experience working with the UNIX operating system. Some specific topics that you might be asked about include:
You can also expect to be asked UNIX commands interview questions about your problem-solving skills, communication abilities, and experience working in a team environment. It is important to be prepared to discuss these topics and to provide specific examples to illustrate your skills and experience.
Preparing for UNIX shell scripting interview questions is important because it allows you to showcase your skills, experience, and qualifications in the best possible light. It also helps you to be more confident and relaxed during the interview, which can improve your chances of making a good impression on the hiring manager. Here are a few reasons why you should prepare for interview questions:
Overall, preparing for UNIX interview questions is a great way to demonstrate your interest and commitment to the job and to increase your chances of getting the position. Hopefully, this article will help you prepare for your interview for the profile of Linux expert. These questions are not only for intermediate but also for highly experienced candidates appearing for the interview of Linux experts.