EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Software Development Basics CentOS add sudo user
Secondary Sidebar
Linux Tutorial
  • CentOS
    • CentOS Commands
    • CentOS packages
    • CentOS package manager
    • CentOS useradd
    • CentOS add sudo user
    • Centos Repositories
    • CentOS kill process
    • CentOS List Users
    • CentOS Set Timezone
    • CentOS netstat
    • CentOS NetworkManager
    • CentOS disable firewall
  • Basic
    • Introduction to Linux
    • What is Linux
    • Careers in Linux
    • Advantage Of Linux
    • What is Raid in Linux
    • What is Raid 5?
    • Raid 5 vs Raid 6
    • Careers in Linux Administration
    • What is Shell in Linux?
    • Bash Shell in Linux
    • Linux Emulator
    • Linux Operators
    • Linux uptime
    • Linux Apps
    • Linux PDF Editor
    • Linux Keyboard Shortcuts
    • Linux Crontab
    • What is Raid Storage
    • What is Vmware
    • What is RedHat
    • What is Zombie Process?
    • What is Debian
    • Uses of Ubuntu
    • Install Skype on Ubuntu
    • Ubuntu Budgie
    • Ubuntu Recovery Mode
    • Career In RedHat
    • Linux Distributions
    • Linux From Scratch
    • Linux Format
    • sqlplus in linux
    • Linux Environment Variables
    • Cheat Sheet Linux
    • Linux QT
    • Linux Unzip Zip File
    • Linux Disk Space
    • Linux remote desktop
    • Linux GUI
    • Linux restart
    • Linux hex editor
    • Linux KVM
    • Linux XFCE
  • Linux Commands
    • Linux install Command
    • Linux Locate Command
    • Linux Shutdown Command
    • CAT Command in Linux
    • SED Command in Linux
    • df Command in Linux
    • Cut Command in Linux
    • Linux Reboot Command
    • PS command in Linux
    • Mkdir Command in Linux
    • rmdir command in Linux
    • mv command in Linux
    • Linux rm Command
    • CHMOD Command in Linux
    • Linux chmod recursive
    • Zip Command in Linux
    • Linux Route Command
    • SCP Command in Linux
    • du Command in Linux
    • Less Command in Linux
    • Copy Command in Linux
    • Head Command in Linux
    • Help Command in Linux
    • Linux History Command
    • Linux Find Command
    • hostname Command in Linux
    • GREP Command in Linux
    • Linux man Command
    • Linux Curl Command
    • Linux List Users
    • Linux List Directories
    • Linux Directory Permissions
    • Find Directory Linux
    • Linux User Permission
    • Linux Add User
    • Linux Delete User
    • Linux uniq
    • Linux Filter Commands
    • Linux sort Command
    • Linux Sort by Size
    • Remove dir Linux
    • Linux tr Command
    • Linux Touch Command
    • Linux Nice Command
    • Linux More Command
    • Linux Cal Command
    • Linux OD
    • Linux Zcat
    • Linux tracepath
    • Linux Relative Path
    • Linux Sleep
    • Linux bg Command
    • Linux WC
    • Linux Read
    • Linux Write
    • Linux Rename Command
    • Linux Free Command
    • Linux tac
    • Linux Shred
    • Linux wget
    • Linux Date
    • Linux Untar
    • Linux JQ
    • Linux Xargs
    • Linux Mount Command
    • Linux mdadm
    • Linux comm
    • Linux tee Command
    • Tail Command in Linux
    • Linux gzip
    • Linux Directory Structure
    • Linux Alias Command
    • Linux Export
    • Linux netstat
    • Linux traceroute
    • Linux Inode
    • Linux Ping
    • Linux Pipe Command
    • Linux Watch Command
    • Linux Terminate Process
    • Linux Home Directory
    • Linux Nohup
    • Linux Split Command
    • Linux Size
    • Linux Network Stack
    • Linux Network Manager
    • Linux Diff Command
    • Vim Command in Linux
    • Linux nslookup
  • Advanced
    • What is Linux Used For
    • Linux PAM
    • Linux pkill
    • Linux Exit
    • Linux id
    • Linux Umask
    • Crontab in Linux
    • Linux kernel
    • Linux Rsync
    • Linux wildcards
    • Exec Linux
    • Linux Symbolic Link
    • Install VMware
    • Linux User Mode
    • Install GRUB
    • Cron timing format
    • Cron validator
    • Cron in Linux
    • Cron Job Scheduler
    • Cron Command
    • Cron Weekly
    • Chown Command in Linux
    • Linux Network Command
    • Configuring Linux Network Environment
    • DNS Configuration in Linux
    • Linux Users
    • Create User in Linux
    • DHCP Server in Linux
    • FTP Server in Linux
    • Linux Regular Expression
    • IP Command in Linux
    • GNU in Linux
    • Set IP Address in Linux
    • Tar Command in Linux
    • Dynamic Host Configuration Protocol
    • Linux Kill Signals
    • Linux File Permissions
    • Linux File System
    • Linux Create File
    • Linux Concatenate Files
    • Linux Join
    • Linux Process Management
    • Linux Proxy Server
    • Linux System Commands
    • Linux System Logging
    • NFS in Linux
    • What is NFS
    • Linux LVM
    • Nautilus Linux
    • Linux mtr
    • Linux While Loop
    • Linux Remove Directory and Contents
    • Linux Repository
    • Samba Server in Linux
    • Top Commands in Linux
    • Types of Shells in Linux
    • Shell Script Types For Linux
    • GCC Command in Linux
    • Monolithic Kernel
    • YARN Package Manager
    • Linux Sed Replace
    • Linux List Groups
    • Linux Container
    • Linux Find File by Name
    • Create Folder in Linux
    • Linux Move Folder
    • Linux Error Codes
    • Linux Automount
    • Linux HugePages
    • Linux Manual Pages
    • Linux iptables
    • CP Command?in Linux
    • Linux Zip Multiple Files
    • Linux XRDP
    • Alpine linux packages
    • Void Linux Packages
    • Linux Terminal
    • Linux Time
    • Why Is It Important To Red Hat Linux Certification?
    • Linux Chgrp
  • Kali Linux
    • Install Kali Linux
    • Kali Linux Hyper-V
    • Kali Linux Wireshark
    • Kali Linux Default Passwords
    • Kali Linux GUI
    • Kali Linux Distro
    • Kali Linux Terminal
    • Kali Linux Chromebook
    • Kali Linux System Requirements
    • Kali Linux Monitor Mode
    • Kali Linux Connect to WiFi
    • Kali Linux Tools
    • Kali Linux Hydra
    • Kali Linux Penetration Testing
    • Kali Linux Virtual Machine
    • Kali Linux Virtual Box
    • Kali Linux XFCE
    • Kali Linux Bootable USB
    • Kali Linux VMware
    • Kali Linux Persistent USB
    • Kali Linux Sources List
    • Red Hat Linux Commands
    • Kali Linux Raspberry Pi
    • Kali Linux Uses
    • Kali Linux tools list
    • Kali Linux Commands
    • Kali Linux Repository
    • Kali Linux Packages
    • Kali Linux root password
    • Kali Linux GNOME
    • Kali Linux SSH
    • Kali Linux KDE
    • Kali Linux NetHunter
    • Kali Linux Metasploit
    • Kali Linux Nmap
    • Kali Linux Alternative
  • Interview Questions
    • Linux Interview Questions
    • Linux System Administration Interview
    • Red Hat Interview Questions
  • Install
    • How to Install Linux
    • Install JDK Ubuntu
    • Install RVM Ubuntu
    • How to Install Ubuntu
    • How to Install Ubuntu Server
    • How To Install Debian

