CentOS Add Users to Sudoers

29/12/2020
In the case of any Linux system, there’s a very powerful user – the “root”. It upholds the ULTIMATE power over the entire system, even modifying data at the hardware level! That’s why it’s so delicate and dangerous at the same time. Without the “root” access, hackers are forced to follow a trickier and more difficult path for taking over the system.The “root” privilege is responsible for performing all the actions that modifies the system files and packages. That’s why in the enterprise/professional workspace, not all users are allowed to run commands as they wish.

CentOS also comes up with a similar policy. It only allows a certain users to perform actions with the “root” privilege. For example, whenever you run any command with the “sudo” command, you’ll get the following error –

For fixing the issue, the user account must be in the “sudoers” file. In this tutorial, we’ll check out on adding a user into the “sudoers” file.

Adding users to the “sudoers”

The trick here is NOT directly editing the “/etc/sudoers” file. Instead, we’ll be adding the specific user into the “wheel” group. In the case of CentOS, all the users in the group have the ability of running “sudo” commands and that’s the easier and safer way.

This is also proven within the “/etc/sudoers” file –

Optional – creating a new user

I’m going to create a new user for the “sudo” purpose only. Don’t worry; you can easily add the existing user.

Enter the “root” mode –

su

Now, create a new user –

adduser <username>

Time to add a password for the newly created username –

passwd <username>

It’s finally time to add the user “Yasuo” on the “wheel” group. At first, make sure that you’re logged as the “root” –

su

Now, perform the final action –

usermod -aG wheel <username>

Everything is set!

Testing the outcome

Well, it’s always worth testing the outcome, no matter how obvious it may seem. Let’s try out running a “sudo” command as “Yasuo” –

su – Yasuo

sudo yum update

Voila! “Yasuo” is now a privileged user account capable of “sudo”!

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Jitsi [Part 5] – Hướng dẫn tích hợp Jitsi LDAP

Mặc định, Jitsi cho phép bất cứ ai cũng có thể sử dụng. Vậy nếu bạn là một tổ chức, một...
30/12/2020

Hướng dẫn reset password bằng Single mode trên Linux (#1)

Trong bài viết này, Onet sẽ hướng dẫn các bạn đặt lại mật khẩu cho User root bằng chế độ...
30/12/2020

[Rsyslog] [ApacheLog] [LAB] [Phần 2] Hướng dẫn cấu hình đẩy Log Apache về Ryslog Server

Tiếp nối phần 1, ở phần 2 mình sẽ hướng dẫn 2 cách đẩy Log Apache về Server Log tập trung. ...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Check proxy trên trang nào chuẩn nhất❓
01/11/2023

Thuê Proxy chạy Google Ads / Cần chú ý gì khi chọn proxy và email chạy G.G ads?
12/10/2023

Thuê proxy 4G ở đâu uy tín, giá rẻ, chất lượng?
05/10/2023

Vì sao cần thuê proxy xoay? Địa chỉ cung cấp proxy xoay uy tín
05/10/2023

Thuê proxy v6 kéo view Youtube ở đâu uy tín, chất lượng?
05/10/2023