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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
As which user did you execute that command and did Bob have any running jobs/instances?
From the manpage:
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.
-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
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
-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 ?