CentOS add sudo user

CentOS add sudo user

Introduction to CentOS add sudo user

In the CentOS environment, the root user is having all the privileges. Some of the system or security-related task, it will not complete unless and until it will not log in with the root user. If we need to provide the same root-level access to a different user then we need to provide the sudo access to the same user. Basically, sudo supports the plugin architecture; it will support the input or output logging and the security-related policies. Third parties like the application or communication can design such type of architecture. It will distribute the own security policy and input or output logging plugin to work smoothly with the front-end sudo user. In the Linux distribution, the sudoers is the default security policy. The same policy can be configured via /etc/sudoers file (It will also be configured via LDAP configuration also). To explore more into it, we need to explore the sudo support information. In this topic, we are going to learn about CentOS add sudo user.

Syntax of CentOS add sudo user

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

As such, there is no specific syntax available to add the user with sudo privileges. If we need any user with sudo access then there are different ways to achieve it. As per the requirement or application use case, we need to do the same.

Sample method how to edit the file for the sudo access: vi /etc/sudoers

  • vi /etc/sudoers: As per the above method, we need to use an editor like vi, vim, nano to edit the file. We need to edit the “sudoers” file. As per the requirement or the access level, we need to add the user with the specific access condition.

How CentOS add sudo user Works?

In the CentOS operating system, the root user is having all the privileges. If any different user what’s the sudo privileges then we can also provide it. There are different methods to provide sudo access.

