Hot to change ownership of one file?

chemistry_geek

Registered
I need to change ownership of one file from root to my user account. Yesterday the "prefs.js" preference file in Mozilla was corrupted, and I restored the file with a backup I had made the week before. The backup was made using the root user account to an external firewire HD. The only thing I need to do is change ownership of that one file, nothing else needs to be changed (read/write priviledges). I can't make changes to Mozilla's preferences without changing file ownership.

I'm asking for advice because I've heard of so many horror stories of people going into the command line and changing ownership of too many files that subsequently requires reinstalling OS X.

I've searched for this through the forums and couldn't find a good enough example that shows what I need to do.

The path of the file is:

/Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/pref.js

The current owner of the file is system buts needs to be changed to alchemist.
 
You don't need any special utilities just su to root and chown it to your user and chmod it to what ever you need it to be.
 
This is what I typed in the command line (apparently it worked):

1. su

2. cd /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/

3. chown alchemist prefs.js

4. exit

I found some examples on the web. I just didn't want to really mess up other file attributes with prefs.js and make the matter more complicated.

This is the problem before chown:
Code:
[localhost:Profiles/default/xpfzghitk.slt] root# ls -l
total 6040
-rw-rw-rw-    1 root       staff     8196 Aug 15 22:38 .DS_Store
-rw-r--r--    1 alchemist  staff      802 Aug 14 11:03 23333318.s
-rw-r--r--    1 alchemist  staff        0 Jun 27 20:15 23333318.w
drwxr-xr-x  260 alchemist  staff     8796 Aug 17 11:33 Cache
drwxr-xr-x    6 alchemist  staff      264 Jun  6 12:40 Mail
drwxr-xr-x    5 alchemist  staff      264 Jun  6 03:38 Security
drwxr-xr-x    8 alchemist  staff      264 Jun  6 03:09 US
-rw-r--r--    1 alchemist  staff  2037600 Aug 15 22:22 XUL FastLoad File
-rwxr-xr-x    1 alchemist  staff    24769 Jun 10 13:02 abook.mab
-rw-r--r--    1 alchemist  staff    45215 Aug 17 11:13 bookmarks.html
drwxr-xr-x    3 alchemist  staff      264 Jun  6 03:09 chrome
-rw-r--r--    1 alchemist  staff     6570 Aug 17 11:33 cookies.txt
-rw-r--r--    1 alchemist  staff     9255 Aug 17 01:14 cookperm.txt
-rw-r--r--    1 alchemist  staff   621750 Aug 16 23:39 downloads.rdf
-rw-r--r--    1 alchemist  staff     8741 Aug 17 11:13 history.dat
-rw-r--r--    1 alchemist  staff    48023 Aug 17 10:18 history.mab
-rw-r--r--    1 alchemist  staff    31761 Aug 17 10:37 localstore.rdf
-rw-r--r--    1 alchemist  staff      287 Jun  6 02:44 mimeTypes.rdf
-rw-r--r--    1 alchemist  staff   152321 Aug 17 10:18 panacea.dat
-rw-r--r--    1 alchemist  staff     1607 Jun  6 02:44 panels.rdf
-rw-r--r--    1 alchemist  staff       12 Aug 17 11:25 parent.lock
-rw-r--r--    1 [B]root[/B]       staff    24598 Aug 17 11:13 prefs.js
-rw-r--r--    1 alchemist  staff     2335 Jun  6 02:44 search.rdf
[localhost:Profiles/default/xpfzghitk.slt] root#

After chown:
Code:
[localhost:Profiles/default/xpfzghitk.slt] root# ls -l
total 6040
-rw-rw-rw-    1 root       staff     8196 Aug 15 22:38 .DS_Store
-rw-r--r--    1 alchemist  staff      802 Aug 14 11:03 23333318.s
-rw-r--r--    1 alchemist  staff        0 Jun 27 20:15 23333318.w
drwxr-xr-x  260 alchemist  staff     8796 Aug 17 11:33 Cache
drwxr-xr-x    6 alchemist  staff      264 Jun  6 12:40 Mail
drwxr-xr-x    5 alchemist  staff      264 Jun  6 03:38 Security
drwxr-xr-x    8 alchemist  staff      264 Jun  6 03:09 US
-rw-r--r--    1 alchemist  staff  2037600 Aug 15 22:22 XUL FastLoad File
-rwxr-xr-x    1 alchemist  staff    24769 Jun 10 13:02 abook.mab
-rw-r--r--    1 alchemist  staff    45215 Aug 17 11:13 bookmarks.html
drwxr-xr-x    3 alchemist  staff      264 Jun  6 03:09 chrome
-rw-r--r--    1 alchemist  staff     6570 Aug 17 11:33 cookies.txt
-rw-r--r--    1 alchemist  staff     9255 Aug 17 01:14 cookperm.txt
-rw-r--r--    1 alchemist  staff   621750 Aug 16 23:39 downloads.rdf
-rw-r--r--    1 alchemist  staff     8741 Aug 17 11:13 history.dat
-rw-r--r--    1 alchemist  staff    48023 Aug 17 10:18 history.mab
-rw-r--r--    1 alchemist  staff    31761 Aug 17 10:37 localstore.rdf
-rw-r--r--    1 alchemist  staff      287 Jun  6 02:44 mimeTypes.rdf
-rw-r--r--    1 alchemist  staff   152321 Aug 17 10:18 panacea.dat
-rw-r--r--    1 alchemist  staff     1607 Jun  6 02:44 panels.rdf
-rw-r--r--    1 alchemist  staff       12 Aug 17 11:25 parent.lock
-rw-r--r--    1 [B]alchemist[/B]  staff    24598 Aug 17 11:13 prefs.js
-rw-r--r--    1 alchemist  staff     2335 Jun  6 02:44 search.rdf
[localhost:Profiles/default/xpfzghitk.slt] root#
 
See the command line is fun, if you want learn and mess around just create another non admin user and enjoy cause you can't really hurt anything important.:)
 
I've been using the command line in MAC OS X since Public Beta, and a little in a UNIX account when I was an undergrad, but there are some commands that I'm a leery of using when I can't find any good examples of their syntax.
 
Mac OS X 10.2 makes this task MUCH easier.

Jag-Finder-info-owner.jpg
 
Originally posted by chemistry_geek
This is what I typed in the command line (apparently it worked):

1. su

2. cd /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/

3. chown alchemist prefs.js

4. exit


You could have done that in less steps than that. :)

1. su
2. chown alchemist /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/prefs.js

or

1. sudo chown alchemist /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/prefs.js
 
Originally posted by hazmat


You could have done that in less steps than that. :)

1. su
2. chown alchemist /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/prefs.js

or

1. sudo /Users/alchemist/Library/Mozilla/Profiles/default/xpfzghitk.slt/prefs.js

PERFECT EXAMPLE of not knowing that this could have been done. Unless I'm very familiar with these commands, I prefer to go in small steps. I'd rather be safe than sorry, and I *NEED* my computer.

Thank you all very much for helping me with this matter.
 
No problem. Actually, see my edit of my message above. I forgot to incluse the chown command in the sudo example. And just in case you don't know, su requires the root password, sudo your own.
 
Back
Top