simple script to mount a folder in all users /home


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple script to mount a folder in all users /home
# 1  
Old 12-09-2010
simple script to mount a folder in all users /home

Go easy on me - first post

I need a simple script that will mount a directory in the /home folder of all users. I need to run this on boot and regular intervals as a cron job. I was hoping to achieve this by modifying fstab but it is not possible and I would like to avoid symlinks.

I have no scripting experience. Thanks for any help.
# 2  
Old 12-09-2010
Can you say why it needs to be done at "regular intervals" if it's done "on boot", and why you need to avoid symbolic links?

After all symbol links would make life much easier.
# 3  
Old 12-09-2010
Thanks for your reply,
Actually you're right, it will only need to run at boot and when a new user is added.

I wanted to avoid symlinks as I want to jail users to their home folder for ftp access.
# 4  
Old 12-09-2010
A simple script would be:

Code:
ls /home | xargs -n1 -I{} mount /some/place /home/{}

But it's hardly scientific (being simple, and making many assumptions) Smilie
# 5  
Old 12-09-2010
Thanks for this, I will have a go over the weekend.

For my education could you explain how the script works and what assumptions it makes?
Thanks again
# 6  
Old 12-09-2010
It works by listing the /home directory and running the mount command against each of them.

The assumptions would be that /home is the correct directory, and is a directory, not a link to where that directory actually is; that users are local users and not remote (like AD / LDAP) users with auto-mounted home directories; and that there's nothing in "/home" that isn't a user's home directory. That kind of thing! Generally the kind of assumptions anyone could make without knowing exactly how your setup looks.
# 7  
Old 12-10-2010
Thanks for your help.

The home directory is on a separate partition and mounted as /home from the fstab, the users login to a samba PDC via LADP but have a real local user accounts stored in /home/username. I assume this script will still work?

Also, how do get the script to check the directory for the mount point exists and create it if it does not?
Thanks

Last edited by barrydocks; 12-10-2010 at 04:45 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple script for adding users

Hi guys, I've a simple linux script (made by my friend), which adds users to the system from userlist file. it also creates user home dir and copies certain files to the directory. To be honest, am a newbie in scripting so am unable to fully understand how the script is working. unfortunately,... (30 Replies)
Discussion started by: vish6251
30 Replies

2. Red Hat

sftp configuration | to lock users to their home folder.

In generally I use vsftp but I want to improve our security so I decide to use sftp instead of vsftp. We know that ssh,scp and sftp are in openssh server. How can I lock only sftp user to their home folder? And to prevent some users for sftp like root as such in vsftp daemon? (3 Replies)
Discussion started by: getrue
3 Replies

3. Shell Programming and Scripting

Get Home Directory for Users in Login Hook Script

I'm writing a script to use as a LoginHook for my Mac users. As part of this script, I need to write to a location in their home directory, but I can't seem to access the path - at this point in the login process, $HOME is empty and ~ gives the path to root's home. Unfortunately, I can't just do... (1 Reply)
Discussion started by: blondepianist
1 Replies

4. Shell Programming and Scripting

script to check for a directory in /home for all users

Following on from this post: https://www.unix.com/shell-programming-scripting/150201-simple-script-mount-folder-all-users-home.html and getting told off for bumping the thread:( Please could someone help me with a short script to check is a certain directory is present in /home for all users... (8 Replies)
Discussion started by: barrydocks
8 Replies

5. IP Networking

Can't see home folder on one NFS mount but can in another mount on another share

Hello, I have a few Ubuntu 9.10 laptops I'm trying to learn NFS sharing with. I am just experimenting on this right now, so no harsh words about the security of what I'm playing with, please ;) Below are the configs /etc/exports on host /home/woodnt/Homeschool... (2 Replies)
Discussion started by: Narnie
2 Replies

6. Solaris

home dir mount issue

Hi all, I have to mount my home directory in one box, by default everyone's home directory will mount in all unix boxes which we have. But we have unmounted these home directories from some boxes to keep the data as safe. So for automation purpose i need my home directory only in those boxes to... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

7. Shell Programming and Scripting

Shell script to execute commands in individual users' home directories

Hi, I am trying to write a shell script which execute certain commands within certain folders in each user's home directories I started off with a bash script - #!/bin/csh -f su -l cvsusr1 cvs -d /home/cvsadm/repository status But the shell script finishes immediately after... (1 Reply)
Discussion started by: rupa_lahiri
1 Replies

8. Shell Programming and Scripting

copy some files from users home folders to my folder

i have users home directories in /home all the users have some files starting with character e and i want to copy all these files in a folder in my (root) home using a script i tried the script for i in m5 do cd m5 cp e1* /home/pc/exam cd .. done but get these... (3 Replies)
Discussion started by: pcrana
3 Replies

9. Ubuntu

how to mount /home on NIS client machine

Hi All, can anyone tell me how to mount NIS user /home/<username> directory on the client machine in Ubuntu. Thanks (3 Replies)
Discussion started by: daya.pandit
3 Replies

10. UNIX for Dummies Questions & Answers

NFS mount home directory

Hello All, I have a question that I think I have the answer to but I'm not sure. All the information I get kind of dance around it. Well, my question is if you have NFS running, automount running, with auto_master and auto_home on a server. If a user logs in form cleint machine that has... (3 Replies)
Discussion started by: larry
3 Replies
Login or Register to Ask a Question