- New User With Root Access and Without Sudo
- 1 Answer 1
- Как дать Root права пользователю в Linux
- Способ 1: Добавление в корневую группу с помощью usermod
- Способ 2: Добавление в корневую группу с помощью команды Useradd
- Способ 3: Редактирование файла /etc/passwd
- Способ 4: Дать права пользователя Sudo
- How To Add a User and Grant Root Privileges on Ubuntu 18.04
- Preflight
- Step 1: Add the Username
- Step 2: Grant Root Privileges to the User
- Step 3: Verify User Has Privileges
- Related Articles:
- About the Author: Justin Palmer
- How to Add a User and Grant Root Privileges on Ubuntu 16.04
- Preflight Check
- Creating a User with Root Privileges
- Step 2: Grant Root Privileges
- Step 3: Verify New User
- Get Started Today!
- Related Articles:
- About the Author: Alison Gray
New User With Root Access and Without Sudo
I Know about the security risk and I know about sudo, sudo su, sudo -i and the sudoers file but what I need is to create a new user (not root user) with the root privilage without having to use sudo at all. how to do that ? and don’t give me an altrnative ways please thank you
If you know about the security risks, then why do it. There are (almost) never a reason to be permanently logged in with root-rights.
1 Answer 1
- It is recommended not to use another user as root and just use sudo permissions.
- You can simply add user by sudo adduser .
- You can change the uid and gid to root uid and gid by using sudo nano /etc/passwd
- you will see users at the same syntax as this example:
- root. 0:0::/:/usr/bin/bash
- newroot:x:1001:1002. /home/newroot:/bin/bash
- change your new user uid and gid to the same as root newroot:x:0:0. /home/newroot:/bin/bash
- Look for the user you created and change the uid and gid to the same as root gid and uid.
- To look what the uid and gid of the root you can just look in the same file at the root user or use the command id root .
- on the most of the distributions the uid and gid of the root is 0.
- I AM SAYING AGAIN IT IS NOT RECOMMENDED TO PUT ANOTHER USER AS ROOT
- you can get the same permissions by using sudo command.
- To give you new user the sudo permissions wich is recommended then the first part on my answer you can simply make it by:
- sudo useradd
- sudo usermod -a -G sudo
- the -a for not overwriting and deleting the «old» groups of the user.
The system does not recoginize the new user and it think that it is the root user .. is there a way around that ?
try to change the gid and uid on the /etc/passwd without changing the path that will work out, (i just did on my ubuntu)
Как дать Root права пользователю в Linux
Суперпользователь «root” — это король пользователей Linux / Unix. Наличие корневого доступа предоставляет полный и неограниченный доступ к дистрибутиву Linux.
В этой инструкции я покажу вам, как дать root права пользователю в системе Linux. Как правило, доступ на корневом уровне (root) используется в системном администрировании. Поэтому всегда больно давать root-доступ другим пользователям. Вы должны быть очень осторожны и должны забрать доступ, как только необходимость в этом отпадет.
Согласно разрешениям файловой системы Linux, root или суперпользователь имеет полные права на чтение (r), запись (w) и выполнение (x) любого файла. По умолчанию идентификатор пользователя root равен «0».
Я собираюсь создать двух пользователей, а именно user1 и user2. Затем я предоставлю root-правак пользователю «user1«.
Способ 1: Добавление в корневую группу с помощью usermod
Давайте посмотрим, как мы можем дать обычному пользователю root- права, добавив его в корневую группу.
# adduser user1
# adduser user2
# groupadd test
Это группы, которые есть в моей дистрибутиве Linux.
# groups
root bin daemon sys adm disk wheel
Я собираюсь добавить user1 в корневую группу следующим образом:
Приведенная ниже команда даст пользователю привилегию root
Способ 2: Добавление в корневую группу с помощью команды Useradd
Я добавил нового пользователя «user3» в корневую группу с помощью команды:
# useradd -m -G root user3
# groups user3
user3 : user3 root
useradd -c “Imitation Root” -d /home/root_user -m -k /etc/skel -s /bin/bash -u 0 -o -g root root_user
Способ 3: Редактирование файла /etc/passwd
Отредактируйте /etc/passwd для конкретного пользователя. Измените UID и GID пользователя на «0«. Это даст root права пользователю в linux.
Теперь пользователь temproot должен иметь привилегии root:
ВНИМАНИЕ: это не рекомендуемый метод предоставления корневого доступа (root-прав)
Способ 4: Дать права пользователя Sudo
Конфигурационный файл sudo — это файл /etc/sudoers, и вы можете отредактировать его с помощью команды visudo:
Использование visudo защищает от конфликтов и гарантирует использование правильного синтаксиса.
Чтобы предоставить полный доступ конкретным пользователям
Добавьте в файл запись, приведенную ниже:
Следовать этому методу не очень хорошая идея, потому что это позволяет и User1, и User2 использовать команду su для предоставления постоянных привилегий root. Таким образом пропуская функции ведения журнала команд sudo.
Предоставление доступа к определенным файлам одному конкретному пользователю
Эта запись позволяет User 1 и всем другим членам группы получить доступ ко всем программным файлам в каталогах /sbin и /usr/sbin, а также привилегию выполнения команды /usr/oracle/backup.pl…
User1, %operator ALL= /sbin/, / usr/sbin, /usr/oracle/backup.pl
Если у вас есть какие-либо вопросы или предложения по этой теме, оставьте комментарий.
How To Add a User and Grant Root Privileges on Ubuntu 18.04
Adding a user and granting that user root privileges is one of the many tasks of a system admin. Once a user has been added and granted root privileges they’ll be able to login to your Ubuntu VPS and perform vital functions for the upkeep of the system. Afterward, they’ll be able to use sudo before commands to perform elevated tasks. In this quick tutorial, we’ll show you how to add a new user and grant root permissions.
Preflight
- These instructions are intended specifically for adding a user on Ubuntu 18.04 LTS.
- We’ll be working from a Liquid Web Core Managed Ubuntu 18.04 LTS server, and I’ll be logged in as root.
Step 1: Add the Username
In my example, I’ll be adding my cat’s name, Tom, using the adduser command. Replace tom with your desired username. During this time, the system will also ask of me details from my user. Feel free to skip these details by pressing enter and eventually it asks us to confirm that the info is correct, leading us to a new user added.
Example Output:
Adding user `tom’ .
Adding new group `tom’ (1001) .
Adding new user `tom’ (1001) with group `tom’ .
Creating home directory `/home/tom’ .
Copying files from `/etc/skel’ .
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for tom
Enter the new value, or press ENTER for the default
Full Name []: Tom
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
Step 2: Grant Root Privileges to the User
The command above leads us to the /etc/sudoers.tmp file, where we can view the following code: # User privilege specification
root ALL=(ALL:ALL) ALL
After the root user line, you will add in your new user with the same format for us to grant admin privileges.
Once you’ve added the permission, save and exit the file by using the following process. (In Ubuntu 18.04, nano is the default editor, so we need to use the ctrl+x, y keystrokes to save and exit the file.)
hold `ctrl` and press `x`. At the prompt, press `y` and then hit `enter` to save and exit the file.
Step 3: Verify User Has Privileges
If you’ve followed the instructions correctly then this user will be able to run commands like, update, using the sudo:
Want to do admin tasks through a control panel? Check out our servers that come with cPanel. We offer assisted migrations and 24/7 support making it effortless to switch to Liquid Web!
Related Articles:
About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business
How to Add a User and Grant Root Privileges on Ubuntu 16.04
Ubuntu 16.04 LTS provides you the ability to add a user for anyone who plans on accessing your server. Creating a user is a basic setup but an important and critical one for your server security. In this tutorial, we will create a user and grant administrative access, known as root, to your trusted user.
Preflight Check
- We will need to open a terminal and log in as the root user.
- We will be working as that root user on a Linux Ubuntu 16.04 LTS server
Creating a User with Root Privileges
Create a username for your new user, in my example my new user is Tom:
You’ll then be prompted to enter a password for this user. We recommend using a strong password because malicious bots are programmed to guess simple passwords. If you need a secure password, this third-party password generator can assist with creating one.
~# adduser tom Adding user `tom' . Adding new group `tom' (1002) . Adding new user `tom' (1002) with group `tom' . Creating home directory `/home/tom' . Copying files from `/etc/skel' . Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Usernames should be lowercase and avoid special characters. If you receive the error below, alter the username. ~# adduser Tom adduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable. Use the `—force-badname’ option to relax this check or reconfigure NAME_REGEX.
Next, a text prompt will appear asking us to enter in info about your new user. Entering this information is subjective and is not required. This info can be skipped if needed by pressing enter in each field. We suggest adding in as much info as needed to track usage.
Enter the new value or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []:
Lastly, the system will ask you to review the information for accuracy. Enter Y to continue to our next step.
Is the information correct? [Y/n]
Step 2: Grant Root Privileges
Assigning root access to a user is to grant the user the highest privilege on our system so caution is advised. Once out user Tom is added, he can make changes to the entire system as a whole, so it’s critical to only allow this access to users who need it. After this, Tom will be able to execute commands using the sudo option which is normally reserved for the root user.
Step 3: Verify New User
As root, you can switch to your new user with the su — command and then test to see if your new user has root privileges.
If the user has properly been granted root access the command below will show tom in the list.
That’s it! We have added a user and then granted that user root privileges on an Ubuntu 16.04 LTS server.
Get Started Today!
Would you like to learn more about setting up a new Ubuntu server? Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Experienced Hosting advisors to learn how you can take advantage of these techniques right away!
Related Articles:
About the Author: Alison Gray
Alison Gray is currently an IT Project Manager at Liquid Web and has been with Liquid Web for nearly 10 years. In 2015, She earned her Bachelor’s Degree in Media and Information from Michigan State University. In her free time, she loves spending time with her girlfriend and 3 kids. You can usually find her at a basketball court or some sort of sporting event. If the weather’s right, she loves being outside in the yard finding some sort of yard work to do.
Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business