Friday, 26 April 2024

Top 50 Linux Interview Questions & Answers for Beginners

 Ques.1. What is UNIX?

Ans. UNIX is a multi-user, multi-tasking computer operating system developed at Bell Laboratories by Ken Thompson and Dennis Ritchie. It is proprietary software with its code not available to the general public.
The different variants of UNIX are HP Unix, Solaris Unix, IBM AIX and BSD.

Ques.2. What is Linux?
Ans. Linux is an open-source UNIX like operating system developed from scratch by Linus Torvalds. Although Linux is actually a different operating system since it is inspired by UNIX, the commands and syntax of UNIX and Linux programs are mostly similar.
Some of the Linux distributions are Ubuntu, RedHat, Fedora, etc.



Ques.3. What are some basic features of Linux?
Ans. Some of the features of Linux are-

  1. Multiuser – The multiuser feature of Linux provides it the ability to let multiple users access the same computer resources like memory, application programs, hard disk, etc at the same time.
  2. Multitasking – Multitasking allows multiple applications or programs to run simultaneously.
  3. Security – Linux provides security features by authentication(username-password for users), authorization(by providing read-write-execute permissions to different files), encryption(by encrypting files so that only the rightful owner can see the original content of the files).
  4. Portable – Linux supports portability with the ability of the OS to get installed on different hardware platforms.
  5. Open source – It is open-source with its code available to the general public.


Ques.4. What is the difference between UNIX and Linux?
Ans.

#UNIXLinux
1.UNIX is a proprietary operating system.Linux is an open-source operating system.
2.Different vendors of UNIX operating system has a different cost of the distributions.Most of the distributions of Linux are free distributed but also have paid distributions.
3.Distributions – HP Unix, Solaris Unix, IBM AIX and BSD etc.Distributions – Fedora, Ubuntu, Debian, Linux Mint, RedHat, etc.
4.It primarily uses the CLI – Command Line Interface.It provides both Graphical User Interface and Command Line Interface.



Ques.5. What is a Linux Loader or LILO?
Ans. Linux loader or LILO is a boot loader for Linux that loads the operating system into memory. Nowadays, it is considered more of a legacy application superseded by GRUB(Grand Unified Boot loader) and GRUB2 bootloaders.

Ques.6. What is Shell?
Ans. A shell is a program that acts as an interface between the user and operating system, allowing the user to execute commands e.g. Bourne shell(sh), bash(Bourne Again Shell), etc.



Ques.7. What is a swap space? What are its advantages?
Ans. Swap space is a piece of hard disk storage that is used when the system needs more memory but the RAM is full. In such cases, the inactive memory pages are moved to swap space to free RAM.

Ques.8. What is a process in Linux?
Ans. A process is an instance of a program under execution. In Linux, there are two kinds of processes-

  1. Foreground processes – A foreground process when initiated by a user runs in the foreground and the user has to wait for it to get completed before issuing any other command e.g. running any command on the terminal.
  2. Background processes – A background process runs on the background and the user can execute other commands also even before the background process gets executed completely. Adding ‘&’ after any command makes it a background process. Also, a background process can be brought to the foreground using ‘fg’ command with jobId of the background job.

Ques.9. How can we list all the processes running on a machine?
Ans. Using Top utility, we can list all the running processes. Running ‘top’, lists important attributes of the process like PID(process id), user/userId, parent process id, virtual memory used, physical memory used, process status, CPU utilization, process start time, command initiating the process, etc.

Ques.10. How can we stop or terminate a running process in Linux?
Ans. Kill command is used to terminate a running process in Linux. There are two variants of killing a process-

  • Kill PId – This will generate a signal SIGTERM, specifying graceful termination of the process with process id – PId
  • Kill -9 PId – This will generate a signal SIGKILL specifying forceful termination of the process with process id – PId



Ques.11. What is the use of ‘ps’ command? How is it different from the top command?
Ans. Ps stands for Process Status. It gives information about the running processes.

#To display information about the process with PId - 12
ps -p 12
#To display all process
ps -ef

It is different from top command in the sense that top displays continuous interactive usage of the processes in real-time. Whereas, ps displays a single snapshot of the processes and is more likely to be used for non-interactive usage in scripts.

Ques.12. What is a daemon?
Ans. Daemons are the processes that run in background either at a predefined time or in the event of a trigger. As a convention, daemon names in Linux end with the letter – ‘d’.

Ques.13. What is the use of man command?
Ans. The man command is used to know the usage of a command, config file or daemon using the man pages or user manual. Usage-

man ls

Output – Displays the manual page for ls command.

Ques.14. How to print the current working directory in Linux?
Ans. Pwd command is used to display the current directory (Print Working Directory)-

$ pwd
/c/Users/Kuldeep



Ques.15. How to create a directory in Linux and give full permission to it?
Ans. Using mkdir, we can create a directory and then with chmod we can give permissions.

mkdir directoryName
chmod 777 directoryName

Alternatively, we can also use ‘-m’ or mode option of ‘mkdir’ command and perform the operation in single command-

mkdir -m 777 directoryName



Ques.16. How to delete a non-empty directory?
Ans. On trying to delete a non-empty directory with ‘rmdir directoryName’ command, we will get an error – “rmdir: failed to remove ‘newFolder’: Directory not empty”.
For removing a non-empty directory, we need to use the ‘-r’ option of ‘rm’ command that recursively deletes the directory and its contents.

rm -r directoryName



Ques.17. How to change directory in Linux? How to move to the parent directory, home directory, and previous directory?
Ans. Using cd command, we can change the directory in Linux. Usage-

cd directoryName

Move to the parent directory or one level up-

cd ..

Move to user’s home directory-

cd

Or

cd ~

Move to the previous directory-

cd -



Ques.18. What is a root directory?
Ans. Linux follows a hierarchical or tree-based file system. The root directory is the parent directory of the hierarchy that includes all the other directories. It is represented by a forward slash ‘/’.

Ques.19. What are absolute and relative paths?
Ans. Absolute path – Absolute path is the path of a file or directory from the root directory i.e. from ‘/’.
Relative path – Relative path is the path of a file or directory from the present working directory.

Ques.20. How to login as a different user in Linux?
Ans. ‘Su’ command is used to login as a different user in Linux. It stands for substitute user or switches user.

#Switch to user2
su user2
Password:
#Switch to root
su root
Password:



Ques.21. What is the root account?
Ans. The root account is the account or a user that has access to each file and directory in Linux. The root account is also known as the superuser. A root user can also have access to run any command including adding users, grant or revoke permissions, etc.

Ques.22. What are the different file ownerships in Linux?
Ans. Each file and directory in Linux can have following 3 owners-

  1. User – The user or owner permission class belongs to the user who created the file.
  2. Group – The group permission class belongs to the members of the file’s group.
  3. Other – User or other permission class refers to each user who has access to the file.



Ques.23. Explain the usage of ‘ls -ltr’ command?
Ans. ‘ls’ command is used to list the directory contents. The options ‘-ltr’ stands for-
‘l’ – Use long listing format
‘t’ – Sort by modification time, newest first
‘r’ – Reverse order while sorting
So, ‘ls -ltr’ will list the content of the directory in a long listing format sorted oldest first.

$ ls
ebooks.zip  imp.txt  Linux.png
$ ls -ltr
total 5072
-rw-r--r-- 1 Kuldeep 197121 5170843 Mar 30  2017 ebooks.zip
-rw-r--r-- 1 Kuldeep 197121    8695 Oct 28 14:06 Linux.png
-rw-r--r-- 1 Kuldeep 197121    6883 Dec 28 19:37 imp.txt



Ques.24. What is the significance of file extensions like .txt, .png, etc in Linux?
Ans. Unlike Windows, file extensions have no significance in Linux. Linux does not rely on the file extensions instead the file type is determined by some content in the file header.

Ques.25. Explain the usage of ‘file’ utility.
Ans. The file utility is used to determine the file type of a file.

$ file imp.txt
imp.txt: ASCII text, with very long lines, with CRLF line terminator
$ file Linux.png
Linux.png: PNG image data, 521 x 177, 8-bit colormap, non-interlaced


Ques.26. What is the purpose of the ‘touch’ command?
Ans. Touch command serves two purposes in Linux-

  1. With a new file name, touch is used to create an empty file .touch newFile
  2. For existing files or directories, touch will change the last access time to the current time.



Ques.27. What is the difference between ‘cp’ and ‘mv’ command?
Ans. The ‘cp’ command is used to copy the content of one file to another. Whereas, ‘mv’ command moves a file from one location to another, deleting the source file. ‘mv’ command is also used for renaming files. Usage-

#Copies content of file1 to file2
cp file1 file2
#Moves/renames file1 to file2
mv file1 file2



Ques.28. Explain the usage of ‘head’ and ‘tail’ commands.
Ans. Head command is used to display the first few lines(default 10) of a file. Whereas, the tail is used to display the last few lines(default 10) of a file. Usage-

#Display first 10 lines of a file
head fileA
#Display first 5 lines of a file
head -5 fileA
#Display last 10 lines of a file
tail fileA
#Display last 5 lines of a file
tail -5 fileA



Ques.29. What is ‘sed’ in Linux?
Ans. Sed stands for Stream Editor. It is used to edit a file or input from a pipeline. Example-

#Prints first 5 lines
sed -n 1,5p fileA.txt



Ques.30. How to print the content of line 5 to 10 from one file to another?
Ans. Using ‘sed’

#'p' to print and '-n' to not print each line
sed -n 5,10p fileA.txt > fileB.txt



Ques.31. What is ‘awk’?
Ans. AWK named after the initials of its authors “Aho, Weinberger, and Kernighan”, is an interpreted programming language for text processing. Usage-

#To display the content of file using awk
awk '{print}' fileA.txt



Ques.32. How to count the number of words, lines, and characters in a file?
Ans. Using wc command (word count)-

#Number of characters
wc -m fileA.txt
#Number of words
wc -w fileA.txt
#Number of lines
wc -l fileA.txt



Ques.33. How to combine the content of multiple files into a single file?
Ans. Using ‘cat’ and redirection-

#merging content of fileA and fileB into mergedFile
cat file1 file2 > mergedFile



Ques.34. What is the use of ‘tac’ command?
Ans. Tac command as the name suggests is the reverse of ‘cat’ command. It displays the content of the file in reverse order – line by line, displaying the last line first and moving up till the first line.

#Displays the content of fileA from the bottom line to top line
tac file!



Ques.35. What is the difference between ‘more’ and ‘less’ command?
Ans. Both more and less commands are used for viewing large files page wise. Unlike any editor like vi, using these commands for opening a file does not load the whole file in memory. One limitation of more command is, we can only scroll down but not up. Whereas, using less command, we can scroll both upwards and downwards in a file.


Ques.36. How can we find the top 3 space-consuming files or directories within a directory?
Ans. Using du(disk usage) command, we can find the disk usage of all directories and sub-directories. Using du with -a option, will list the disk usage of all files as well, along with the directories. The ‘-h’ option displays the size in a human-readable form. Later, we can use this command along with sort and head command, to first sort the files/directories by size and then fetch the required number of files.

#Sorts the files and directories within artOfTesting directory by size
du -h -a artOfTesting/ | sort -n -r | head -n 3



Ques.37. How to create aliases in Linux?
Ans. Aliases are used to create aliases or some abbreviated short-name for a command or a group of commands.

#Alias for some log directory
alias logs="cd /user/application/logs"



Ques.38. What is the use of shred utility? How it is different from the rm command?
Ans. Shred utility is used for deleting the content of a file in such a way that the content cannot be recovered using some data recovery tools/utilities. Whereas, when we delete a file using the rm command, the space taken by the file is marked available for other files, hence there is a possibility to recover the content of the file. Thus, shred is better for deleting files with sensitive data.

#Overwrites the content of the file to make it impossible to recover
shred file1



Ques.39. What is the difference between find and locate command?
Ans. Both find and locate commands that are used for searching files on Linux. The ‘find’ command searches file in real-time and thus take a longer time to return the search result in case there are too many files to scan through. Whereas, ‘locate’ command is much faster than find as instead of real-time search it looks up in a database – updatedb. Since the updatedb takes a snapshot of the file system only once a day output of locate is not always accurate or updated.

