Can I create another root user account in Linux / UNIX?
Q . I’d like to create my root account in Linux. How do I do it?
A . Root user is superuser on a Unix / Linux system. Root user has all rights or permissions. . The root user can do many things an ordinary user cannot do on system such as start / stop services, grant / revoke any permissions, open ports (especially
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
In general when a response is label A for answer, the response will actually answer the question
Who can I change the root account Passward what was created at the time of installation.
I know the existing passowrd but I need to chenge it for security.
hai , root user will have the permission to change the root passwd
its simple and very easy. just type the command “passwd” space the “username.”
then enter it will ask for new password… tats it..
SYNTAX: [root@server1
]# passwd root
Changing password for user root.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
so how do i do it, i know its a security risk just how do i do it.
Yes you can create another account who will have the same power as root user,
It very much simple in most of Linux OS.
User the command ,
#useradd -ou 0 vikas
#passwd vikas
After this user(vikas) will work as root user
You are very good in linux. I have read your shell scripting tutorials also.
good work.
All the best,
Praveen
pls mail ur shell scripting tutorials
Really helpful, kindly send the links of your tutorial.
Thanks vikas, Its a cool command, There are bunch of ediots wrting tens of pages to do this and finaly nothing happens. Keep up the good work.
If you haven’t found an answer yet:
useradd -G root newuser
passwd newuser
id newuser
thankw
it works
Thanks for sharing you saved me alot of needless waste of time.
when installing Linux the system will not let you create a user called “root” because it already exists. You can create a user like localadmin or use your own name. Give it a password then after the installation is finished you can change root’s password by typing sudo passwd root
it asks you for new password twice. and then after that you can log in as root.
you can always change users password by using sudo passwd username. but if you want to be root you have to log in as yourself then do a su
then put roots password in. after that you wont have to sudo every time.
it is all for your benefit because you dont want to re-format and reinstall every time you make a mistake (as root) it is too dangerous.
I am a new user of linux OS Ubuntu and am trying to login as root. I can’t do so because I don’t know the root password. I was only asked for one password on installation and that does not work with root. Can someone help?
if ur normal user you will not allow to enter in to root previleges
OK I am new too so experts can correct me if I am wrong!…but this is my experience…. the ubuntu 8.04 workstation version and gdm (the gnue GUI/windows) will not allow you to log in as root or privileged user…but before that when you first log in, use whatever name you created to get in the system.
then if you are in the GUI open up a terminal (comand line) and do a
sudo passwd root
and set a password for the root user.
then you can either use the command su to get in as root or login as root (before you get in the GUI).
The root is automatically created when you install the system but it is not activated until you setup a password for it.
you have to be patient bcs the first time you have to put your password whenever you use sudo then after that you’ll enter root’s new password twice then after that its easy bcs whenever you login as root you only use the new password once.
You can use xdm instead of gdm to be able to log in as the root. gdm/kdm will not allow you to do that tho.
any way root user is too dangerous.. it has precedence even over the operating system so be careful with it.
To satisfy both the security problems and your wish to have your own unique root user:
usermod –login newusername root
This changes the root user to whatever you want AND strengthens the security at the same time as noone can brute force the COMMON root user anymore. In order you add a DUPLICATE “root” user and sustain the same permissions, you must change the account to –non-unique so that two accounts can share the uid “0” and gid “0”. Linux is ignoring me when I use this command and I don’t know why; so, for now just change the login name. Please post if you figure out how to get linux to accept the –non-unique using usermod command.
Also, SU command will no longer work without defining your new username you choose once you do this; I don’t see this as a big problem and it again increases the security.
I did not know about usermod command.
I know tho the only GUI program that actually allows you to log on as root is xdm.
kdm and other xwindows prog. like gdm will not allow root to log in.
regards;
can anyone help me ?
how to set bandwidth on ip address in linux (downloading).
using neat command u will get option over there
to change the speed of network card you can use ifconfig
like
ifconfig eth0 up mtu 1500
mtu 1500 is the max speed
you can use 1200 or less if you wanted to
up means to enable the nic.
Actually, the mtu is not bandwidth or NIC speed. You don’t want to mess with that unless you are changing a NIC to enable jumbo framing.
actually my friend has created rootuser while installing but after two days i want to change that .Thatswhy i went to first system settings i changed the password like user name :jyotshna,password:jyotshna. Now iam not able to enter in to system throughlike super user.while iam trying do that it is showing root is changed as home directory .
how to create super user
super user bis nothing but root user
First, as an infosec professional I completely agree with the additional security benefits and best practices SUDO provides.
However, the self-proclaimed experts who repeatedly belch forth the tired “I-know-how-but-I’m-not-going-to-tell-you-so-go-learn-SUDO-&-sudoers” mantra are the same individuals who post explicit command-line configurations for complex OS & service installations or modifications INCLUDING THE SUDO command, without considering that newbies are simply copying & pasting these commands into their installations without understanding ANY of the risks or the increased attack surface the changes may be creating. Such behavior creates MORE security issues than sharing the information to allow a user to create alternate root accounts.
**Before using the following commands, it is your responsibility to understand the ramifications of creating and using a root-level account. Use may result in a security compromised system or you may render your system COMPLETELY UNUSABLE.
** You agree by using the information contained herein that any negative impact or results to any system, data or network are entirely your responsibility.
Create additional root-level accounts by running these commands from a terminal session:
> sudo su
> useradd -G root
> passwd
> id
(you should see something similar to: uid=1001(newusername) gid=1001(newusername) groups=0(root)
> usermod -o -u 0 -g 0
(in the usermod command string, the first switch is the letter “O”. The characters following the -u and -g switches are each “zero”)
> id
(now you should see something similar to: uid=0(root) gid=0(root) groups=0(root)
I suggest bouncing your system prior to logging on with the newly created root-level user account.
These commands work well in most main stream *nix and BSD distributions. Use them wisely.
Thanks darkrift2012. Most *nix vets don’t even seem to be able to understand the question.
I have a problem in regards to root. I have a windows virus in linux weird but true! the problem is it’s in root on my linux distro and i’m sure its using wine to activate the virus. Would i need to worry as it can’t move around like in windows. Can’t do anything with it do you have any ideas?
i cant able to add new user from root.. its saying that useradd command not found.. now wat i have to do?
how to give root permission to normal user
I think you have to be root in order to add user.
so log in with your user name and then type su then hit enter then put in the root password.
then the commands will work.
Oh BTW, if this is the first time you set up linux what you can do is to log in as regular user (bcs it will not allow you to create root at the install, since its already there…) then do a passwd root to set a new password for the root, then you can log on as root user or do the su or sudo commands.
Darkrift2012 has an excellent post above as well.
how can i stop/start a services in /etc/init.d/ using an ordinary user account?
how do you make a user a sudoer
how to install image on ubantu
Root is a secret….
Because PC’s have a 99% chance of getting physically stolen where cruel punishment can take place, which could include:
1. Drop from a 3rd story window
2. Electrify your cat Squiggles while its taking a bath
3. Mysterious strangers using your backspace key as if its a pound key repeatedly
4. Because grany loves peaking at your special artwork
5. Because being root makes you feel important
6. Aunt Jemima and her secret service of highly trained ninjas
i want to create a new user in fedora linux
but that permission was denied while using the command USERADD.
how to grant the permission to create a new user?
please its urgent
oops made a comment but in the wrong place, I think.
I hope su works.
did you use sudo before useradd?
or as I do I just type in su and then the password then I get the new shell which I am the root, then I can do whatever. then I type exit to get out of root and go back to my user.
How can I set Privileges to created user in centos?
I created a root user name but could not login with the password I provided. How do I recover my password or how do I go about logging-in?
Источник
Как создать пользователя Linux
Основу управления правами доступа в Linux и уровнем привилегий в Linux составляют именно пользователи. Изначально, еще при проектировании системы существовал пользователь root, которому позволено выполнять любые действия и другие пользователи, права которых настраиваются с помощью вступления их в группы Linux и установки прав на каталоги.
Многопользовательская архитектура, одна из первых особенностей Linux, которая существует еще с зарождения системы. В системе могут работать одновременно множество пользователей благодаря удаленному входу, а также пользователи используются для запуска определенных сервисов. В этой статье мы рассмотрим как создать пользователя linux, рассмотрим способ через терминал и в графическом интерфейсе.
Создание пользователя в Linux
Вся информация о пользователях находится в файле /etc/passwd. Мы могли бы создать пользователя linux просто добавив его туда, но так делать не следует, поскольку для этой задачи существуют специальные утилиты. Одна из таких утилит, это useradd. Рассмотрим ее подробнее.
Команда useradd
Это довольно простая команда, которая есть во всех дистрибутивах Linux. Она позволяет зарегистрировать нового пользователя или изменить информацию об уже имеющемся. Во время создания можно даже создать домашний каталог пользователя и скопировать в него системные файлы. Рассмотрим синтаксис команды:
$ useradd опции имя_пользователя
Все довольно просто, дальше нам нужно рассмотреть основные опции команды, с помощью которых вы будете настраивать нового пользователя:
- -b — базовый каталог для размещения домашнего каталога пользователя, по умолчанию /home;
- -c — комментарий к учетной записи;
- -d — домашний каталог, в котором будут размещаться файлы пользователя;
- -e — дата, когда учетная запись пользователя будет заблокирована, в формате ГГГГ-ММ-ДД;
- -f — заблокировать учетную запись сразу после создания;
- -g — основная группа пользователя;
- -G — список дополнительных групп;
- -k — каталог с шаблонами конфигурационных файлов;
- -l — не сохранять информацию о входах пользователя в lastlog и faillog;
- -m — создавать домашний каталог пользователя, если он не существует;
- -M — не создавать домашнюю папку;
- -N — не создавать группу с именем пользователя;
- -o — разрешить создание пользователя linux с неуникальным идентификатором UID;
- -p — задать пароль пользователя;
- -r — создать системного пользователя, не имеет оболочки входа, без домашней директории и с идентификатором до SYS_UID_MAX;
- -s — командная оболочка для пользователя;
- -u — идентификатор для пользователя;
- -D — отобразить параметры, которые используются по умолчанию для создания пользователя. Если вместе с этой опцией задать еще какой-либо параметр, то его значение по умолчанию будет переопределено.
Теперь, когда вы знаете основные необходимые нам параметры утилиты мы можем перейти к разбору того, как выполняется создание нового пользователя linux. Сначала давайте посмотрим какие параметры будут применены для пользователя по умолчанию:
Как видите, по умолчанию домашний каталог пользователя будет создан в /home и будет использоваться оболочка /bin/sh. Теперь создадим минимального пользователя с минимальными настройками:
sudo useradd test
Был создан самый простой пользователь, без оболочки и пароля, а также без групп. Теперь немного усложним задачу и создадим пользователя с паролем и оболочкой /bin/bash:
sudo useradd -p password -s /bin/bash test1
Для того чтобы получать доступ к системным ресурсам пользователю нужно быть участником групп, у которых есть доступ к этим ресурсам. Дополнительные группы пользователя задаются с помощью параметра -G. Например, разрешим пользователю читать логи, использовать cdrom и пользоваться sudo:
sudo useradd -G adm,cdrom,wheel -p password -s /bin/bash test2
Также, можно установить дату, когда аккаунт пользователя будет отключен автоматически, это может быть полезно для пользователей, которые будут работать временно:
sudo useradd -G adm,cdrom,wheel -p password -s /bin/bash -e 01:01:2018 test2
Некоторых пользователей интересует создание пользователя с правами root linux, это очень просто делается с помощью useradd, если комбинировать правильные опции. Нам всего лишь нужно разрешить создавать пользователя с неуникальным uid, установить идентификатор в 0 и идентификатор основной группы тоже в 0. Команда будет выглядеть вот так:
sudo useradd -o -u 0 -g 0 -s /bin/bash newroot
Пожалуй, это все основные примеры как добавить пользователя linux. Дальше нам осталось взглянуть только на работу в графическом интерфейсе.
Создание нового пользователя linux в GUI
В графическом интерфейсе системы создать нового пользователя linux еще проще. Рассмотрим окружение Gnome, хотя и в KDE тоже есть аналогичная функция. Войдите в главное меню и откройте параметры системы:
Затем откройте «Пользователи»:
Поскольку утилита запущена от имени обычного пользователя вы ничего не можете сделать. Поэтому нажмите кнопку «Разблокировать»:
Только после этого используйте кнопку со знаком плюс для создания нового пользователя Linux:
В открывшемся окне нужно заполнить все поля. Но тут намного больше ограничений, чем в методе через терминал. Вы не можете задать слишком простой пароль, а также нельзя настроить группы. Можно только указать будет ли пользователь включен в группу wheel с помощью выбора типа пользователя — администратор или обычный:
После этого создание пользователя linux завершено, новый пользователь появится в списке.
Выводы
В этой статье мы рассмотрели как создать пользователя linux с помощью терминала или в графическом интерфейсе системы. Оба способа имеют свои преимущества. Например, способ в терминале намного гибче, но в то же время графический способ дает больше контроля над процессом. Если у вас остались вопросы, спрашивайте в комментариях!
Источник