how to find out the home directory of a user??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to find out the home directory of a user??
# 8  
Old 04-08-2008
You should avoid cat of a single file. Grep can read the file just fine, you don't need cat to feed it.

Code:
#!/bin/sh

case $# in 0) echo foo: need an argument >&2; exit 1;; esac

for i in "$@"; do
  grep "$i" /etc/passwd | cut -d: -f6
done

Pay attention to the quoting; you want to avoid throwing an error if somebody calls your script with a string with spaces in it, or (worse yet) an actual shell command which gets executed and has dire side effects (think `rm -rf $HOME` in backticks).

You should probably actually grep "^$i:" to avoid accidentally printing the wrong information because of a coincidental substring match. (True story: grep era /etc/passwd would find "System Operator" and print root's home directory on BSD.)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question
FLAMEROBIN(1)						   Firebird Administration Tool 					     FLAMEROBIN(1)

NAME
flamerobin -- management and data manipulation tool for the Firebird DBMS SYNOPSIS
flamerobin [-h directory | --home=directory] [-uh directory | --user-home=directory] DESCRIPTION
flamerobin is a graphical frontend to the Firebird DBMS. It is small and simple, yet offers all the basic features needed to create and manipulate databases, execute queries and perform administrative tasks. This manual page only documents the run-time options and environment of flamerobin. Information about using the GUI may be obtained by selecting the Help -> Manual menu item once the application is running. flamerobin uses two directory hierarchies for its normal operation. The data directory contains the templates for property pages, the default configuration and the on-line documentation grouped into three sub-directories as follows: conf-defs default configuration docs on-line documentation html-templates templates for property pages The user home directory contains the per-user configuration, comprising three entries: fr_databases.conf this file stores the user's registered databases. fr_settings.conf this file stores the user's preferences related to the flamerobin GUI. history this directory holds the SQL statement history, one item per file. flamerobin accepts several options, which are described as follows: -h directory --home=directory Use directory as the data directory (but see ENVIRONMENT below). -uh directory --user-home=directory Use directory as the user home directory (but see ENVIRONMENT and CAVEATS below). ENVIRONMENT
FR_HOME Specifies an alternate location for the flamerobin data directory. If both -h (or --home) and this environment variable are set, the command line argument takes precedence. FR_USER_HOME Specifies an alternate location for the flamerobin user home directory. If both -uh (or --user-home) and this environment variable are set, the command line argument takes precedence. FILES
/usr/share/flamerobin The default flamerobin data directory. ~/.flamerobin The default flamerobin user home directory. AUTHORS
flamerobin was written by The FlameRobin Development Team <http://www.flamerobin.org/>. CAVEATS
flamerobin only writes files under the user home directory. If flamerobin is configured so that this directory and the files contained therein are shared among several users or concurrent instances of flamerobin, no precaution is taken to avoid overwriting settings created by other users or other application instances. NOTES
The specification of the data directory and the user home directory (regardless of whether they occur in the environment or on the command line) may be the literal string ``$app'' which translates to a common data folder determined at compilation time, or ``$user'' which trans- lates to the user local data directory. These options currently have effect only on Windows platform. FlameRobin 0.7 April 12, 2006 FlameRobin 0.7