LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-24-2008, 12:36 PM   #1
marciobarbalho
Member
 
Registered: Dec 2007
Location: Brazil
Distribution: slackware 13
Posts: 151

Rep: Reputation: 30
file permissions


Please, dear friends...

How do I set permissions to a file that users are allowed to read but not delete, move or modify ?

Thank you very much
 
Old 07-24-2008, 12:41 PM   #2
wernerz
Member
 
Registered: Jun 2008
Location: Ottawa, Ontario, Canada
Distribution: debian, dsl-n
Posts: 55

Rep: Reputation: 15
chmod 444 "file"

Taken from man page:
Examples

chmod 400 file - Read by owner
chmod 040 file - Read by group
chmod 004 file - Read by world
chmod 200 file - Write by owner
chmod 020 file - Write by group
chmod 002 file - Write by world
chmod 100 file - execute by owner
chmod 010 file - execute by group
chmod 001 file - execute by world

To combine these just add the numbers together:
chmod 444 file - Allow read permission to owner and group and world
chmod 777 file - Allow everyone to read, write, and execute file
 
Old 07-24-2008, 01:27 PM   #3
marciobarbalho
Member
 
Registered: Dec 2007
Location: Brazil
Distribution: slackware 13
Posts: 151

Original Poster
Rep: Reputation: 30
then, whether I did this to a file, it works no matter what machine the file will be read on, right? I mean, I set this permissions on my machine and then send the file to a friend who will only read the file whether he is not logged as root, right?

Thanks
 
Old 07-24-2008, 01:48 PM   #4
wernerz
Member
 
Registered: Jun 2008
Location: Ottawa, Ontario, Canada
Distribution: debian, dsl-n
Posts: 55

Rep: Reputation: 15
No! File permissions are only good on your machine or on the same linux network. If you send a file to a Windows user he/she will be able to read it/change it/delete it because it is on their computer...assuming it is a text/html or other common file format.
 
Old 07-24-2008, 02:37 PM   #5
KasMage
LQ Newbie
 
Registered: Jul 2008
Location: Indiana
Distribution: Mandriva 2008.1
Posts: 21

Rep: Reputation: 15
Permissions are not too hard once you get them down.

4 = read
2 = write
1 = execute

Add them together for combined powers. In other words, 4 (read) + 2 (write) = 6, so 6 means you have the ability to read and write. 7 would be read, write, and execute, and 5 would be read and execute.

Each file will have three numbers for permissions (and an optional fourth, but that's slightly more complicated). The first number determines the permissions for the owner. The second number determines the permissions for the group owner. The third number determines permissions for everyone else.

So, if a file is set to 740, then the owner has full access, people in the group the file belongs to have read access, and others have no access. For your particular case, you're probably wanting something like 744. The owner would retain all control, and everyone else would have read access. The 444 recommendation would work as well, but then the owner has no execute or write permissions, which I would assume you'd want.

As for files retaining their permissions when transferred, you're almost always out of luck. If you e-mail him the file or something along those lines, he gets complete control of his copy of the file. If it's on a local network, then he won't be able to do anything to the file that he doesn't have permission to do, but once he copies the file to his computer, he gets control over that copy. You can't just retain control over a file on somebody else's computer just because they copied it from you.

Last edited by KasMage; 07-24-2008 at 02:39 PM.
 
Old 07-24-2008, 07:04 PM   #6
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
If you package the file in a tar archive you can retain permissions (use the -p switch), so when the recipient untars the file the permissions will be preserved. However, as the new owner (or at least as the root user), they can always chmod the file to give themselves write permissions.
 
Old 07-24-2008, 07:10 PM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Quote:
Originally Posted by marciobarbalho View Post
How do I set permissions to a file that users are allowed to read but not delete, move or modify ?
To prevent file deletion, it is necessary to remove write permission from the DIRECTORY where the file resides. When a file is deleted, it is the directory that is modified, not the file.

An alternative is to use chattr on the file (ACLs, but these are non-portable).
 
  


Reply



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
Windows file permissions with a Linux file server joseph_k Linux - Server 3 05-09-2008 12:54 PM
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM
file permissions and file owner won't change Nadim Slackware 5 11-29-2003 06:03 PM
Changing file permissions on a SAMBA file share apenney Linux - Software 0 02-11-2002 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:17 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
Open Source Consulting | Domain Registration