5 gold badges40 silver badges44 bronze badges
asked Aug 9, 2009 at 18:21
answered Aug 9, 2009 at 18:40
You must make note of the caveats though:
answered Aug 9, 2009 at 18:32
John T
27 gold badges339 silver badges347 bronze badges
Just edit the entry in /etc/password
to what you want. You may also need to update /etc/group
for consistency. Then rename your home directory (in /home
) to match.
answered Aug 9, 2009 at 18:23
Adam Batkin
7 silver badges16 bronze badges
I think if you add
if grep "\\<${USER}\\>" /etc/jailbirds > /dev/null
then
echo I am not a crook
else
exec chroot $CWD
endif
If you do try my suggestion I suggest you be very careful. It would be easy to get it wrong and mess things up bad. I have not tested this, by the way.
- Can you change the root username?
- How to change root username and password in Ubuntu?
- How to change root name in terminal?
- How to get back to root?
- How do I change my username in Unix?
- How do I change a username on Linux?
- How can I root on Linux?
- How do I log in as root on Linux?
- How do I set a root password?
- How do I change my root password?
- What is a root password?
- How do I change the name of my terminal?
- How do I change my hostname?
- How do I change the command prompt name?
- Can we rename the root user in Linux?
- Can you change the root username?
- How to change the root user to a normal user on Linux?
- How do I change my username on Linux?
- How to get back to root?
- How do I change my username in Unix?
- How do I change my WSL username?
- What is the command to delete a user in Linux?
- How to find the root user in Linux?
- How do I change the user?
- How can I switch back from root user to normal user?
- How do I get back to root on Linux?
- How do I change my username?
- How can I login as sudo?
- How do I change my Linux username and password?
- How do I change the root user name?
- Re: How do I change the root user name?
- Re: How do I change the root user name?
- Changing the username in Ubuntu
- 1. Change username in Ubuntu
- 2. Change the Group name in Ubuntu
- 3. Change the name of the home directory
- What happens to files owned by the old username?
- Switching to a normal user from root user
- Switch to another user from a regular user
- Switching users into their login shell
- Switch to root user
- Run a command as another user
Can you change the root username?
How to change root username and password in Ubuntu?
Option 2: Change the sudo password using the passwd command
First, open the terminal (CTRL+ALT+T). Enter your current password and press Enter. The output you get should show that you can now run commands as root. Enter a new password and repeat it to confirm the change.
How to change root name in terminal?
Launch a new terminal to see the new hostname. For non-GUI Ubuntu servers, run sudo vi /etc/hostname and sudo vi /etc/hosts and modify them one by one. In both files, change the name as desired and save them. Finally, restart your computer for the changes to take effect.
How to get back to root?
To gain root access, you can use one of several methods:
How do I change my username in Unix?
The direct way to do this is:
11 Oct 2012
How do I change a username on Linux?
The procedure is very simple:
7 Sept 2019.
How can I root on Linux?
File and directory commands
July 2, 2016
How do I log in as root on Linux?
How do I set a root password?
22 Oct 2018.
How do I change my root password?
What is a root password?
How do I change the name of my terminal?
July 31, 2015
How do I change my hostname?
Command to change Ubuntu hostname
1 month. 2021 .
How do I change the command prompt name?
Can we rename the root user in Linux?
5 answers. In theory, changing /etc/passwd and /etc/shadow would be all you need to “rename” root.
Can you change the root username?
How to change the root user to a normal user on Linux?
How do I change my username on Linux?
How to get back to root?
To gain root access, you can use one of several methods:
How do I change my username in Unix?
The direct way to do this is:
11 Oct 2012
How do I change my WSL username?
April 13th. 2018 .
What is the command to delete a user in Linux?
How to find the root user in Linux?
22 Oct 2018.
How do I change the user?
How can I switch back from root user to normal user?
How do I get back to root on Linux?
How to change directory in Linux terminal
August 9th. 2021 .
How do I change my username?
31 times. 2020 .
How can I login as sudo?
19 times. 2018 .
How do I change my Linux username and password?
25.8. 2021 .
Forum rules
There are no such things as «stupid» questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help. Topics in this forum are automatically closed 6 months after creation.
How do I change the root user name?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
-
Reorx
- Level 12
- Posts: 4039
- Joined: Tue Jul 07, 2009 7:14 pm
- Location: SE Florida, USA
Re: How do I change the root user name?
by Reorx » Sat Jan 11, 2014 5:51 pm
Which DE are you using?
Last edited by Reorx on Sun Jan 12, 2014 1:16 pm, edited 1 time in total.
-
WharfRat
- Level 21
- Posts: 13833
- Joined: Thu Apr 07, 2011 8:15 pm
Re: How do I change the root user name?
by WharfRat » Sat Jan 11, 2014 9:23 pm
usermod -l new_username old_username
Changing the username in Ubuntu
- Change username
- Change group name
- Rename home directory
1. Change username in Ubuntu
usermod -l newUsername oldUsername
Here, I will be changing from sagar
to abhiman
:
usermod -l abhiman sagar

2. Change the Group name in Ubuntu
groupmod -n newUsername oldUsername
For me, I’m changing the group name from sagar
to abhiman
:
groupmod -n abhiman sagar

3. Change the name of the home directory
Technically, not changing the name of the home directory won’t cause any issues. But to make it a seamless experience, you should go for it.
usermod -d new_home_directory -m new_username
As I’m changing to abhiman
, my command looks like this:
usermod -d /home/abhiman -m abhiman


What happens to files owned by the old username?
I hope you will find this guide helpful and if you have any queries or suggestions, let me know in the comments.
Subscribe
Join the newsletter to get the latest updates.
Great! Check your inbox and click the link
Please enter a valid email address!
su other_username
A few things you should know here:
- If you were logged in as a normal user, you’d be asked to enter the password of the other user
- The root user can switch to other users without needing the passwords of those accounts
- If you have sudo access, you can use
sudo su other_username
to switch user without the password of the other user
su -l other_username
compgen -u
Switching to a normal user from root user
su other_username

exit
Customer Referral Landing Page — $100
Cut Your Cloud Bills in Half Deploy more with Linux virtual machines, global infrastructure, and simple pricing. No surprise bills, no lock-in, and the
Switch to another user from a regular user
su other_username

sudo su other_username

Switching users into their login shell
su -l other_username

You can use -p
option instead of -l
to preserve the environment instead of testing them in the new shell.
Forgot your own password or have to reset it for others? Here’s how to change the password in the Ubuntu command line.
Switch to root user
su
When asked, enter the root password:
[email protected]:/root$ su
Password:
[email protected]:~#
sudo su
When asked for the password, enter your account’s password:
[email protected]:~$ sudo su
[sudo] password for abhi:
[email protected]:/home/abhi#
Run a command as another user
su -c command_to_run user_name
The command should be a single argument and hence you should keep it under quotes.
[email protected]:/home/abhishek# su -c "touch a.txt" abhishek
[email protected]:/home/abhishek# ls -l a.txt
-rw-rw-r-- 1 abhishek abhishek 0 Aug 23 07:56 a.txt
[email protected]:/home/abhishek#
I hope you like this handy Ubuntu tutorial.
Subscribe
Join the newsletter to get the latest updates.
Great! Check your inbox and click the link
Please enter a valid email address!