#Find all text files
find / *.txt
#Find all text files
locate "*.txt"



Ques.40. How can we introduce wait time in scripts?
Ans. Sleep command can be used to introduce wait time in scripts. We can specify wait in terms of seconds, minutes, hours and days.

#Wait for 5 seconds
sleep 5s
#Wait for 5 minutes
sleep 5m
#Wait for 5 hours
sleep 5h
#Wait for 5 days
sleep 5d



Ques.41. How to compress and decompress files in Linux?
Ans. Using ‘zip’ and ‘unzip’ commands, we can compress and decompress files in Linux.

#Creates a file zipFile.zip with fileA and fileB compressed
zip zipFile fileA fileB
#Unzips zipFile.zip
unzip zipFile.zip



Ques.42. What are the different file permissions or access modes in Linux?
Ans. Each file and directory in Linux can have following 3 permissions, represented by a three-digit octal number-

  1. Read – Provides the ability to read the content of a file (represented by ‘r’ in first position – “r–“)
  2. Write – Provides the ability to edit or delete the content of a file (represented by ‘r’ in second position – “-w-“)
  3. Execute – Provides the ability to execute or run a file (represented by ‘x’ in third position – “–x”)



Ques.43. Explain the meaning of the permission mode “drwxr-x–x”.
Ans. The 10 characters of permission mode provide information about the permission to the user, group, and other users.

  • 1st character indicates whether the given thing is file or directory, ‘-‘ for file and ‘d’ for the directory.
  • Next 3 characters indicate the read-write-execute permission to the user or owner of the file.
  • Next 3 characters indicate the read-write-execute permission to the group belonging to the file.
  • Last 3 characters indicate the read-write-execute permission to all the other users.

So, the permission mode “drwxr-xr-x”, means a directory for which the user has all the read-write-execute permission, group has read and execute permission and other users can only execute the file.

Ques.44. How can we grant or remove access to a file in Linux?
Ans. The ‘chmod’ command is used to grant permission to a file or directory in Linux. There are two modes to grant or remove permission using chmod-

  1. Symbolic mode – With symbolic mode we can grant permission to a file using ‘+’ operator, remove permission using ‘-‘ operator, and set the required permission using ‘=’ operator.#Add read and execute permission to group chmod g+rx fileA #Remove execute permission to owner chmod u-x fileA #Set write and execute permission to other users chmod o = wx fileA
  2. Absolute mode – With absolute mode, an octal number a used to specify different permissions.#751 will grant permission 7 to owner, 5 to group and 1 to other users chmod 751 fileA

Ques.45. Explain the octal number representation for different permission types in Linux.
Ans. The absolute permission of chmod uses an octal number. The different octal numbers for different permission types are-

Octal numberPermission granted
0No permission (—) i.e. 0+0+0=0
1Execute (–x) i.e. 0+0+1=1
2Write (-w-) i.e. 0+2+0=2
3Write and execute (-wx) i.e. 0+2+1=3
4Read (r–) i.e. 4+0+0=4
5Read and execute (r-x) i.e. 4+0+1=5
6Read and write (rw-) i.e. 4+2+0=6
7Read, write and execute (rwx) i.e. 4+2+1=7



Ques.46. How can we change ownership and group ownership of a file in Linux?
Ans. The ‘chown’ command (change owner) is used to change the ownership of a file.

chown userK fileA

The ‘chgrp’ command is used to change the group ownership of a file.

chgrp group fileA



Ques.47. How to sort the contents of a file?
Ans. Sort command can be used to sort the elements of a file line-wise.

#File content - kuldeep, abc, 1India, zed each in separate line 
sort file

Output-

1India
abc
kuldeep
zed



Ques.48. How can we remove the duplicates in a file?
Ans. Using ‘uniq’ utility with ‘sort’ command.

#File content - bat, all, cat, cat, all, cat each in separate line 
sort fileWithDuplicateContent | uniq

Output-

all
bat
cat



Ques.49. What are soft links in Linux? What is its advantage over the cp command?
Ans. Soft links are also known as symbolic links or symlinks. These are used to create symbolic links or pointers to a file. In Linux, soft links are created using the ‘ln’ command with the ‘-s’ option.

