Introduction to Linux. Lesson 3. Moving a user and its home directory. Lab.
357
This section will demonstrate how to put together some of the topics and utilities covered so far in this chapter. The elegant design of Linux allows you to combine simple commands to perform advanced operations. Sometimes in the course of administration you might have to move a user and its files around. This section will cover the process of moving a user’s home directory. In this section, you are going to move the user named “project5” from his default home directory /home/project5 to /export/home/project5. You will also have to set the proper permissions and ownership of the user’s files and directories so that the user can access it. Unlike the previous exercises, which were performed as a regular user (the user yyang), you will need superuser privileges to perform the steps in this exercise.
TIP The dashes (-) you used here with the tar command force it to first send its output to stdout and then receive its input from stdin. 12. Use the ls command to ensure that the new home directory was properly created under the /export directory. Type [root@fedora-serverA ~]# ls -R /export/home/ /export/home/: project5 /export/home/project5: a b c d e 13. Make sure that project5 has complete ownership of all the files and directories in its new home. Type [root@fedora-serverA ~]# chown -R project5.project5 /export/home/project5/ 14. Now delete project5’s old home directory. Type [root@fedora-serverA ~]# rm -rf /home/project5 15. Good, we are almost done. Try to temporarily assume the identity of project5 again. Type [root@fedora-serverA ~]# su - project5 su: warning: cannot change directory to /home/project5: No such file or directory -bash-3.2$ Ah… one more thing left to do. We have deleted the user’s home directory (/home/project5), as was specified in the /etc/passwd file, and that is why the su command complained. 16. Exit out of project5’s profile using the exit command. Type -bash-3.00$ exit 17. Now we’ll use the usermod command to automatically update the /etc/passwd file with the user’s new home directory. Type [root@fedora-serverA ~]# usermod -d /export/home/project5 project5 NOTE On a system with SELinux enabled, you might get a warning about not being able to relabel the home directory. You can ignore this warning for now.
Content type
Image
Digest
Size
91 MB
Last updated
almost 9 years ago
docker pull marlabsdocker/lesson3