Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I retrieve the home directory of a user

Tags:

salt-stack

let's say I have a service that has a pillar-configured user associated with it now I want to fetch a tar.gz and put it in this user home directory... how do I do that...

user.info return a bunch of data including the home directory.. but how do I get only that ?

iow

foo:
  archive:
    - extracted
    - name {{ <get the user home directory here> }}
...
like image 486
nthiebaud Avatar asked Apr 17 '14 22:04

nthiebaud


People also ask

How do I find the home directory of a user?

(1) A storage folder that contains the user's personal files. Starting with Windows Vista, the Windows home directory is \user\username. In prior Windows versions, it was \Documents and Settings\username. In the Mac, the home directory is /users/username, and in most Linux/Unix systems, it is /home/username.

How do I find the user's home directory in Linux?

String userHome = System. getProperty( "user. home" ); to get the home directory of the user on any platform.

How do I find the path to my home directory?

By default, all non-root user home directories are located in a directory named "home", below the / (root) directory - in the path of /home. For example, for a Linux user named cwest, the home directory is in the path of /home/cwest. The home directory for the bbest user is in the path of /home/bbest.


1 Answers

Trial and error got me there:

{% set my_user = ..get your pillar user or default to a sane value.. %}

{{ salt['user.info'](my_user).home }}

resolves to the user's home directory

like image 63
nthiebaud Avatar answered Oct 03 '22 18:10

nthiebaud