#Creates a soft link 'fileA' to the file 'fileA.txt'
#'-s' option to create a soft link
ln -s fileA.txt fileA

It has got an advantage over the cp command (which creates a new copy of the file) in the sense that in order to change the permission to the files, with links only the permission of the original file need to be changed. Whereas, with the cp command, the permission to all the copies of the file needs to be changed.

Ques.50. What are the hard links in Linux? How it is different from a soft link?
Ans. Hard links are like another name for an existing file. Instead of pointing to a name(like a soft link), hard links point to the content of the file directly(point to inode – a table containing metadata about a file).

Top 30 Red Hat Linux System Administrator Interview Questions & Answers

 

1. What do you mean by Linux? 

Answer: Linux s one of the most widely used operating systems, developed based on Linux Kernel. As this is an open-source OS and can use on various hardware platforms. Those who are looking for low-cost and free OS, then this one is the best. It comes with a user-friendly interface, and users can customize the source code as per their requirements. 

2. What do you mean by Red Hat Enterprise Linux? 

Answer: This is one type of Linux/ GNU distribution developed by Red Hat, a multinational open-source software provider. 

3. How to verify the uptime of a Linux server?

Answer: For this, you can use the uptime command. It can show you the duration of how long the Linux box is running. Besides, w and top command can verify the uptime. 

4. What do you mean by Red Hat Network? 

Answer: Red Hat Network is a platform, especially a system management platform which provides the users with effective lifecycle management of different applications and operating system. It helps in: 

  • Installing as well as provision new Linux systems. 
  • Configuration file management. 
  • Updating systems.
  • Performance monitoring.
  • Redeploying the systems for satellite and hosted deployment architectures.

Don’t forget to cover this question while preparing for Red Hat Linux System Administrator interview questions and answers.

5. How can one change the user password? 

Answer: The users to change the password, can use the command “passwd.” While executing the command through the terminal, the users need to put the current password. After that, put the new password. The process is quite easy. 

Also Read: How to Prepare for Red Hat Certified System Administrator (RHCSA) Exam?

6. How can a user rename a file in Red Hat Linux?

Answer: To rename the file, you need first to open the shell command line of Red Hat Linux. There you need to use the “mv command.” Then the command will take to the original file and the newly named file. You need to check the parameters before renaming the files. However, if you forget to mention the parameters, then the command will notify you to put those. 

7. Can you explain the objectives of Red Hat Linux?

Answer: The users who know everything about Red Hat Linux can use the Red Hat Enterprise Linux for customization of the operating environment. Besides, it also helps in completing some basic command-line tasks as well as productivity roles related to the desktop. 

8. Can you explain the functionality of a Puppet Server? 

Answer: Yes. In general, this is an enterprise application and perfect for configuration management. A puppet server is for Unix like OS. Explaining in detail, this a completely open-source and fully automated program. Using this, one can send the configurations to puppet agents through codes. Some essential tasks such as updating user accounts, verifying permissions of the file, new software installation, and others and can be carried out using the puppet code. 

9. How to know what the version of the Red Hat is? 

Answer: For this, the users can use the command “cat /etc/Redhat-release.” You will get the output that will show the version. 

10. What is the command to install Rpm packages? 

Answer: To install Rpm packages in CentOS and Red Hat, you can use yum and rpm command lines. 

Preparing for Linux interview? Here’re the top 60 Linux interview questions with detailed answers to crack the interview!

11. Which command can be used to determine the Linux box’s hostname? 

The hostname command helps in determining the hostname of the server. 

12. Explain in short about the storage cluster? 

Answer: This is one of the most commonly asked Red Hat Linux System Administrator interview questions that you will face during your job interview. Talking about the cluster, here multiple computers combined together to carry out some tasks. Some major types of clusters are high performance, load balancing, high availability, and storage.

The storage cluster helps in providing the perfect view of the file system in the servers in the group. It dramatically improves the servers to write and read at the same time to a shared file system. Besides, storage simplifies the storage administration by effectively limiting the patching and application installation process. 

13. Can you explain the difference between umask and ulimit?

