LinuxQuestions.org
Review your favorite Linux distribution.
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 11-27-2012, 12:49 AM   #1
slowerogue
Member
 
Registered: Oct 2012
Posts: 93

Rep: Reputation: Disabled
changing entire directory permission


hi gais,
i have user1,2,3,4
i want to make sure that user1 can only access /home/user1, and nowhere else
same goes to user2,3,4

how do i change the permission to all other directory
do i need to setfacl to directory one by one
is there a way to do this simpler?
 
Old 11-27-2012, 04:20 AM   #2
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,452

Rep: Reputation: 85
Code:
sudo chmod -R g-wrx,o-rwx /home/*
Then in each user's .bashrc file, append on a new line at the bottom:

Code:
umask 077
So the default newly created files will have permissions denying other users to read write or execute.

Also, edit:

/etc/skel/.bashrc

And append the

Code:
umask 077
to the end of it too.

This will cause any new users you create to automatically have the umask 077 in the .bashrc, so you do not have to manually edit each one after creating a new user.

After that, you can test it.

Code:
sudo su - user2
(Enter your users password)

cd /home/user1
ls /home/user1
su means switch user. Using sudo before it means you won't need to know user2's password to switch to that user. This only works if sudo is installed and configured and your user is a member of the wheel or sudo group. Ubuntu does this by default for the first user created during installation.

Last edited by fakie_flip; 11-27-2012 at 04:24 AM.
 
2 members found this post helpful.
Old 11-27-2012, 07:31 AM   #3
Thad E Ginataom
Member
 
Registered: Mar 2011
Distribution: Ubuntu 12.04 with KXStudio, MATE & Compiz
Posts: 46

Rep: Reputation: 7
Clever thinking! Not to look at user1, but to look at the other users.

Can I just add the significance of the - in your su command?

su means to assume the stated user's id; su - means to assume the stated user's id and the environment as if they had logged in. Makes a very important difference for testing.
 
Old 11-27-2012, 07:51 AM   #4
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,452

Rep: Reputation: 85
Quote:
Originally Posted by Thad E Ginataom View Post
Clever thinking! Not to look at user1, but to look at the other users.

Can I just add the significance of the - in your su command?

su means to assume the stated user's id; su - means to assume the stated user's id and the environment as if they had logged in. Makes a very important difference for testing.
Sure. I can add to that. A lot of users think su means Super User. It doesn't. It means Switch User. su - user2 doesn't enable you to become the Super User. Also - is short for -l which means login terminal. When using a login terminal. /etc/profile and ~/.bash_profile are read. When you open an interactive terminal that is not a login terminal such as starting konsole, xterm, etc from a GUI, those files are not read. The /etc/bashrc and ~/.bashrc are read. On my system, the ~/.bash_profile will check if a ~/.bashrc exists, and if it does, reads and executes it to using source ~/.bashrc or . ~/.bashrc. The (.) dot means source.
 
1 members found this post helpful.
Old 11-27-2012, 09:15 PM   #5
slowerogue
Member
 
Registered: Oct 2012
Posts: 93

Original Poster
Rep: Reputation: Disabled
hi thx for ur help
i wanted to make all the user unable to access /etc, /mnt, /tmp and so on
what i want to do is the user cant go anywhere else on the system, only their own home/userX
 
Old 11-28-2012, 12:44 AM   #6
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,452

Rep: Reputation: 85
https://www.google.com/search?q=jail...irectory+linux
 
  


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
[SOLVED] changing the permission of directory. Nitin Chaudhary Linux - Newbie 9 06-13-2012 03:00 AM
Changing Directory Permission tendonut Linux - Software 1 08-19-2007 08:57 PM
Changing File Permission in a FTP directory to prevent deleting of files shawnbishop Linux - Software 3 01-10-2006 06:41 AM
changing permissions for entire directory jmarsh Linux - Networking 2 05-13-2003 09:12 AM
mount -- changing directory permission newbie_jubie Linux - Software 5 02-15-2002 02:06 AM


All times are GMT -5. The time now is 02:32 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration