Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux CentOS In-Depth: Adding Users As Sudo User

Thursday, September 23, 2021

Linux CentOS In-Depth: Adding Users As Sudo User

Sometimes you don't want to do everything with the root account.  So there are some super users who you trust as administrators.  For those users you want them to be able to run the sudo command.  A sudo command allows a user to run commands with root privileges without logging in as root.
For example something like this sudo yum update unlike the su command which prompts you for the root password.  The sudo command prompts you for the password of the logged in user.

In order for the sudo to work we have to configure the /etc/sudoers file.  There is a special command for editing the sudoers file and it's the visudo command.  This command should be used at all times when editing the sudoers file instead of a text editor.





The sudoers file contains command aliases for different command sets.  For example the alias for networking is

Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

So let's say we created a group called networkadmin and want the group to be responsible for networking we can put the entree %networkadmin ALL = NETWORKING

By default the wheel group has all the access to the commands

%wheel ALL=(ALL) ALL

If we want to assign all the commands to an individual we can do the same thing

jason ALL = (ALL) ALL



What we can do is give jason access to all the commands because he is the tech lead, but only give the developers commands for SOFTWARE, and SERVICES

Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig

We could breakup the users into User_Alias which is a group that exists in the sudoers file, that we can mix and match users into these aliases.

For example let's we have  four developers dora, john, todd, jason.  Two of them are junior developers and the other two are senior developers.

We could create a user alias of JUNIORDEV and SENIORDEV, here is how it would look

User_Alias        JUNIORDEV = todd, john
User_Alias        SENIORDEV = jason, dora

Now we can assign the User_Alias to the Cmnd_Alias

JUNIORDEV    ALL=SOFTWARE

SENIORDEV    ALL=SOFTWARE,SERVICES


As you can see the junior developers only have access to the commands that are in the software command alias, while the senior developers have access to both the SOFTWARE and SERVICES























Similar Posts:



15 comments:

  1. avscourierservice is very loyal to take care of every single client’s product. There is no another way left for your trusted quality demand. For getting better service you need to contact us soon. We have certified international transaction license which ensures your right choice. So, hurry to contact us. Our talents are waiting for your best satisfaction. Visit our Dhl courier service in delhi and contact with us to get better service. Create your order, we will provide you fast, economical and safer goods transaction.

    ReplyDelete
  2. Yes! Linux is a very advanced and core language. Many institutes can start online certification. But our company's services are somewhat different, such as Phd Thesis Writing Services, Academic Writing Services, etc., and our company also provide academic-related certification for students.

    ReplyDelete
  3. I had a computer science dissertation based on Linux system. However, I had not enough command on this operating system. Therefore, I started looking for a useful resource and at the end, I found NetAcad where the basic commands with tutorials were there. It was really helpful for me to complete my dissertation without being stuck due to lack of knowledge on command lines.

    ReplyDelete
  4. Yes! Linux is a very mature and important programming language. Many institutes are able to begin offering online certification. Cheap Essay Writing Services.

    ReplyDelete
  5. Looking for the best person to do my online exam? Turn to an online exam expert for all exam services at a reasonable cost.

    ReplyDelete
  6. Plagiarism is an issue that should not be ignored. It's a red flag to consider when hiring, evaluating and even looking for a writing service, especially if the company has a reputation of hiring plagiarists. That's why we provide you case study solutions online

    ReplyDelete
  7. This is so complex! I would never be able to understand it. If I was this smart then I would have been doing my assignments on my own rather than paying for the best assignment help uk-based services. I try to escape from the situations even with the slightest complexity, I’m working upon it but this is how I am.

    ReplyDelete
  8. help with finance homework from experts. We provide assignment help to students who want to get good grades in their assignments.

    ReplyDelete
  9. Linux is a good programming language.Many software houses are used in this programming language.If any one wants high school gpa calculator uk service.

    ReplyDelete
  10. This is an amazing post. It is very precise and informative. I loved reading it. Do my online class

    ReplyDelete
  11. It's well-known for its stability, security, and reliability, and it's often used as an operating system for servers and other infrastructure components. Recently, I stuck in my operating system assignment and found this write my assignment uk for help and its help me to complete my task. Their team of experienced and highly qualified writers are experts in various subjects and are well-versed in academic writing, ensuring that you receive the best possible grade.

    ReplyDelete
  12. Merchant Cash Advance Leads refer to potential customers or businesses that may be interested in obtaining cash advances for their merchant accounts.

    ReplyDelete
  13. wow, thanks for this informative article this is very helpful for me and I will share this with my all friends and once again thankyou and keep it up.

    ReplyDelete
  14. thanks for this informative and interesting and very helpful article and I will share this with my all friends and once again thank you and keep it up.

    ReplyDelete
  15. Dominos NHS Discount offers an exclusive NHS discount to show appreciation for the hardworking healthcare professionals. With this discount, NHS employees can enjoy delicious pizza at a reduced price, making it a tasty and budget-friendly treat. It's a small token of gratitude for their dedication and service to the community.

    ReplyDelete

Search This Blog