This article is a continuation to the article Getting Started CentOS 7 (Part-1). In the first part we covered the following topics:
This article explains how to disable SELinux, set date, time and timezone and how to manage users and groups in CentOS 7.
Disable SELinux
Security-Enhanced Linux (SELinux) is an access control mechanism that provides higher security by enforcing security policies that prevent access to files and processes. SELinux can run in three different modes - Enforcing, Permissive and Disabled. When running in Enforcing mode, security policies are enforced and access is denied. In Permissive mode security policies are not enforced but warnings are displayed and logged. No security policy will be loaded in Disable mode.
To view the current status of SELinux, run the command
# sestatus
To change SELinux to disabled, edit the file /etc/sysconfig/selinux
and change
SELINUX=disabled
Save and exit the file. You need to reboot your system for the changes to take effect.
Setting Date and Time
Use the timedatectl command to set the date and time in CentOS 7.
Command | Description |
---|---|
timedatectl | Display date and time settings. |
timedatectl set-time time | Set the system date and time. Input time in the format YYYY-MM-DD HH:MI:SS. Example: # timedatectl set-time "2017-11-28 12:54:00" |
timedatectl list-timezones | Show all available timezones. |
timedatectl set-timezone timezone | Sets the timezone. Example: # timedatectl set-timezone Europe/Brussels |
timedatectl set-ntp true/false | Enable or disable NTP time synchronization. Example: # timedatectl set-ntp false |
User and Group Management
The following commands can be used to create, modify and remove users and groups.
Command | Description |
---|---|
cat /etc/passwd | Show all users. |
cat /etc/group | Show all groups. |
groupadd group_name | Add a new group. Example: # groupadd tech |
useradd user_name | Add a new user. Example: # useradd alex | usermod user_name -g group_name | Add a new user and set the primary group for the user. Example: # useradd alex -g tech |
usermod user_name -g group_name -G supplementary_groups | Add a new user, set the primary group and also add supplementary groups for the user. Example: # useradd alex -g tech -G root |
groups user_name | Show groups to which a user belongs. |
id user_name | Show information about the specified user. |