How can we verify the change in the user's home directory?

QuestionsQuestions8 SkillsProUser Account ManagementSep, 05 2025
0104

To verify the change in a user's home directory in a Linux system, you can use the grep command to check the /etc/passwd file, which contains user account information, including the home directory. Here’s how to do it:

  1. Open the Terminal.

  2. Run the following command, replacing username with the actual name of the user whose home directory you want to verify:

    grep '^username:' /etc/passwd

    For example, if you want to verify the home directory for a user named joker, you would run:

    grep '^joker:' /etc/passwd
  3. Check the Output: The output will show a line formatted like this:

    username:x:UID:GID:full name:/home/new_home_directory:/bin/sh

    The sixth field (the part after the fifth colon) indicates the user's home directory.

  4. Verify the Path: Ensure that the path shown is the new home directory you set. If it matches, the change was successful.

Example

If you changed the home directory of joker to /home/wayne, the output should look like this:

joker:x:5001:5001::/home/wayne:/bin/sh

This confirms that joker's home directory has been updated to /home/wayne.

0 Comments

no data
Be the first to share your comment!