Getting Started with CentOS 7 (Part-2)

Last updated on 01st December 2017

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.

CommandDescription
timedatectlDisplay 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-timezonesShow 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.

CommandDescription
cat /etc/passwdShow all users.
cat /etc/groupShow all groups.
groupadd group_nameAdd a new group. Example:
# groupadd tech
useradd user_nameAdd a new user. Example:
# useradd alex
usermod user_name -g group_nameAdd 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_nameShow groups to which a user belongs.
id user_nameShow information about the specified user.

Also Read


Post a comment

Comments

Nothing yet..be the first to share wisdom.