Make a subdirectory the root directory


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Make a subdirectory the root directory
# 1  
Old 02-26-2014
Make a subdirectory the root directory

I have a series of configuration files to deliver to multiple unix environments (dev, test, bench, prod etc). However I don't to modify them for each environment.

The files are text which currently contain this type of directory information

Code:
IN=/DVT/ms/sas/reception/PIL_QPA_SID/GSPIN001
OUT=/DVT/ms/sas/emission/PIL_QPA_SID/GSPIN001
TEMP=/DVT/data/PIL_QPA_SID/GSPIN001/TEMP
REJECT=/DVT/data/PIL_QPA_SID/GSPIN001/REJECT

However I want to deliver a file which contains this.

Code:
IN=/ms/sas/reception/PIL_QPA_SID/GSPIN001
OUT=/ms/sas/emission/PIL_QPA_SID/GSPIN001
TEMP=/data/PIL_QPA_SID/GSPIN001/TEMP
REJECT=/data/PIL_QPA_SID/GSPIN001/REJECT

These configuration files will be used by a 3rd party ETL tool called Datastage. Datastage requires a unix login.

Is it possible to configure a Unix user so that it believes a certain directory is the root. In this case for a user in the development environment, it would be /DVT. Thus if I login with this user and do an ll I would only see
Code:
/ms
/data

And
Code:
cd ..

would not take me up a level.

If there is an alternative which achieves this, I am open to this.

Thanks
# 2  
Old 02-26-2014
Have a look at chroot man pages to see if that can do what you want...
# 3  
Old 02-26-2014
chroot can do exactly that. But what do you expect the user to do in that environment? No /bin or /usr/bin so he could not run ls or any other command. ls, when used with -l, really needs to look stuff up in /etc/passwd and /etc/group but they are not around. It takes quite a bit of planning to create a chrooted environment that will work.
# 4  
Old 02-26-2014
That is a very good point. In essence, the user just has to be able to run a Datastage job and be able to create and delete files within the /DVT area.

However, there are Datastage routines which shell out to Unix to run wc -l and head etc.

Must I create a subdirectory within my system to hold all of the bin commands or can I include them in the chroot definition ?

How would this be configured ?

Are there any alternatives to Chroot ?

Thanks
# 5  
Old 02-26-2014
Quote:
Is it possible to configure a Unix user so that it believes a certain directory is the root
See post #3
And what perderabo is saying, that a good chroot is one a user has no doubt on what he is seeing, takes some time to figure out, because the main point is not to make a 2nd copy, but to have a restricted environment that is functional , e.g. it has all it needs to do what it is supposed to... and nothing more...
If the main purpose it trying to limit what a user can see, try a restricted shell like rksh...
# 6  
Old 02-26-2014
Just on the train surfing a little.
Not sure if this c/would work...

Make a minimal install into an image, then bind loop mount the data dir inside the image.
The image containing and the loop mount might work inside the chrooted - already mounted and datafolder sharing lokal-chroot-dir.

Thus all you'd later need to handle was a 2-4gb imagefile and the real data on the comuter.
Of course, dont forget about the file permissions for the proper UIDs, host system id and image system id.

Hth
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching File in Directory and all Subdirectory and Delete

Hi All, My directory structure is like Directory1 SubDirectory1 SubDirectory2 SubDirectory3 I have main directories and subdirectories underneath. I want to write a shell script where I will be passing file name as a parameter, Now I want to find all the files in Directory1... (19 Replies)
Discussion started by: John William
19 Replies

2. Shell Programming and Scripting

Remove all files except the subdirectory(without pattern) in a directory

I used rm * and it deleted the files in the directory but gives and error message for unsuccessful subdirectory deletion. "rm: cannot remove 'DirectoryName': Is a directory" I dont want to explicitly get the above error. What are the modifications I have to do in the rm command? (3 Replies)
Discussion started by: duplicate
3 Replies

3. Shell Programming and Scripting

Changing ownership of a directory, subdirectory and files as same as in another server

accidentally i have changed ownership of a directory,subdirectory and files wil below command. I want to the change ownership back as same as in same directory on another server. How can i do it? chown -R user:group /u01 is there any simple script? it is really an urgent need.. (2 Replies)
Discussion started by: johnveslin
2 Replies

4. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46Any ideas how can we do this? Got a sun cluser global mount point which takes ages to mount everytime, need to understand... (5 Replies)
Discussion started by: jakerock
5 Replies

5. UNIX for Dummies Questions & Answers

How to move all files in a directory and subdirectory?

I'm trying to organize my MB Pro by moving all my jpeg files to a single folder from the desktop. There are some on the desktop that are not in any folder. I was at the command line and typed mv *.jpg "Jpeg files" but it only moved the files that were on the desktop, not any of the ones that... (3 Replies)
Discussion started by: Straitsfan
3 Replies

6. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

7. Shell Programming and Scripting

How to list directory and subdirectory?

Hi, I want to list all the directory and subdirectories under any directory. For eg. i am in a directory called A and want to check all directories under A. Output should be as below. /A /A/a1 /A/a1/a2 /A/b1 /A/c1/c2 A,a1,a2,b1,c1 and c2 all are directories.Just for Eg. Please... (7 Replies)
Discussion started by: anshu ranjan
7 Replies

8. Shell Programming and Scripting

Find command, -name by directory and subdirectory?

Hi All, I'm trying to use the find command to return matches for a directory and file. For example, given the following directories: /one/two/three/file1.txt /one/three/two/file1.txt /one/four/two/three/file1.txt I'm expecting the following to be returned: ... (16 Replies)
Discussion started by: makodarear
16 Replies

9. Shell Programming and Scripting

Find files in directory and its subdirectory

I am writing a script which reads a file line by line and then assigns it to a variable like this 1090373422_4028715212.jpg. I have images with file name of this format in some other directory. In my script I want to assign variable with this file name and then find this filename in some other... (11 Replies)
Discussion started by: jyotib
11 Replies

10. Shell Programming and Scripting

How to calculate file's size in directory and subdirectory

Hi, I have written one script to calculate total space of all file in one directory, ignoring subdirectory, it works fine. Now, I've been trying to calculate all files which includes files in any subdirectories. I use recursive function to do this, but it can work only if there is only one... (4 Replies)
Discussion started by: KLL
4 Replies
Login or Register to Ask a Question