Answer: In general, ulimit is a Linux built-in command which offers excellent control over available resources to start the process. The users, if want, can limit the range by customizing the limits.conf files. Besides, the users can update the system settings by editing the sysctl.conf file. Now talking about umask, it defines the use file creation mask. When the users create a directory and file, umask sets the permission for the directories and files. 

Now, let’s look next Red Hat Linux System Administrator interview questions. 

14. Elaborate about SELinux? 

Answer: Talking about SELinux, it is a Linux program with enhanced security features. SELinux keeps the server protected from compromise and misconfiguration. This is sued to access the control implementation for the Linux Kernel. It puts a limit and then instructs the servers to only access the particular files and security policies. 

15. While installing Apache, what is the web port used to serve web pages?

Answer: Well, most of the web servers operate on Port 80. So, while installing Apache, it automatically defaults to Port 80. However, users can use some alternative ports. But this will force them to type a port into a browser to get access to the website. You can also use Port 8080 for this. 

Linux Blogs are the good source to learn about the latest Linux news, updates, trends, strategies etc. Here is the list of 20 best Linux Blogs and websites!

16. Explain about rgmanager and CMA? 

Answer: This is one of the most complex Red Hat Linux System Administrator interview questions. So, while answering it, remember to tell transparently. In the Red Hat cluster, Cman works as a cluster manager, especially a distributed cluster manager. It operates in a cluster node. Talking about its functions, it effectively tacks the cluster quorum by observing the cluster nodes. Cman is responsible for a quorum, voting, communication, and monitoring between clusters. 

Coming to the rgmanager, it is a resource group manager. Rgmanager is responsible for collecting cluster resources defined as resource trees, resource groups, and services. This dramatically helps a Red Hat administrator to define, monitor, and configure the cluster services. When a node fails to work, it will locate that particular clustered service to other nodes without affecting the services. 

17. Explain the runs levels and how to alter them? 

Answer: In Linux, a run level is a stage of initialization that effectively defines what types of system services are functioning. They are generally defined by numbers. In general, there are a total of 7 run levels in the Linux system, and they serve a different purpose. They are:

  • Halt system (Sued to turn off the system)
  • Basis multi-user mode but there will be no NFS
  • Single users mode
  • Full multi-user mode (based on the text)
  • Multi-user mode (graphical UI)
  • Unused
  • Reboot system

Now talking about the process for changing the level, one needs to change the file – /etc/inittab. Alter the initdefault entry (id:5: initdefault:). If the users want to alter the run level on the fly, they can do it through the ‘init’ command. Let’s take an example. 

When a user types Init 3 in the command line, this will shift the system to run level 3 from run level. To list the current level, the users can use the command “Who -r.” 

18. Can you explain DAS? 

Answer: This is one of the common Red Hat Linux System Administrator interview questions that every employer asks. However, the answer is quite simple. It is, generally, a block device physically connected to the host machine. It comes with a filesystem. Only certain servers can access the device. You can find such storage devices, near-dedicated resources, and server storage. The DAS is inexpensive and easy to use. It covers SATA and SCSI technologies. 

19. Tell me about the load balancing cluster? 

Answer: As the name suggests, the load balancing cluster utilized to balance the load throughout the cluster nodes. It works when the cluster dispatches the service request to a different cluster node. This cluster offers inexpensive scalability as multiple nodes can be configured considering the load requirements. In this cluster, if a node is not working correctly, it will then detect the failure and then assign required requests to available nodes. Here the collapse of the node will not be visible outside the cluster. 

20. What do you mean by LVM? 

Answer: In Red Hat Linux, LVM refers to Logical Volume Mangere. It is the storage management solution that lets the Red Hat Linux System Administrators split the space of hard drive into PV- Physical Volumes. After that, PV is combined into VG- Volume Groups. The VG can be further divided into LV- Logical Volumes. 


21. Elaborate the process for creating LVM?

Answer: When talking about Red Hat Linux System Administrator interview questions, we can’t ignore this question. You need to elaborate it steps by steps. First, users need to create physical volumes. For this, they can use the command “pvcreate” (#pvcreate /dev/sda2). After establishing that, they need to add the physical volume to the volume group. Here “vgcreate” command can be used (#vgcreate VLG0 /dev/sda2). Now, from the volume group, create a logical volume. Use the “lvcreate” command (#lvcreate -L 1G -n LVM1 VLG0). In the last step, the users need to use the “mke2f” command to make a file system on Sda2 (#mke2fs -j /dev/VLG0/LVM1). 

22. Clearly explain the Indoes and their uses in Red Hat Linux?

Answer: It refers to a data structure of a file system found in Unix like OS. It stores all the necessary information about the file. However, it doesn’t use the actual name. The inode helps in the process of recovering the files systems, which are damages. If there is any lost inode, you can locate it in “locate + found” directory. Remember that this question comes under the most frequently asked Red Hat Linux System Administrator interview questions. So, keep the answer in your mind. 

23. Tell us about SAN and NAS? 

Answer: In Red Hat Linux, NAS runs an embedded OS on the basic hardware, for example, keyboard and monitor. Its primary purpose is to verify the clients and offer to share with the multiple systems or users to a particular network that needs dedicated IP to work. On the other side, SAN is a perfect storage solution at the block-level. It is primarily developed to handle high volume data transfer. In terms of performance and capacity, this is perfectly scalable. 

24. Elaborate about sgid and suid terms? 

Answer: Talking about suid, it offers the same level of ownership permissions while a user executes a file. Coming to the sgid, it comes with a group of privileges of a completed file. It inherits the ownerships while developing the directory. 

25. Can you tell me about the bootloader? Give us a short description.

Answer: One of the easiest Red Hat Linux System Administrator interview questions in the interview. The answer is very simple. Just tell the recruiter that bootloader boots the operating system. Besides, it takes the decision about the kernel from which the operating system will boot.

26. Do you know what is “parted” Command? If yes, then tell why it is used? 

Answer: In Red Hat Linux, parted is a popular command, or you can say a tool that lets the users manage the hard disk partitions easily. This can help you in deleting, adding, extending, and shrinking hard disk partitions and file systems. However, with time it has gone through several changes. Some of its old features are now replaced with new ones.

Aspired to become Red Hat Certified Engineer? Here we bring the comprehensive Red Hat Certified Engineer exam preparation guide, that will help you prepare and pass the certification exam.

27. What do you mean by Crontab? Can you explain the fields of the Crontab? 

Answer: In the Red Hat Linux system, the cron executes the commands at specific times and dates in Linux. So, this greatly helps in scheduling the activities and quite useful for recurring works. The Crontab helps in uninstalling and installing the tables used to drive the cron. Here are some command lines for Crontab. 

  • Crontab -e Edit your crontab file.
  • Crontab -l Show your crontab file.
  • Crontab -r Remove your crontab file.

While searching for Red Hat Linux System Administrator interview questions, this question will definitely come in the list. 

28. What kind of remote software users can use to encrypt communication?

Answer: One can use SSH, reliable remote desktop software that can help the users to control the Red Hat server remotely. It can be controlled through certain commands. Besides, SSH also effectively encrypts the data. This software uses port 22. 

29. How will you create a partition of 100MB and mount it?  

Answer:

  • Use the command “partprobe” and then mkfs -t ext3 /dev/hda?
  • First, to create a new partition, the users need to use fdisk /dev/had.
  • Now, for the new partition, type “n.”
  • Then, the users need to select between primary or logical partition. There, press “1” to go for a logical partition. 
  • It will then ask to choose the starting cylinder type. Keep it default by pressing “Enter.” 
  • Now, the users need to put the size. Put +100M then press “P” for verification of the partition list and name.
  • To write the partition on the partitions table, press “W.” 

Such types of Red Hat Linux System Administrator interview questions are quite common. While answering it, don’t skip any steps. So, remember each step. 

30. Can you elaborate on the process states in Unix? 

Answer: In Unix, the processes execute the changes states considering the ongoing circumstances. However, the states in Unix are: 

  • Waiting: It suggests the process is waiting for the resources or an event. 
  • Running: Here, the process is in running states, or it may suggest the process is all set to work. 
  • Stopped: The Unix process has been stopped. They stop functioning after getting a signal. 
  • Zombie: It suggests, the Unix process is dead. However, it is still there in the process table. 

Top 20 Linux Interview Questions and Answers 2024

 

  1. How to remove file and directories?

rm  file1 file2

rmdir dir1 (only deletes empty directories)

rm –r dir1 dir2

  1.  How to change from one directory to other?

cd dir1

  1. How to find logs older than seven days and remove them?

find /path/ -type f -mtime +7 -name ‘*.gz’ -execdir rm — ‘{}’ \;

Details:

find: the UNIX command for finding files/directories/links etc.

/path/: the directory path where you are searching for old logs

-type f: specifying to check only for files.

-name ‘*.gz’: will find for the files that end with “.gz”.

-mtime +7: only consider the ones with modification time older than 7 days.

-execdir … \;: for each such result found, execute the following command.

rm — ‘{}’: remove the file; the {} part is where the output from previous command will be given as input.

  1. What is cron job and how to set it?

cron is a kind of a daemon that executes scripts or programs at specific time intervals.

These commands are called cron jobs.

This is like a scheduler for system admins and developers. Many use cases are present for which we can set cron jobs like log rotation,

emailing users to trigger any update for automatic data backup at any specified timings.

find the standard cron job writing style:- 

* * * * * script1

please find the details below for all the description for every *:-

# +—————- minute (0 – 59)

# |  +————- hour (0 – 23)

# |  |  +———- day of month (1 – 31)

# |  |  |  +——- month (1 – 12)

# |  |  |  |  +—- day of week (0 – 6) (Sunday=0)

# |  |  |  |  |

  *  *  *  *  *  command to be executed

if you want to save the output of the cron job, you can execute the below command.

Timing   Execute Path to script                   Output

* * * * * /usr/bin/scripts /var/www/html/crontest/cron.sh > /dev/null 2>&1

  1. How to copy the files in Linux?

cp command

we can use cp command to copy any data from the current directory to a different directory. 

For example:-the command cp test.txt /home/users/files would create a copy of test.txt at “/home/users/files”

  1. How to move the files in Linux?

mv command

mv command can be used to move files from one folder to another; This is also used to rename the files.

This works as cp command only. We need to type mv, the file’s name, and the destination’s directory. 

For example: mv file.txt /home/users/Docs.

  1. What is sudo command?

sudo stands for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions. 

However, it is not recommended to use sudo command because most of the tasks would be performed as a particular user.

  1. Which command is used to check disk space and disk usage?

df command

df command is used to check the disk space, shown in percentage and KBs. 

If you want to see the report in megabytes, type df -m.

du command

this is used to check Disk Usage. 

However, the disk usage summary will show disk block numbers instead of the usual size format. 

If you want to see it in bytes, kilobytes, and megabytes, add the -h argument to the command line.

  1. How to check first few and last few lines of any linux file?

The head command is used to view the first lines of any text file. By default, it will show the first ten lines, 

but you can change this number to your liking. 

For example, if you only want to show the first five lines.

head -n 5 filename.ext.

tail command

This one has a similar function to the head command, but instead of showing the first lines, 

the tail command will display the last ten lines of a text file. 

tail -n filename.ext.

10. How to check the difference between two Linux files?

diff command

the diff command compares the contents of two files line by line. 

After analyzing the files, it will output the lines that do not match. 

Programmers often use this command when they need to make program alterations instead of rewriting the entire source code.The simplest form of this command

       diff file1.ext file2.ext

11  Which command is used to archive files in Linux?

The tar command is the most used command to archive multiple files into a tarball — a common Linux file format that is similar to zip format, 

with compression being optional.

12 How to kill a process?

If a process becomes unresponsive and you wish to kill that process. Get the pid of that process and kill using the below command.

Kill Sign option file1

Kill -9 file   ( 9 forces programs to stop immediately)

you also need to know the process identification number (PID) of the program you want to kill. If you don’t know the PID, simply run the command ps ux.

13 How to check connectivity of any linux  server?

Use the ping command to check your connectivity status to a server. 

For example, by simply entering ping example.com, 

the command will check whether you’re able to connect to the server and measure the response time.

14 How to download the file using CLI?

wget command is used to download the files from the internet.

15 How to check the OS version in Linux?

The “uname” command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel etc.