In this article, we’ve included 5th set of 10 basic Linux Interview Questions and detailed answers that will help candidates prepare for the Linux interview and get the best job in the IT industry.
These Linux interview questions and answers will be useful for both freshers and experienced professionals at any level.
The root user (aka superuser) is the most privileged user on a Unix and Linux like operating systems, which is similar to an administrator in Windows.
It’s a special user account in Linux used for system administration and has access to all commands and files on a Linux system.
The root user can do many things such as read and write any files on the system, perform operations as any user, change system configuration, formatting and mounting disk, starting/stopping services, install and remove software, and upgrade the operating system.
id uid=0(root) gid=0(root) groups=0(root)
UID 0 (zero) is reserved for the root user on Linux and Unix like operating system.
The default umask value for the root user is 022.
Normal users are highly restricted users created by the root or another user with sudo privileges. It has its own home directory where the user can make any changes and each user has a numeric user identifier called UID.
Usually, a normal user account is intended for a specific limited tasks or routine tasks. It can only perform permitted tasks and can only access those authorized files and services.
The default umask value for the non-root user is 002.
For normal user account, the UID will be automatically selected from the ‘/etc/login.defs’ file depending on the ‘UID_MIN’ and ‘UID_MAX’ values. To check the UID_MIN and UID_MAX values on your Linux system, run:
grep -E '^UID_MIN|^UID_MAX' /etc/login.defs UID_MIN 1000 UID_MAX 60000
Typically system users are created when installing the operating system (OS) and new packages on the system, and these accounts are used by services to run processes and execute functions.
For instance, the Apache user will be created when installing the httpd package on the system. Similarly, all system users are created for different purposes when installing different packages and operating system.
System users will be created with no aging information, the UID will be automatically selected from the /etc/login.defs file depending on the SYS_UID_MIN (100) and SYS_UID_MAX (499) values.
grep -E '^SYS_UID_MIN|^SYS_UID_MAX' /etc/login.defs SYS_UID_MIN 100 SYS_UID_MAX 499
sudo stands for “super user do”, it’s one of the most important commands in Linux that allow normal user to temporarily run other administrative commands or tasks with elevated privileges.
If you prefix “sudo” with any Linux command, it will run that command with elevated privileges.
sudo access can be configured for users using the ‘/etc/sudoers’ file.
Enabling sudo access for a user, will accurately track the user activity and records everything in the message log (/var/log/message).
UID stands for ‘user identifier’, which is a number assigned to each Linux user on the system.
This UID is used to identify the user to the system and to determine which system resources the user can access. This is why the user ID must be unique.
By default, Linux systems automatically assign UIDs and GIDs to new user accounts in numerical order according to the UID pattern reservation.
On a Linux system, you can find the stored UID and GID in the ‘/etc/passwd’ file.
cat /etc/passwd linuxgeek:x:1000:100:linuxgeek:/home/linuxgeek:/bin/bash 2daygeek:x:1001:101:2daygeek:/home/2daygeek:/bin/bash linuxfaq:x:1002:102:linuxfaq:/home/linuxfaq:/bin/bash linuxtechnews:x:1003:103:linuxtechnews:/home/linuxtechnews:/bin/bash
List of UIDs and their details:
You can identify your UID on a Linux system by running the ‘id’ command without additional parameters.
id
GID stands for ‘group identifier’. Groups in Linux are defined by GIDs (group IDs), is a numeric value used to represent a specific group.
List of GIDs and their details:
In Linux, a group is a collection of users. The main purpose of groups is to define a set of privileges to the members of the group.They all can perform the particular operations but not others.
There are two types of default groups available in Linux. Each user should have exactly one primary group and any number of secondary groups.
Primary group is a group that is automatically added to the user during user account creation. It’s typically the name of the user. The primary group is applied to the user when performing any actions such as creating new files (or directories), modifying files, or executing commands, etc,. The user primary group information is stored in the /etc/passwd file.
id uid=1000(linuxgeek) gid=100(users) groups=100(users),456(vboxusers)
100(users)
is the primary group of linuxgeek user.Secondary group is known as Supplementary group. This allows a group members to perform a specific action, and users can belong to up to 15 secondary groups. For example, if you want to allow some users to run the Apache (httpd) service command, it will fit exactly.
id uid=1000(linuxgeek) gid=100(users) groups=100(users),456(vboxusers)
456(vboxusers)
is the secondary group of linuxgeek user.If you don’t know the difference between $ and #. Here are the details.
The umask shorthand for “user file-creation mode mask” is a four-digit octal number that Unix and Linux like operating system uses to determine the file permission for newly created files and directories.
The most common umask values are described in the below table:
umask | User Access | Group Access | Other |
---|---|---|---|
0000 | all | all | all |
0002 | all | all | read, execute |
0007 | all | all | none |
0022 | all | read, execute | read, execute |
0027 | all | read, execute | none |
0077 | all | none | none |
For file permission: You can simply subtract the umask from the base permissions to determine the final permission for file.
0666 - 0022 = 0644 0666 - default file-creation mode 0022 - umask value 0644 - final file permission value.
For directory permission:
0777 - 0022 = 0755 0777 - default file-creation mode 0022 - umask value 0755 - final directory permission value.
su (short form of “substitute” or “switch user”) command allows us to run commands with the privileges of another user.
su is the simplest way of switching over to root account which requires root password to use the ‘su’ command in Linux.
Also, you can use it to switch to any user account. For instance, to switch ‘linuxfaq’ user, you’ll be prompted to enter linuxfaq’s password.
su - linuxfaq
If you wondering what is the difference between ‘su – user’ and ‘su user’, here are the details.
In this guide, we’ve included the most frequently asked 5th set of 10 basic Linux Interview Questions and detailed answers for your reference purpose and we hope it will be very useful.
If you have any questions or feedback, feel free to comment below.
Cron is a command-line job scheduler available on Linux operating systems that allows users to…
In computing, there are two types of IP addresses, IPv4 and IPv6. By default, IPv6…
A tarball is commonly known as a TAR file, short for tape archive, which is…
A tar archive is a file that stores a collection of directories and files, also…
On Linux, you can quickly find out how LUNs are mapped to the underlying OS…
Keeping your Ubuntu system up-to-date is critical to ensuring a system's stability and security. This…
This website uses cookies.