Linux Users & Permissions Linux supports multiple users on the same system. There are different tiers of users, including an admin type, which can make changes on other users and file permissions. Linux is designed from the ground up to prevent individual users from accessing areas of the file structure they shouldn’t access. Linux environment administrators have to define separate accounts and p ermissions to determine who can access specific files, directories, applications, and resources.
Types of Linux Users Admin or Non-admin? A Linux user is either an administrator or non-administrator. The administrator is a superuser (or root user) with full control over the entire system. With that in mind, it is important to ensure that only a very limited number of folks have read and write permissions on all the files in the entire system. In contrast, a non-administrator by default has limited (or no) access to certain system/configuration files.
Normal user A majority of the accounts will be non-administrators. These users can be divided into two subtypes: normal user or system user. Normal users are real people. The individual is given a user account for login and limited access to computer applications, files, and resources.
System user A system user is typically a non-human or computer-generated account. System users are created to run a specific program or process/daemon such as a web server or backup program. This type of “user” is limited in control and is assigned only enough access to manage its particular process.
Users and Groups in Linux On a Linux system, all users added are assigned a name, unique user identification (UID), group, and group identification (GID). When a user is initially created, a new UID and matching GID are assigned. UID and matching GID numbers are assigned based on the type of user: Administrator (root): UID and GID = 0 System user (computer-generated): UID and GID assigned from 1 to 999 Normal users (real people): UID and GID = 1000 or greater, incremented with every new user
File Permission in Linux If we use the command ls -l on a working directory, we will see directory/file permissions, user, group, filesize, creation date/time, and filename. In Linux , everything is based on file permissions. Each file or directory has an owner and a group (or groups) that usually has more permissions to read, write, or execute than users not in the owner or in the permission group.
Let’s break down the permissions line for file-1.txt from the screenshot: -rw-rw-r-- Note: the first character identifies the resource as either a directory ( d ) or file ( - ).
The following nine characters should actually be read as triplets: rw- for the file owner, rw- for the group(s) that have permission to the file, and r-- for all others. What do these symbols mean? read ( r ) = contents can be viewed but not edited, renamed, added, or deleted write ( w ) = contents can be viewed, edited, renamed, added, and deleted execute ( x ) = contents can run as a program or script ( - ) = permissions don’t apply So, the permissions shown for file-1.txt means that the owner can read and write, the group can read and write, and all others can only read.
Read-write-execute permissions can also be written as numbers, with each being a power of two. Each set of triplets can be expressed as the sum of the permissions that apply. For example, a file’s permission being 777 is equivalent to rwxrwxrwx , whereas a file’s permission being 755 is equivalent to rwxr-xr-x . Permission Number Letter read 4 r write 2 w execute 1 x