LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-29-2015, 06:43 PM   #1
fshah
Member
 
Registered: Apr 2013
Posts: 45

Rep: Reputation: 0
Post Want to share folder on every user login on the system


Hi Everyone

I want to share folder on every user who login to the system on his desktop whether he has a local user acccount or login using ldap server. Folder should be placed on his desktop. Does any one has suggestions?

Regards
 
Old 06-29-2015, 07:25 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by fshah View Post
Hi Everyone

I want to share folder on every user who login to the system on his desktop whether he has a local user acccount or login using ldap server. Folder should be placed on his desktop. Does any one has suggestions?

Regards
Use a symbolic link or a hard link and give the folder appropriate permissions.
 
Old 06-30-2015, 08:40 AM   #3
fshah
Member
 
Registered: Apr 2013
Posts: 45

Original Poster
Rep: Reputation: 0
Suppose I have folder "test" on root of the file system. I want when any one login to the system whether first time that folder must be placed on his desktop. How I can accomplish this using soft or hard link.

Regards
 
Old 06-30-2015, 11:55 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by fshah View Post
Suppose I have folder "test" on root of the file system. I want when any one login to the system whether first time that folder must be placed on his desktop. How I can accomplish this using soft or hard link.
First, ensure that /test has rwx permissions for your users.

Assuming that on your system the desktop is in $HOME/Desktop, do the following after adding a user:

Code:
ln -s /test /home/new_user/Desktop
chown new_user:new_user /home/new_user/Desktop
This sets a symbolic link onto the user's desktop.

Perhaps you can automise it by making this link in /etc/skel/Desktop. See the man page for useradd for details.

Last edited by berndbausch; 06-30-2015 at 11:56 PM.
 
Old 07-01-2015, 01:10 AM   #5
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
First you need to give read write permission to the directory so any user would be able to modify it as it was said.

You can create a shell script for it so it will make link of test folder on Desktops of all users in one run.
If new users will be registered, you can add this script in cron so you do not need to run ln command everytime manually. Cron will do the work for you. Create link of test folder on desktop if it does not exist.

Whether new user is registered or not, you can check it from /etc/passwd file or if all user home folders in one directory like /home. you can check there. If there is new entry, create a link on the desktop.
 
Old 07-05-2015, 08:49 PM   #6
fshah
Member
 
Registered: Apr 2013
Posts: 45

Original Poster
Rep: Reputation: 0
@eklavya Can you create a shell script for me?
 
Old 07-07-2015, 12:23 AM   #7
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
We need to see your efforts first. What have you written so far? Paste your code here and we will definitely help you to solve your problem.
 
Old 07-07-2015, 07:36 PM   #8
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by berndbausch View Post
Code:
ln -s /test /home/new_user/Desktop
chown new_user:new_user /home/new_user/Desktop
My advice is not quite correct and, it seems, needs to be more detailed, so let me amend it.
Before writing a script, you need to test the approach. For example:
  • Create two users, let's call them user1 and user2. I assume that their Desktop directories are /home/user1/Desktop and /home/user2/Desktop.
  • Create a group for all those users that are supposed to access the shared directory. Let's call it common.
  • Add that group to the new users. On the command line, this is done as follows:
    Code:
    usermod -a -G common user1
    usermod -a -G common user2
  • Ensure that the /test directory can be accessed and written by members of group common. One way to do that is
    Code:
    chgrp common /test
    chmod g+rwx /test
  • Link /test to the users' Desktop directory
    Code:
    ln -s /test /home/user1/Desktop
Now log on as user1 and user2 and test if they can use the folder in the intended way.

Once you are satisfied it all works, run a script like this each time you create a new user:
Code:
usermod -a -G common $1
ln -s /test /home/$1/Desktop
Let's call the script "setuptest". The $1 is a command line argument. For each user that requires /test to be on the Desktop, run "setuptest nameoftheuser". You can do that in a loop:
Code:
for u in anne bob chris daniel erika fshah
do
    setuptest $u
done
 
  


Reply

Tags
desktop, shareddirectory, ubuntu 14.04



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
samba folder share user permission ac_kumar Linux - Newbie 3 12-23-2013 10:56 AM
Redirect an app resource folder from system /usr/share to /home/user/[app]/usr/share minyor Linux - Software 2 04-23-2013 06:44 AM
how to share a folder in samba with no need of password for individual user not guest golden_boy615 Linux - General 5 06-18-2011 06:13 AM
how to share a folder in samba with no need of password for individual user not guest golden_boy615 Linux - Newbie 6 06-14-2011 01:11 AM
[SOLVED] How to Share Folder For Windows Base System k_oudom SUSE / openSUSE 1 10-14-2009 09:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration