LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-21-2012, 05:13 AM   #1
suresh.k
Member
 
Registered: Aug 2011
Location: Hyderabad, AP, India
Distribution: centos, Ubuntu
Posts: 163
Blog Entries: 1

Rep: Reputation: Disabled
How to create a user, who can access only his home directory


How to create a user which can access only his home directory .
The user should not see any other directories.

I used the following process,
#adduser user1
And then in /etc/passwd file I edited bash shell to /bin/rbash

then he is not able cd.
but he can view the content of file's with path
for example
# vim /etc/passwd

I want user can not able to view any other files or directories except his

Thanks
Suresh
 
Old 07-21-2012, 05:58 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Privileges are assigned to files and directories, and are given in 3 categories: owner, group, and others. By default, any new user is set up as the owner of everything in their ~ (/home/<username>) directory, and--also by default-- users will not be able to see the files of any other user.

System configuration files are normally set up as "read only" for ordinary users, and executable files as read and execute.

Do you have an example of you would need a new user to have privileges different from the defaults?
 
Old 07-21-2012, 07:39 AM   #3
suresh.k
Member
 
Registered: Aug 2011
Location: Hyderabad, AP, India
Distribution: centos, Ubuntu
Posts: 163
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pixellany View Post
Privileges are assigned to files and directories, and are given in 3 categories: owner, group, and others. By default, any new user is set up as the owner of everything in their ~ (/home/<username>) directory, and--also by default-- users will not be able to see the files of any other user.

System configuration files are normally set up as "read only" for ordinary users, and executable files as read and execute.

Do you have an example of you would need a new user to have privileges different from the defaults?
normal user can read all the files and folders from command prompt.
 
Old 07-21-2012, 09:22 AM   #4
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 54
Quote:
Originally Posted by suresh.k View Post
normal user can read all the files and folders from command prompt.
No, he can't. He can only "see" (read and execute) files that are necessary to perform essential tasks with his computer. If a user can't read/execute any file outside his home directory, how will he be able to use any command in command line?
Maybe you are looking for a chroot jail?
 
Old 07-21-2012, 09:37 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by suresh.k View Post
normal user can read all the files and folders from command prompt.
NO--Except for root, ALL users have permissions based on their username, groups they are assigned to, and "others"

Look --for example--in /etc: Here are two typical permission setups:
-rw-r--r-- 1 root root 5649 Apr 14 13:33 rc_maps.cfg
-rwxr-xr-x 1 root root 684 Jul 3 22:37 rc.multi
As a normal user (not a member of the "root" group) I fall into the "other" category--thus I can read both files, and I can execute one of them.

Then look at the user directories in /home. You will see that only the owner of the files has any privileges at all.

Go here:
http://www.tldp.org/LDP/intro-linux/html/
look at Section 3.4
 
Old 07-21-2012, 10:39 AM   #6
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,731

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
Quote:
Originally Posted by segmentation_fault View Post
Maybe you are looking for a chroot jail?
^ This is my recommendation.

suresh.k - What you're asking for is not possible. The user MUST have access to many of the files outside their home directory, such as /bin/bash, /etc/passwd, etc. Without access to these files, they will not be able to log in or run any commands at all. For example, when you run "mv", you're actually executing a program called mv, which lives in /bin/. If the user doesn't have access to /bin, they can't run mv.

A chroot jail is a way of setting up a new "filesystem" for the user, which contains only the files and directories that the user needs access to. You place this new "filesystem" somewhere on the real filesystem, such as /usr/local/chroot. Inside /usr/local/chroot, you'll have all of the regular bin, etc, home directories. When the user logs in, they are placed in their own home directory in this new "filesystem", and are only able to see the files around them. So what they think is /, or /etc, are actually /usr/local/chroot and /usr/local/chroot/etc.
 
Old 07-21-2012, 12:12 PM   #7
i_joh
Member
 
Registered: Apr 2005
Distribution: Debian
Posts: 82

Rep: Reputation: 5
The restricted shell you are trying to run (rsh) is actually supposed to prevent the user from using cd. But then you have to copy the essential commands and programs that the user is supposed to be able to run into the user home directory. If you don't you'll have a useless user account.

Oh sorry. I read that as 'not being able to cd' is the problem. Use a chroot then. The user will still be able to read any files inside the chroot.

Last edited by i_joh; 07-21-2012 at 12:14 PM.
 
Old 09-14-2012, 07:25 AM   #8
suresh.k
Member
 
Registered: Aug 2011
Location: Hyderabad, AP, India
Distribution: centos, Ubuntu
Posts: 163
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Thanks for your suggestions
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create user without creating user home directory aksharb Linux - Software 1 05-12-2011 04:21 PM
create a directory at user home using shell script nagendrar Solaris / OpenSolaris 10 04-30-2010 05:30 AM
create a new user with a different home directory cccc Debian 6 08-06-2008 05:47 AM
Auto Create user home directory on Samba m2azer Linux - Networking 2 01-15-2007 11:56 AM
adding a new user doesn't create a home directory abrakadabra Linux - General 6 08-09-2002 08:11 PM


All times are GMT -5. The time now is 12:52 PM.

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