Linux Interview5
Linux Interview5
Kernel type
It uses a microkernel.
File system
Kernel: Linux kernel is a core part of the operating system that works as a bridge
between hardware and software.
Shell: Shell is an interface between a kernel and a user.
GUI: Offers different way to interact with the system, known as the graphical user
interface (GUI).
Application programs: It is designed to perform a bundle of tasks through a bundle
of functions.
System Utilities: It is the software functions through which users manage the
system.
6. Elaborate all the file permission in Linux.
There are three types of file permissions in Linux:
8. Explain LILO
LILO, i.e., Linux Loader and is a Linux Boot loader. It loads the Linux operating
system into memory and starts the execution. Most operating systems like Windows
and macOS come with a bootloader. While in Linux, you need to install a separate
boot loader, and LILO is one of the Linux boot loaders.
csh (C Shell): This shell offers job control and spell checking and is similar to C
syntax.]
ksh (Korn Shell): A high-level shell for programming languages.
ssh (Z Shell): This shell has a unique nature, such as closing comments, startup
files, file name generating, and observing logout/login watching.
bash (Bourne Again Shell): This is the default shell for Linux.
Fish (Friendly Interactive Shell): This shell provides auto-suggestion, web-based
configuration, etc.
10. What is a root account?
The root is like the user’s name or system administrator account in Linux. The root
account provides complete system control, which an ordinary user cannot do.
13. What is the difference between hard links and soft links?
Here is the table that shows the difference between soft links and hard links:
Hard Links
Soft Links
Every change in this link reflects its hard link and the actual file directly.
For mounting:
First, identify the partition through the fdisk -l command. You can also use the
lsblk command for it.
After identifying the partition, create the directory which will work as the mount
point. For example, running the mkdir /mnt/mountpnt will create the mountpnt
directory as the mount point.
Finally, you can run sudo mount <partition> <mount_point_directory> to complete the
mounting.
For Unmounting:
Once you check if the specific filesystem is in use, you can run the `sudo umount
<mount_point_directory>` for unmounting. If you want to learn more about the mount
command in Linux, check out this brief guide.
First of all, please check if the internet connection option is on and also check
the cables to find if there is any issue with it.
Please check that your network is configured correctly and the network interface
has your IP address. You can check it by running the ip addr or ifconfig commands.
You can also run the ip route command to check if the default gateway is set
properly.
Finally, verify the DNS server configuration in the /etc/resolv.conf file.
Check the Firewall:
Sometimes, firewall rules block the internet connection for the system’s security.
Hence, you can run the ufw or iptables command to modify the firewall rules.
Network Interface:
You can restart your network interface through the ifup and ifdown commands. Once
you restart the network interface, please reboot the system to make changes
successful.
18. How do you list all the processes running in Linux?
You can list the currently running process in Linux through various commands such
as:
ps Command:
The ps command displays brief information about the running processes. You can use
the ps -f or ps -f command because the -f option shows the full-format result, and
the -e option displays all processes. Moreover, you can use the ps auxf command to
get a detailed list of processes.
The top command displays the real-time details about the system process and the
complete resource usage.
The htop command is the improved version of the top command because it displays the
color-coded list with additional features such as sorting, filtering, sorting, etc.
19. What is the chmod command in Linux, and how do you use it?
You can use the chmod command to change the file permissions of the directories. It
offers a simple way to control the read and write permissions. For instance, if you
want to change the permission of the ABC.sh script and give it the write and
executable permission, you can run the below command:
df Command:
The df or disk-free command shows the used and the available disk space. You can
use the additional options to check disk space differently. For instance, you can
use the df -h command to check the disk usage in the human-readable format.
du Command:
The du or disk usage command estimates and shows the disk space usage, so running
the du command with no option shows the disk usage of your current directory.
However, you can run the following command to check the disk usage of a specific
directory:
du -sh ~/<directory>
ncdu Command:
The NCurses Disk Usage, or ncdu command, displays more interactive disk usage.
Similar to the du command, the ncdu command also requires the path of the specific
directory to check its space.
pgrep Command:
The pgrep command shows the PID of a process through its name or other different
attributes. For example, you can find the PID of process_1 using the below command:
pgrep <process_1>
ps Command:
ps command not only displays the currently running process but also shows the
process’s PID. However, if you want to check the PID of a specific process, you can
combine the ps with the grep command:
ps -e | grep -i <process_1>
22. What is the rsync command, and how do you use this command for synchronization?
The rsync command is used to synchronize and transfer the files in Linux. It
synchronizes files between two local systems, directories, or a network. The basic
rsync command contains the following:
useradd Command:
Let’s create a username, “Ron,” and provide a password for accessing the system:
useradd Ron
passwd Ron
You can also explore the useradd command’s additional options to modify the new
user’s permissions and privileges.
adduser Command:
The adduser command is similar to the useradd command, so let’s create a username
“Shawn”:
adduser Shawn
passwd Shawn
24. How do you format a disk in Linux?
The mkfs or make file system command helps format the disk in the Linux system. All
you need to do is use the following method to format the disk:
First, run the lsblk command to list the available partitions and identify which
disk you want to format.
If the selected disk is mounted, then unmount it through the following command:
umount <partition>
Now, find the file system type of the disk, like EXT4, NTFS, or XFS. Once you are
done then, run one of the following commands according to the file system type:
mkfs.ext4 <partition>
mkfs.xfs <partition>
mkfs.ntfs <partition>
Finally, mount the disk again through the mount command after the successful
format. Moreover, please ensure that you have created a complete disk backup to
eliminate the chances of data loss.
passwd username
For example, let’s change the password of a user “Ron” through the below command:
passwd Ron
Once you run the command, the system will ask you to enter and confirm the new
password.
Comparison Factors
Process
Thread
Creation time
Dependency
It depends on other threads because they share some memory with other threads.
Resource
Termination time
27. What is the ulimit command, and how do you use it?
The ulimit command controls the resource limit for the user process. You can use
the ulimit command to set the limit on the system resource to prevent consuming the
higher resources. This command contains multiple options to set the limit. For
example, you can use the u option to set a maximum number of processes to 50:
ulimit -u 50
You can explore more options of the ulimit command by following this guide.
28. What is the find command, and how do you use it?
The find command searches for files based on different factors such as name, size,
permissions, etc. Here is the basic command:
RAID Level
Description
RAID 0
It is called striping, which allows you to split the data into multiple disks
without redundancy.
RAID 1
RAID 5
RAID 6
RAID 10
It combines RAID 0 and RAID 1 to generate the set of mirror disks to improve
performance and redundancy.
Therefore, you can use /proc file system in Linux to get information about the
system and modify the particular Kernel parameters at the runtime.
strace ls
Once you run the above command, the system will start tracing the list command and
show the system calls generated by it. Output from the above command includes
information like call name, argument, and return values.
Run the below command to display the current iptables rules, including policies,
chains, and other actions for the network:
iptables -L
The iptables configuration uses the predefined set of chains to process the network
packages at different stages. So you can define rules to these chains for
manipulating the network packets:
iptables -A <chain> <options> -j <target>
In the above command:
<chain>: Specifies the chain where you want to define a new rule.
<options>: Defines the conditions for the rule, like ports, protocols, etc.
-j <target>: Defines the target action when the packet matches the rule.
By default, iptables rules get automatically removed after the system reboot, but
you can use the following command to make the rules persistent:
Check the warning and error messages you get during the boot process because it can
help you diagnose the issues.
Check the boot logs to find the exact reason behind the boot error.
Open the GRUB bootloader and check the boot options to solve the booting problems.
Check the hardware connections like cables, RAM, cooling fan, etc.
If the system shows an error message related to the Kernel, try to boot it with the
older Kernel version from GRUB.
Identify the last changes you made in the system before the boot.
41. What is the init process in Linux?
The init or also called the initialization process is the first process that begins
during the system boot. It is responsible for initializing and processing the
system in its functional state. Hence, init works as the parent process because its
process ID is 1. Originally Linux systems used to have SysV init, but now it is
developed as the systemd init (an improved version of SysV).
You can use the LVM to create the logical volume for easy storage management
through various features like resizing, volume mirroring, and snapshots. LVM is a
powerful utility for disk management where you need dynamic storage allocations.
Factors
UDP
TCP
Connection-oriented
Usage
It is used where ordered data is delivered, and reliable data must be delivered.
Applications
46. What is the difference between absolute and relative paths in Linux?
Absolute path = It specifies the exact location of a file or directory from the
root directory (“/”). We will notice that they always start with a forward slash
(“/”).
For example: If we want to search `test` in a text file name “file.txt”. We use the
following command
For example: If we want to display the status of the Apache Web server. We use the
following command.