LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   Newbie needs help to change folder/file permissions (https://www.linuxquestions.org/questions/suse-opensuse-60/newbie-needs-help-to-change-folder-file-permissions-894460/)

theblackpig 07-29-2011 06:15 AM

Newbie needs help to change folder/file permissions
 
I've previously run Mandriva OS but have now changed to Suse Enterprise Desktop.I imported files and folders from My backup hard disc but they are all "locked" I tried going into properties but I'm told as I'm not the owner I can't change anything.
How do I change the permissions?
IN SIMPLE STEP BY STEP INSTRUCTIONS PLEASE as I'm a bit of an ignoramus

tronayne 07-29-2011 07:13 AM

You'll have to do that as root (either logged in as root, use su - or using sudo) in a "terminal" window.

You'll need to be careful depending upon where the directories and files were "imported" to; i.e., just exactly what did you import? Your own directories and files? System directories and files? Your own stuff you can do as below but, if you somehow imported system directories and files, you don't want to fiddle with them (system directories would be such as /etc, /usr/bin, /lib and the like).

So, let's assume that what you imported was your /home/username directory from the Mandriva system? Maybe some data directories and files? Stuff that's not system stuff?

Change directory to wherever your directories/files were put and execute
Code:

ls -al
to show you the names and permission masks; directories should look like
Code:

drwxr-xr-x  2 owner group      4096 Jan 13  2010 test/
and files should look like
Code:

-rw-r--r--  1 owner group      1484 Oct 26  2009 testing.doc
where "owner" is the name (or, possibly, a number, see below) of "who" owns the file or directory and "group" is the name (or number) of the group. Note that the number immediately to the left of the date is the size of the directory or file; ignore it.

If either the owner or group is numeric that would be because on your new system there is no owner or group with those identification numbers -- not to worry.

So, let's say that these recovered files don't have the default mask values (drwxr-xr-x for directories and rw-r--r-- for files) and you'd like to correct them to a reasonable default.

If they do have the default mask values, don't do this.

Still logged in as root (or using sudo)
Code:

cd to the directory where all the files and directories are -- do not do this in the root directory!
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

That will fix the masks (note: that will set all files to read-write, read, read -- if you have any files that you want executable, you'll need to manually change them with
Code:

chmod 755 filename
but don't do that now.

Now, let's assume that you want the directories and files to be owned by you; i.e., your login, and your default group (most likely "users"):
Code:

chown -R your_login:users *
That should do it.

Before you start, you might want to glance at the manual pages for find, chmod and chown to get a feel for what they do. Also, before you start, logged in as "you," and enter
Code:

groups
You ought to see something similar to
Code:

users lp floppy dialout audio video cdrom plugdev power usbfs netdev scanner vboxusers cvs
(Yours will probably vary).

Your default group is the first one on the left, in this case users. That's the one you use above.

Hope this helps some.

theblackpig 07-29-2011 01:57 PM

Hi tronayne, didn't understand a lot of what you posted BUT I tried this "chown -R your_login:users * "
and it worked a treat, many thanks.


All times are GMT -5. The time now is 11:10 PM.