How to get home directory of a prticular user in bash scripting or a single command

The below command gets the home directory of user if at all the user exists
 
getent passwd naresh | cut -f6 -d:

2 comments:

Drupal programmers said...

thanks for the commands

Custom Application Development said...

There is a command specifically for this: getent

getent passwd someuser | cut -f6 -d: