Part-5: Basic 10 Linux Interview Questions and Answers

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.

Q.1) What is a root user in Linux

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)

What is the value of root UID

UID 0 (zero) is reserved for the root user on Linux and Unix like operating system.

What is default umask value for root user

The default umask value for the root user is 022.

Q.2) What is normal user in Linux

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.

What is default umask value for non-root user

The default umask value for the non-root user is 002.

How to check the UID limit for normal users in Linux

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

Q.3) What is system user in Linux

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.

How to check the UID limit for system users in Linux

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

Q.4) What is sudo command in Linux

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).

Q.5) What is UID in Linux

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
  • The third field represents the UID and forth field represents the GID.

List of UIDs and their details:

  • UID 0 (zero) is reserved for the root.
  • UIDs 1–99 are reserved for other predefined accounts.
  • UID 100–500 are reserved by system for administrative and system accounts/groups.
  • UID 1000–60000 are reserved for users account.

How can I identify my UID on Linux?

You can identify your UID on a Linux system by running the ‘id’ command without additional parameters.

id

Q.6) What is GID in Linux

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:

  • GID 0 (zero) is reserved for the root group.
  • GID 1–99 are reserved for the system and application use.
  • GID 100+ allocated for the user’s group.

Q.7) What is group on Linux

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
  • Secondary group or Supplementary group

What is the primary group in Linux?

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.

What is the secondary group in Linux?

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.

Q.8) What is the symbol used for a root user and non-root user shell?

If you don’t know the difference between $ and #. Here are the details.

  • When you are signed in as, or acting as “root”, the shell prompt displays ‘#’ as the last character. The # hash is the default for root user.
  • When you are logged into the system as a regular user, the shell prompt displays ‘$’ as the last character. The $ dollar sign is the default for regular users.
  • In the C shell, the prompt ends with a percentage sign (%).

Q.9) What is umask in Linux

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:

umaskUser AccessGroup AccessOther
0000allallall
0002allallread, execute
0007allallnone
0022allread, executeread, execute
0027allread, executenone
0077allnonenone

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.

Q.10) What is Linux su command

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.

  • su – user : It sets the target user environment with HOME, SHELL, USER, LOGNAME and PATH.
  • su user: It preserves the current user environment.

Conclusion

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.

fosstechi

Recent Posts

How to List or Display all Cron Jobs in Linux

Cron is a command-line job scheduler available on Linux operating systems that allows users to…

1 year ago

How to Disable IPv6 on RHEL System

In computing, there are two types of IP addresses, IPv4 and IPv6. By default, IPv6…

1 year ago

How to View Contents of tar.gz File in Linux

A tarball is commonly known as a TAR file, short for tape archive, which is…

1 year ago

How to Create tar.gz File in Linux

A tar archive is a file that stores a collection of directories and files, also…

1 year ago

How to Identify LUN Mapped to VxVM Disk in Linux

On Linux, you can quickly find out how LUNs are mapped to the underlying OS…

1 year ago

How to List Available Package Updates in Ubuntu

Keeping your Ubuntu system up-to-date is critical to ensuring a system's stability and security. This…

1 year ago

This website uses cookies.