Sponsored Content
Top Forums Shell Programming and Scripting how to find out the home directory of a user?? Post 302183138 by DukeNuke2 on Tuesday 8th of April 2008 11:18:57 AM
Old 04-08-2008
there are many ways....

Code:
$ cd
$ pwd

$ echo $HOME

$ grep username /etc/passwd

hth,
DN2
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How can I forbid a user to go up his home directory

Hi everybody, How can I forbid a user to go up his home directory ? Thanks MarcoW (2 Replies)
Discussion started by: MarcoW
2 Replies

2. UNIX for Dummies Questions & Answers

user home directory problem

The home directory for me on my system is on /home/kwon. It was created using "useradd kwon" When i go to change the home directory for a user doing a usermod -d /home/test when they log on it gives them messages saying to generate new ssh keys, and it does. It gives me a thing that says... (1 Reply)
Discussion started by: BangYourWallnut
1 Replies

3. UNIX for Dummies Questions & Answers

Specifying FTP user Home Directory

Hi, I am running Solaris 10 and I am using the ftp server that comes with it. I would like to specify a specific directory as ftp user's home directory. For example, if "ftpuserx" ftps into my solaris machine, they will automatically be taken to "/space/web" directory, even though there... (0 Replies)
Discussion started by: annointed3
0 Replies

4. Solaris

Restricting SFTP user to a defined directory and home directory

Hi, I've created solaris user which has both FTP and SFTP Access. Using the "ftpaccess" configuration file options "guest-root" and "restricted-uid", i can restrict the user to a specific directory. But I'm unable to restrict the user when the user is logged in using SFTP. The aim is to... (1 Reply)
Discussion started by: sftpuser
1 Replies

5. Red Hat

User's home directory

Hi, By default user's home directory will be /home/$user. I want to change it to /javauser/$user. How can I do it? Thanks Jeevan. (5 Replies)
Discussion started by: jredx
5 Replies

6. Solaris

Home Directory for oracle user

Hello all, I am Installing Oracle 11g on my Solaris OS. I created the below oracle user: # /usr/sbin/useradd -g oinstall -G dba oracle but when i am trying to to su - oracle it give me the below error No directory Do i have to setup a home directory for oracle user? and how can i do... (1 Reply)
Discussion started by: beayni33
1 Replies

7. UNIX for Dummies Questions & Answers

Restricting a user to their home directory and below

I found this old closed thread: I can do these things, but how to I change someone's profile - where do I find the profile? I'm running Centos 5.6 ~~~~~~~~~ providing you have the password shell set to ksh, you can put this in his .profile: cd /opt/load alias -x cd=: (6 Replies)
Discussion started by: jjj0923
6 Replies

8. UNIX for Dummies Questions & Answers

User's home directory not being created

I am trying to create Oracle user. I will install oracle after that. But my problem is /home/oracle directory is not being created. bash-3.2# useradd -g oinstall -G dba,oper -d /home/oracle -m oracle cp: /home/oracle: Operation not applicable chown: /home/oracle: No such file or directory ... (3 Replies)
Discussion started by: hubatuwang
3 Replies

9. Shell Programming and Scripting

Trying to delete a user and home directory

Good Afternoon, I'm trying userdel -r username on Solaris 9 and getting UX: userdel: ERROR: unable to find status about home directory: No such file or directory I see the user's home directory and getent passwd shows the user Anybody know what's causing it? (2 Replies)
Discussion started by: Stellaman1977
2 Replies

10. Solaris

SunOS confusing root directory and user home directory

Hello, I've just started using a Solaris machine with SunOS 5.10. After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me I'm at my home directory (someone configured "myuser" as default user after init). ... (2 Replies)
Discussion started by: egyassun
2 Replies
GETPWENT_R(3)						     Linux Programmer's Manual						     GETPWENT_R(3)

NAME
getpwent_r, fgetpwent_r - get passwd file entry reentrantly SYNOPSIS
#include <pwd.h> int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp); int fgetpwent_r(FILE *fp, struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): getpwent_r(), _BSD_SOURCE || _SVID_SOURCE fgetpwent_r(): _SVID_SOURCE DESCRIPTION
The functions getpwent_r() and fgetpwent_r() are the reentrant versions of getpwent(3) and fgetpwent(3). The former reads the next passwd entry from the stream initialized by setpwent(3). The latter reads the next passwd entry from the stream fp. The passwd structure is defined in <pwd.h> as follows: struct passwd { char *pw_name; /* username */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user ID */ gid_t pw_gid; /* group ID */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ }; The nonreentrant functions return a pointer to static storage, where this static storage contains further pointers to user name, password, gecos field, home directory and shell. The reentrant functions described here return all of that in caller-provided buffers. First of all there is the buffer pwbuf that can hold a struct passwd. And next the buffer buf of size buflen that can hold additional strings. The result of these functions, the struct passwd read from the stream, is stored in the provided buffer *pwbuf, and a pointer to this struct passwd is returned in *pwbufp. RETURN VALUE
On success, these functions return 0 and *pwbufp is a pointer to the struct passwd. On error, these functions return an error value and *pwbufp is NULL. ERRORS
ENOENT No more entries. ERANGE Insufficient buffer space supplied. Try again with larger buffer. CONFORMING TO
These functions are GNU extensions, done in a style resembling the POSIX version of functions like getpwnam_r(3). Other systems use proto- type struct passwd * getpwent_r(struct passwd *pwd, char *buf, int buflen); or, better, int getpwent_r(struct passwd *pwd, char *buf, int buflen, FILE **pw_fp); NOTES
The function getpwent_r() is not really reentrant since it shares the reading position in the stream with all other threads. EXAMPLE
#define _GNU_SOURCE #include <pwd.h> #include <stdio.h> #define BUFLEN 4096 int main(void) { struct passwd pw, *pwp; char buf[BUFLEN]; int i; setpwent(); while (1) { i = getpwent_r(&pw, buf, BUFLEN, &pwp); if (i) break; printf("%s (%d) HOME %s SHELL %s ", pwp->pw_name, pwp->pw_uid, pwp->pw_dir, pwp->pw_shell); } endpwent(); exit(EXIT_SUCCESS); } SEE ALSO
fgetpwent(3), getpw(3), getpwent(3), getpwnam(3), getpwuid(3), putpwent(3), passwd(5) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2007-07-26 GETPWENT_R(3)
All times are GMT -4. The time now is 04:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy