When I ssh into my server and login as t root user and I'm getting the following error on screen:
Could not chdir to home directory /root: No such file or directory
How do I fix this error under CentOS or Debian Linux server?
The error message is clear. /root home directory does not exists or deleted by you. If you see the following error:
Could not chdir to home directory /home/vivek: No such file or directory
It means when you created a user called vivek, the home directory /home/vivek was not created. To fix this problem create missing directory and apply current permission. To create a directory called /root and set permission, type:
# mkdir /root
# chown root:root /root
# chmod 0700 /root
To create a directory called /home/vivek and set permission, type:
# mkdir /home/vivek
# chown vivek:vivek /home/vivek
# chmod 0700 /home/vivek
Try to login as vivek:
# su - vivek
Please note that you may need to adjust directory owner, group, and permissions as per your setup.
Finding more information about the user account
- vivek: Login name / username
- x : Password: An x character indicates that encrypted password is stored in /etc/shadow file.
- 1000: User ID (UID)
- 1000: The primary group ID (stored in /etc/group file)
- Vivek Gite: The comment field. It allow you to add extra information about the users such as user's full name, phone number etc. This field use by finger command.
- /home/vivek: Home directory
- /bin/bash: The absolute path of a command or shell (/bin/bash)
$ getent group vivek
vivek:x:1000:Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop