Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As which user did you execute that command and did Bob have any running jobs/instances?
From the manpage:
Quote:
usermod will not allow you to change the name of a user who is logged
in. You must make certain that the named user is not executing any
processes when this command is being executed if the user's numerical
user ID is being changed. You must change the owner of any crontab
files manually. You must change the owner of any at jobs manually. You
must make any changes involving NIS on the NIS server.
I created a user named Bob. Now i want to change its home directory to be Bob1. I did this
usermod -d /home/Bob1 Bob
but not effect !!!
The name was still Bob. What might be issue ?
pls guide me
If you want to move the contents of Bob to Bob1 then you need the -m flag, furthermore if you want the login name to change you need the -l flag.
Code:
-d, --home HOME_DIR
The userīs new login directory.
If the -m option is given, the contents of the current home
directory will be moved to the new home directory, which is created
if it does not already exist.
-l, --login NEW_LOGIN
The name of the user will be changed from LOGIN to NEW_LOGIN.
Nothing else is changed. In particular, the userīs home directory
name should probably be changed manually to reflect the new login
name.
I was simply practicing the usermod command. I am logged in as root. I simply issued the following commands
1) useradd Bob
2) passwd Bob
3) ls /home ( to verify that /home/Bob exists )
4) usermod -d /home/Bob1 Bob
But no effect, i am not logged in as Bob. Any ideas pls ?
[Edit] I am using Centos 5.5. When i add the -m option, it doesnt execute, i am expecting that above usermod command will create a new dir in /home, is that right ?
The -m option moves the content from the old home directory into the new home directory.
useradd Bob - Maybe cent-os lets you do it the way you tried, but: useradd Bob will not work on most distro's (Bob is an illegal name, caps are not allowed. bob would be legal). It also does not create the home directory, you need to add the -m flag.
This would be correct: useradd -m -d /home/bob bob
The following would move all to the new home directory: usermod -d /home/bob -m bob (mind you: usermod -m -d /home/bob bob will not work).
Like I said before, maybe cent-os lets you create users that contain capitals, and also creates the homedir if you do not use the -m flag (talking about the useradd command). Not all distro's do.
I tried your example on my Centos 5.5 box & it works, as specified by the manual
Quote:
-d, --home HOME_DIR
The user's new login directory. If the -m option is given the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.
ie unless you specify the -m option, only the home dir as registered in /etc/passwd is changed.
This enables you to create a new home dir first if necessary, then switch the entry in/etc/passwd.
I was expecting that according to man page, new dir will be created automatically. I can see that entry in etc/passwd is changed but i wasnt seeing bob1 directory under /home. So you mean, my command executed but i need to create the new home dir manually ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.