6.2.9 Ensure users own their home directories (Scored)

Level 1 - Server
Level 1 - Workstation 

The user home directory is space defined for the particular user to set local environment variables and to store personal files..

Since the user is accountable for files stored in the user home directory, the user must be the owner of the directory.

Run the following script and verify no results are returned:

cat /etc/passwd | awk -F: '{ print $1 " " $3 " " $6 }' | while read user uid dir; do
  if [ $uid -ge 1000 -a -d "$dir" -a $user != "nfsnobody" ]; then
  owner=$(stat -L -c "%U" "$dir") 
    if [ "$owner" != "$user" ]; then
    echo "The home directory ($dir) of user $user is owned by $owner." 

Change the ownership of any home directories that are not owned by the defined user to the correct user.

  • ubuntu1604/6/2/9.txt
  • Last modified: 2017/05/04 14:38
  • by Piotr K┼éoczewski