Below are the lists of options that can be considered while working with the sudo.

  • -A, –askpass: From the user terminal, if the sudo requires a password then it will read. If the -A –askpass option is in used then the graphical program will execute to read the user’s password and output the password to the standard output. We can also set the SUDO_ASKPASS environment variable in the system. we can set the path for the askpass helper program

For example, we can set it to “/usr/X11R6/bin/ssh-askpass” (If the no askpass program is available then the sudo will exit with an error message)

  • -b, –background: It will help to run the command in the background. Please note: it will not possible to use a shell job. To control the manipulate background processes which are started by sudo user. The number of interactive commands will fail to work properly in background mode.
  • -C num, –close-from=num: It will help to close all the file descriptors which are greater than or equal to num before executing a command. It will not permit if the Values are less than three. By default, the sudo will close all open file descriptors other than standard input, standard output, and standard error when executing the command.  By default, the security policy will restrict the user’s ability to use this option.  The sudoers policy only permits to use of the command with the help of the -C option.
  • -E, –preserve-env: This option will indicate the security policy that the user requirement to preserve their existing environment variables. The security policy may get the error message if the login or access user is not having permission to preserve the environment.
  • –preserve-env=list: This option will indicate to the security policy that the user requirement to add the comma-separated list of environment variables to those preserved (it will from the user environment). The security policy may get the error message if the login or access user is not having permission to preserve the environment.
  • -H, –set-home: It will help to set up the HOME environment variable for the security policy. In the target user’s password database entry, it will also set the home directory specified.
  • -h, –help: It will print the short help information to the standard output. It will automatically exit.
  • -g group, –group=group: It will help to run the command with the primary group. In the target user’s password database entry, it will set to group instead of the primary group.

Examples to understand CentOS add sudo user

Here are the following examples mention below

1. CentOS add sudo user: Grant the Sudo Access to Normal User

In the CentOS environment, we are able to provide sudo access to the normal user. As we have discussed earlier, there are different methods to do that. Here, we are using the group modification method.

Command :

usermod -aG wheel user1

Explanation :

As per the above command, we are modifying the group for the “user1” user. In screenshot 1 (a), we are not able to run the “systemctl” command because we need sudo access. Once, we have added the user to the wheel group. The user1 will get the sudo access and the ability to run the command (please refer to screenshot 1 (b)).

Output :

CentOS add sudo user output 1

Screenshot 1 (a)

CentOS add sudo user output 1.2

Screenshot 1 (b)

2. CentOS add sudo user: Allow sudo access to the normal user

In the CentOS environment, we can provide sudo access to normal user via editing the “sudoers” file

Command:

vi /etc/sudoers

Explanation :

As per the above command, we are doing changes in the “sudoers” file. We need to add the user name to which we need to provide the sudo access. Here, we are providing sudo access to the “user11” user.

Output :

CentOS add sudo user output 2

Screenshot 2 (a)

output 2.2

Screenshot 2 (b)

Conclusion

We have seen the uncut concept of the “CentOS add sudo user” with the proper example, explanation, and command with different outputs. By default, there are multiple ways to provide sudo access to the normal user. As per the requirement or need, we need to choose any method which is applicable.

Recommended Articles

This is a guide to CentOS add sudo user. Here we discuss the uncut concept of CentOS add sudo user along with the example and command. You may also have a look at the following articles to learn more –

  1. CentOS Commands
  2. What is CentOS?
  3. Linux Curl Command
  4. How to Install CentOS?
Popular Course in this category
Software Testing Training (11 Courses, 2 Projects)
  11 Online Courses |  2 Hands-on Projects |  65+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Selenium Automation Testing Training (11 Courses, 4+ Projects, 4 Quizzes)4.9
Appium Training (2 Courses)4.8
JMeter Testing Training (3 Courses)4.7
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more