Fw: Changing file ownership

David Kramer david at thekramers.net
Tue Apr 10 09:40:01 EDT 2001


I'm forwarding this one on because this is a subject that frustrates new *NIX users, 
and it was well-written.  Alpha geeks can delete it.

---- Original Message ----
From:		Linux Tips at TechRepublic.com
Date:		Tue 4/10/01 7:47
Subject:	Changing file ownership

TechRepublic: www.techrepublic.com

Presents your
LINUX TECHMAIL

<-----------------Advertisement------------>

Need Development Help?

The Developer NetNote brings great news and information direct to your 
e-mail inbox. From the latest columns to the most useful downloads, 
we've got you covered. Don't be left behind. Click here to sign up for 
this great resource now.

http://click.techrepublic.com/Click?q=91-EZypQAzsXfOPSalPzKYpVdRR

<------------------------------------------->

LINUX TIPS FOR APRIL 10, 2001

LINUX SKILLS REVIEW: CHANGING FILE OWNERSHIP
In the Linux filesystem, every file has an owner. Normally, the owner 
of a file is the user who creates the file. By default, you are the 
owner of all the files you create in your home directory. But there are 
times when you'll need to change a file's ownership. Should you need to 
do so, you can use the chown command. To change a file's ownership, 
switch to superuser by typing su and pressing [Enter].

The chown command uses the following syntax:

chown [ file owner] [ file name ]

To change the ownership of the file named document1.doc to a user named 
ferret, type the following code and press [Enter]:

chown ferret document1.doc 

As with most file utilities, you can specify a list of files or use 
wildcards, as in these examples:

chown ferret document1.doc document2.doc document3.doc 
chown ferret document?.doc

To change file ownership recursively (throughout the current directory 
and within all associated subdirectories), use the recursive (-R) 
option:

chown -R ferret *

The above example changes the ownership of all the files in the working 
directory and all associated subdirectories to ferret.

LINUX SKILLS REVIEW: CHANGING FILE PERMISSIONS
To change the permissions assigned to a file, use the chmod command. If 
you're the owner of the file, you can change the permissions while 
logged in to your user account. If the file belongs to someone else, 
you'll need to switch to superuser by typing su and pressing [Enter] at 
the command prompt.

Permissions affect the ability of the following user classes to access 
or change the file:

* u: User (owner of the file)

* g: Group (group owner of the file)

* o: Other (all other users)

* a: All (includes user, group, and others)

You can change permissions by specifying relative changes from the 
current permissions or by specifying absolute permissions. To specify 
relative changes to the current permissions, use the chmod command's 
symbolic mode. Absolute permissions can be set with the symbolic mode 
or the numeric mode. (A subsequent tip will cover absolute 
permissions.)

In the chmod command's symbolic mode, you can specify a user class, an 
operation, and a permission type. Here is how the operations are 
indicated:

* +: Adds the specified permission to the current setting

* =: Specifies an absolute permission setting (overrides the current 
permissions)

* -: Removes the specified permission from the current setting

Permission types include the following:

* r: Read permission (the file is read-only)

* w: Write permission (the file can be altered or deleted)

* x: Execute permission (the script or program can be executed)

In the symbolic mode, you use the chmod command with the following 
syntax:

chmod [ user class ] [ operation ] [ permission ] [ file ]

Examples:

* chmod g-w autobiography.doc: (removes Write permissions from 
autobiography.doc for members of the file owner's group)

* chmod a+r README.TXT: (makes README.TXT readable for all users)

These examples show how you can combine user classes and permissions:

* chmod ug+rx myscript: For the file owner and group owners, add Read 
and Execute permissions to the existing permissions for the file named 
myscript.

* chmod go-wx myscript: For group owners and others, remove Write and 
Execute permissions from the file named myscript.

In place of a single filename, you can supply a file list or use 
wildcards:

chmod u+x script1 script2 script3

or

chmod u+x script?

To change permissions throughout a directory and all associated 
subdirectories, you can use the recursive option (indicated by typing -
R or --recursive before the user class):

* chmod -R u+w *: Adds Write permissions to the owner's files 
throughout the working directory and all associated subdirectories

------------------------------------------

Read more about IT at TechRepublic

WHEN LINUX PANICS: MANAGING AN OS EMERGENCY 
What would you do if your Linux OS crashed? Have you made any backups? 
Have you even considered the possibility? Jack Wallen, Jr. has. He 
discusses the value of boot floppies and fsck, and lists some important 
files and directories.
http://click.techrepublic.com/Click?q=b7-FOzPQ8JmgO4mlqzZN-N0BRRR

LINUX 101: BASIC NETWORK SECURITY 
New to Linux? Here are the basics you'll need to know in order to 
protect your Linux machine from unwanted visitors.
http://click.techrepublic.com/Click?q=d8-XWv3QWLUI7bOdzROkkMQfRRR

------------------------------------------

Today @ TechRepublic

DOWNLOAD OUR FILL-IN-THE-BLANK PRIVACY POLICY 
Every organization should have a privacy policy in place to protect the 
valuable personal data that customers entrust to your Web site. 
Download our fill-in-the-blank version to help you beef up your 
existing policy or use it to build one from scratch.
http://click.techrepublic.com/Click?q=fe-xkOgQwgVyCP5UukwEyRYO9RR

WHAT TO DO WHEN IMPOSSIBLE PROJECT DEADLINES ARE COMMON PROCEDURE 
It happens with almost every project--the business unit demands an 
impossible time frame to complete the work required. Columnist Tom 
Mochal offers advice to a TechRepublic member who's struggling to meet 
project deadlines.
http://click.techrepublic.com/Click?q=fa-Fm5NQhO3Y5MUBOulvGSamRRR

EVALUATING MICROSOFT'S ISA SERVER FIREWALL PRODUCT 
If your organization is looking for a firewall product to integrate 
with your Windows 2000 network, you should consider Microsoft's 
Internet Security and Acceleration Server, a full-featured upgrade to 
Proxy Server 2.0. Here's a look at what it offers.
http://click.techrepublic.com/Click?q=cc-h4WQQ0ObtVjQqqXjqlnkmsRR

------------------------------------------

ERP SUPERSITE NEWSLETTER
Each week, the ERP SuperSite NewsLetter keeps you up-to-date on the 
latest developments in enterprise resource planning technology. Who's 
saying what, who's buying whom, what stock is hot--sign up and you'll 
get the straight story. Get on the list now!
http://click.techrepublic.com/Click?q=74-VA08IZZvNaxiEiCQYD7bndRR

------------------------------------------

TechRepublic TechMails may contain links to sites on the Internet which 
are owned and operated by third parties. TechRepublic, Inc. is not 
responsible for the content of any such third-party site.

Questions or comments:
mailto:ecomments at techrepublic.com?subject=Linux

Copyright 1999-2001 TechRepublic, Inc. All rights reserved.

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list