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:
-
Open the Terminal.
-
Run the following command, replacing
usernamewith the actual name of the user whose home directory you want to verify:grep '^username:' /etc/passwdFor example, if you want to verify the home directory for a user named
joker, you would run:grep '^joker:' /etc/passwd -
Check the Output: The output will show a line formatted like this:
username:x:UID:GID:full name:/home/new_home_directory:/bin/shThe sixth field (the part after the fifth colon) indicates the user's home directory.
-
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.
