Manage the default UNIX license with adduser and umask
Network administration - The most important point in the process of securing file-level confidentiality on UNIX systems is to limit the file access license to the extent possible without affecting the necessary tasks of the system, At the same time, it does not interfere with users accessing the file according to the necessary method.
In general, UNIX and LINUX system administrators need to ensure that the owner of a file (Owner) will have full control over the file and will not grant access to any user by default. Any other. Doing so will reduce the problems encountered when administering the system without having to perform more complicated tasks to automate the process of granting default licenses to new files.
Configure the default license of the home directory
First, the permissions for a user's home directory can be granted when that user is created with the adduser command. For example, in FreeBSD, we can grant initial licenses to a new user's home directory using the -M option with the adduser command. Therefore, if you want to create a user account with the home directory permissions set to 750 , we need to run the following command:
When the default license for a user's home directory is granted, that user's home directory will be inviolable whether browsing or viewing for all accounts without root privileges, except The account owns this directory and the accounts belong to the default group of that account. In addition, this default license will not allow deleting this home directory, even other accounts in the default group of licensed user accounts. Once the home directory has been created, we still need to automate the default licensing process for additional files created by that account.
Configure the default mask of the file license
File Creation Mask (FCM) can help automate file-level security policies by using a limited set of default file permissions when new files are created. The command is often used for FCM in UNIX and UNIX systems, umask (abbreviated from user mask). In POSIX-standard operating systems, every process has a user mask to limit the modes for the files it creates. The umask command will specify unauthorized permissions. UNIX-style systems also use the umask command to install the umask for a utility.
This command can be improved to affect any operating process in the context of a user login utility. We can apply this umask to every user account on a system by specifying an default umask in a default utility configuration file of the system. For example, in most Linux distributions, bash is the default utility, the bash configuration file will be / etc / profile or / etc / bashrc . For BSD Unix systems, the default utilities are part of the C utility group, such as csh and tcsh , and the configuration files of these utilities will be /etc/login.conf .
In FreeBSD, by default, the corresponding line in this configuration file will be:
A umask that is better suited for security purposes will be umask that helps to block license group certificates valued at more than 750, configured in the etc / login.conf file by changing the value of umask to:
Default license policy
The default license policy (Default Permission Policy) applied to each system will depend on the needs of each user. As mentioned in the article Understanding basic file access licenses in UNIX , there is a simple but quite effective rule to enhance file-level access security:
The most important aspect of the file-level security process on UNIX systems is to limit the file access license to the extent possible without affecting the necessary tasks of the system, without causing hinder access to files according to the necessary method.

Configure the default license of the home directory
First, the permissions for a user's home directory can be granted when that user is created with the adduser command. For example, in FreeBSD, we can grant initial licenses to a new user's home directory using the -M option with the adduser command. Therefore, if you want to create a user account with the home directory permissions set to 750 , we need to run the following command:
adduser –M 750In Ubuntu Linux, to issue the same license, we must edit the DIR_MODE line in the /etc/adduser.conf file, then this line will be changed to:
DIR_MODE = 0750The /etc/adduser.conf file can be used to configure the home directory's default license for user accounts via administrative tools on FreeBSD systems as well as Ubuntu Linux systems, however The –M option of the adduser command will allow the default license in /etc/adduser.conf to be overwritten when running the adduser command.
When the default license for a user's home directory is granted, that user's home directory will be inviolable whether browsing or viewing for all accounts without root privileges, except The account owns this directory and the accounts belong to the default group of that account. In addition, this default license will not allow deleting this home directory, even other accounts in the default group of licensed user accounts. Once the home directory has been created, we still need to automate the default licensing process for additional files created by that account.
Configure the default mask of the file license
File Creation Mask (FCM) can help automate file-level security policies by using a limited set of default file permissions when new files are created. The command is often used for FCM in UNIX and UNIX systems, umask (abbreviated from user mask). In POSIX-standard operating systems, every process has a user mask to limit the modes for the files it creates. The umask command will specify unauthorized permissions. UNIX-style systems also use the umask command to install the umask for a utility.
This command can be improved to affect any operating process in the context of a user login utility. We can apply this umask to every user account on a system by specifying an default umask in a default utility configuration file of the system. For example, in most Linux distributions, bash is the default utility, the bash configuration file will be / etc / profile or / etc / bashrc . For BSD Unix systems, the default utilities are part of the C utility group, such as csh and tcsh , and the configuration files of these utilities will be /etc/login.conf .
In FreeBSD, by default, the corresponding line in this configuration file will be:
: umask = 022:Because this is a mask that blocks a set of device licenses, we need to consider them as licenses that are excluded from the default licenses that a file might have. For example, when a process with umask tries to create a file with a 775 license, it will complete with the 755 license group because the license has a value of 2 (Write - write license) has been blocked with the Group object. as a default file access license. Since files outside the directory are usually not executable files, however, licenses 1 (Execute) are always ignored by creating an installation umask 022 to assign licenses 644 to files outside the directory when created, while files in the directory will be created with the license group 755 .
A umask that is better suited for security purposes will be umask that helps to block license group certificates valued at more than 750, configured in the etc / login.conf file by changing the value of umask to:
: umask = 027:Meanwhile, on Ubuntu Linux systems, the default value of umask in etc / profile will be:
umask 022To automate file creation licenses to prevent them from exceeding 750 we need to change this line to:
umask 027Also users can install a different value for the file license. For example, if a user creates a file, then wants to grant 777 license, then the chmod command can be used with the following syntax:
chmod 777 [name_file]The default umask configuration of this utility will not prevent users from making changes to the license, but it only sets default values for specific license groups when the file is created.
Default license policy
The default license policy (Default Permission Policy) applied to each system will depend on the needs of each user. As mentioned in the article Understanding basic file access licenses in UNIX , there is a simple but quite effective rule to enhance file-level access security:
The most important aspect of the file-level security process on UNIX systems is to limit the file access license to the extent possible without affecting the necessary tasks of the system, without causing hinder access to files according to the necessary method.
3.7 ★ | 3 Vote
You should read it
May be interested
- What is Unix / Linux?unix operating system is a collection of programs that act as a link between a computer and a user.
- Basic utilities: print, email in Unixby this chapter, you have a few basic insights about unix systems and some of its basic commands. this chapter will briefly discuss some of the basic but important utilities of unix utilities that you will use in your daily activities.
- Instructions for installing Unix / Linuxan important unix concept is the environment, which is defined by environment variables. some are set up by the system, others are set up by you, by the shell or any program you download.
- ManPage Help in Unixall unix commands come with arbitrary and mandatory functions. it is very common when you forget the full syntax of these commands.
- File Management in Unix / Linuxall data in unix is organized in files. all files are organized in folders. these directories are organized in a tree structure that is called the file system.
- Regular Expression in Unix / Linuxa regular expression is a string that can be used to describe different sequences (arrangement) of characters. regular expression is often used by various unix commands, including ed, sed, awk, grep and micro domains.
- Useful commands in Unix / Linuxthis chapter lists the commands, including syntax and brief descriptions. for more details about these commands, you use.
- Basic file system in Unix / Linuxa file system is a logical collection of files on a partition or a disk. a partition is an information store and can be combined into a hard disk if desired.
- System performance in Unix / Linuxthe purpose of this tutorial is to introduce performance analysis with the tools available for monitoring and managing performance on unix systems, and to provide a general guideline on how to detect and fix performance issues in unix environments.
- Techniques cited in Unix / Linuxshell provides a variety of characters that have special meaning while using them in any shell script and cause a limit of a word unless quoted.