LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 09-21-2010, 09:58 AM   #1
Virchanza
LQ Newbie
 
Registered: Aug 2009
Posts: 26

Rep: Reputation: Disabled
How to make a public folder within a private folder?


My Linux username is "virchanza" and my group is "virchanza". Here's how my home folder looks:

Code:
virchanza$ ls -alhd /home/virchanza
drwx------ 59 virchanza virchanza 20K 2010-09-21 20:55 virchanza
As you can see, I have full access to my home folder, but my "group" and "others" have no access whatsoever.

Inside my home folder, I want to create a publicly accessible folder called "public_stuff":

Code:
virchanza$ cd
virchanza$ mkdir public_stuff
virchanza$ chmod 777 public_stuff
virchanza$ ls -alhd public_stuff
drwxrwxrwx 2 virchanza virchanza 4.0K 2010-09-21 21:32 public_stuff
OK, you can see that this "public_stuff" folder has full access permissions for everyone. Now I'm gonna create a file inside this folder:

Code:
virchanza$ cd public_stuff
virchanza$ echo "One two three four five" > file.txt
virchanza$ chmod 777 file.txt
virchanza$ ls -alh
total 40K
drwxrwxrwx  2 virchanza virchanza 4.0K 2010-09-21 21:35 .
drwx------ 60 virchanza virchanza  20K 2010-09-21 21:32 ..
-rwxrwxrwx  1 virchanza virchanza   24 2010-09-21 21:35 file.txt
Now I'm going to navigate back to the "/home" folder and switch to a different user

Code:
virchanza$ cd /home
virchanza$ su guest_user
Password:
guest_user$ cat /home/virchanza/public_stuff/file.txt
cat: /home/virchanza/public_stuff/file.txt: Permission denied
guest_user$
I thought this would work... but it doesn't.

How do I make a publicly-accessible folder within my private home folder?
 
Old 09-21-2010, 10:05 AM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
In order for someone to see a file a few permissions need to be in place:

First, they have to have access to the file itself which you've done.
Second, All the directories leading to that file must be executable by the person who wants to browse to this file.

I would recommend setting up a public location in a common directory rather than in your home directory for this purpose.

Regards,

Alunduil
 
Old 09-22-2010, 12:18 AM   #3
Virchanza
LQ Newbie
 
Registered: Aug 2009
Posts: 26

Original Poster
Rep: Reputation: Disabled
Hey Alunduil thanks a lot for your reply.

I got everything working the way I wanted it.

The "public folder" which I want to keep inside my private home folder actually contains the files for my website (I have a web server demon running on my machine) . I want to keep my website files within my home folder.

I added "o+x" to my home folder permissions so now everything is working fine (people can navigate into my home folder but they are unable to view its contents because I didn't specify "o+r" for my home folder).

Thanks a lot for your help!

Virchanza
 
Old 09-22-2010, 08:13 AM   #4
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
No problem. Just for further edification:

* If you would ever need to delete that user (which I doubt you would) you don't want to delete the user's information because now the website would be deleted as well.
* Setting up websites that are accessible in this manner is typically best solved by setting up the website in a www directory (usually in /var) and then symlinking that directory into the home directory.

I'm glad everything is working just wanted to provide a couple of alternatives.

Regards,

Alunduil
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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: permission for sharing public and private folder zamri Linux - Software 16 02-02-2011 07:49 AM
[SOLVED] Symlink on public folder - problem or not konzo Linux - Security 1 07-22-2010 09:26 AM
Samba Public Folder eth4rendil Linux - Server 2 05-06-2009 06:59 AM
how can I set a public folder in samba combilli Linux - Software 2 11-25-2006 08:50 AM
Samba Public Folder DerrickCheang Linux - Newbie 3 10-29-2002 06:04 AM


All times are GMT -5. The time now is 10:51 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration