11

I have changed the username of a user.

Commands:

killall -u username
usermod -l new_username old_username
groupmod -n new_groupname old_groupname
usermod -d /home/new_username -m new_username
usermod -c "New Name" new_username

chown new_username:new_groupname .Xauthority

I want to know if changing the home directory from for example /home/test/ to /home/ubuntu/ will affect any applications.

I have already installed RVM, Ruby, Rails, Oracle and a few more.

techraf
  • 3,316
Chetan
  • 143

3 Answers3

4

It should work.

Some applications will store absolute pathnames in their configuration files or in other files they keep. You will have to change those manually or set up the user-specific parts of the application again.

You can search for these files as follows (at least the ones that store the pathnames as text):

find /home/new_username -type f -exec egrep -H '/home/old_username' {} \;

That command won't fix the files. It will only find them for you. You could use sed to change the files. Something along the lines of:

find /home/new_username -type f -exec egrep -l '/home/old_username' {} \;|xargs sed -i 's%/home/old_username%/home/new_username/‌​;g'

Please test first.

Note that some files might seem to be text files, but actually are binary files. Doing a search-and-replace on these files can break them.

Note: You don't need to use chown -R new_username:new_groupname /home/new_username to transfer ownership of the files in the new home directory to the new user, because the UID for the "new user" is the same as for the "old user", so then the files are already owned by the "new user".

NZD
  • 3,301
  • 1
  • 15
  • 22
1

the only thing that work for me was:

sudo gedit /etc/passwd

sudo gedit /etc/group

and made the changes that I wanted manually!

0

Small update: You have to create (if not exists) admin's account or activate root account first. Enter that account and proceed. Also be patient. Some processes won't be killed immediately. Wait a bit, since usermod -l will fail saying that you still have some process(es) running. Repeat killall once again

edulov
  • 1