본문 바로가기

OS/Linux

[Theorem] Owner/Permissions

1. What is Owner?

Owner refers to a person who uses a computer system in a computing environment. Users should attempt to authenticate for purposes such as security, login history, and resource management. When attempting to authenticate, the user must have an account and user name, and use the user interface to access the system and process authentication.

 

There are many users connected to one network. In order to separate users and ensure the integrity of the computer, the conept of a user has been used. Each user has its own permissions.

 

1.1 Check Owner 

There are several ways to check the user. The whoami command outputs a simple user.

 

user@host: /home$ whoami

 

The id command outputs information about different users.

 

user@host: /home$ id
  • uid : uid is an abbreviation for User Id, which is a unique number for each user and is the same as the user in the command prompt.
  • gid : gid is an abbreviation for Group Id to which the uid belongs
  • sudo : In Unix and Unix-like operations systems, programs that allow other users to run program with security privileges, usually as a superuser.

 

1.2 Change Owner

The chown command change owner of file and directory.

 

user@host: /home$ chown [new_owner][:new_group] /home/dir1/file1

 

2. Permissions

Permissions refer to a set of actions that a user may perform. Therefore, it prevents users from manipulating and changing other users' directories and files. Privileges are defined for the following three users.

 

  1. Permissions for the Owner
  2. Permissions for the Owner group
  3. Permissions for Everyone

 

These users have their own file access mode, which defines the rwx(read mode, write mode, execute mode). The following characters such as '-r-xr--r--' result of ls -l correspond to the file access mode. Depending on what file access mode each user group has, it can prevent other users from accessing or allow only reading.

 

The file system forms a hierarchical directory structure. For this reason, even if the subdirectory has 'rwxrwxrwx' file access mode, other users cannot access the subdirectory if the parent directory has 'rwxrwx---' file access mode.

 

2.1 Change Permissions

The chmod command used for changing permissions of file and directories.

 

user@host: /home$ chmod [ugoa][+-=][rwx] /home/dir1/file1
  • [ugoa] : Each option defines a user, group, other, or all user.
  • [+-=] : Define whether to add, remove, or change file access modes.
  • [rwx] : Define read mode, write mode, execute mode.