LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-22-2016, 03:17 PM   #1
borgward
Member
 
Registered: Apr 2005
Location: Austin, Texas
Distribution: Feather, Darn Small Linux
Posts: 243

Rep: Reputation: 17
Change Ownership


I have a .jpeg owned by root. How do I change the ownership to user (me)
 
Old 08-22-2016, 03:27 PM   #2
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,351
Blog Entries: 8

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
chown borgward:borgward pikachalupa.jpeg
 
Old 08-22-2016, 04:44 PM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
You have to be root to change the ownership, so use sudo (or your distribution's equivalent if applicable) for IsaacKuo's command.
 
Old 08-22-2016, 08:24 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
To clarify ...

Only "the present owner of a thing" ... uhh, "and root" ... is permitted to (irrevocably, except for root) "give the thing to anyone else."
 
Old 08-22-2016, 08:37 PM   #5
borgward
Member
 
Registered: Apr 2005
Location: Austin, Texas
Distribution: Feather, Darn Small Linux
Posts: 243

Original Poster
Rep: Reputation: 17
so the code would be $ sudo chown root:user name.jpeg ?
 
Old 08-22-2016, 09:17 PM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
Quote:
Originally Posted by borgward View Post
so the code would be $ sudo chown root:user name.jpeg ?
Nope. What is your username on the system?
 
Old 08-22-2016, 09:28 PM   #7
borgward
Member
 
Registered: Apr 2005
Location: Austin, Texas
Distribution: Feather, Darn Small Linux
Posts: 243

Original Poster
Rep: Reputation: 17
xyz
 
Old 08-22-2016, 09:50 PM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,645

Rep: Reputation: 278Reputation: 278Reputation: 278
check out this link: http://www.linfo.org/chown.html

running using root privileges try this:

chown xyz name.jpeg
 
Old 08-22-2016, 10:43 PM   #9
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,004
Blog Entries: 1

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
If you have read permissions you don't need to change owner. You can make a copy (cp) which gives the copy your ownership and group. But you lose some things like the original date and timestamp of the file.

$ sudo chown _owner_:_group_ _file_

is functionally the same as:

$ sudo chown _owner_ _file_
$ sudo chgrp _group_ _file_

You could also chmod the file so anybody could do anything to the file. But probably not the proper way to do things.
 
Old 08-23-2016, 03:50 AM   #10
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
sudo chown xyz:xyz name.jpeg
 
Old 08-24-2016, 05:19 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,710

Rep: Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520Reputation: 2520
Actually, only root or a user with root-type access eg through sudo can change ownership of a file.
Code:
 chown user1 t.t
chown: changing ownership of `t.t': Operation not permitted
Waaay back in the day, you could do that in Unix, but that was a long time a go, and its a good thing
 
Old 08-24-2016, 05:25 AM   #12
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,645

Rep: Reputation: 278Reputation: 278Reputation: 278
Lightbulb

Quote:
Originally Posted by Shadow_7 View Post
If you have read permissions you don't need to change owner. You can make a copy (cp) which gives the copy your ownership and group. But you lose some things like the original date and timestamp of the file.

$ sudo chown _owner_:_group_ _file_

is functionally the same as:

$ sudo chown _owner_ _file_
$ sudo chgrp _group_ _file_

You could also chmod the file so anybody could do anything to the file. But probably not the proper way to do things.
Good idea, just use cp if got read permissions. Then maybe just use touch to modify the timestamp.
 
Old 08-24-2016, 11:53 AM   #13
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,351
Blog Entries: 8

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
BTW, you can use
Code:
cp -va oldfile.jpeg newfile.jpeg
to copy over timestamp and file permissions. If you run this as a regular user, the owner of the new file will be the regular user you're running as (because regular users do not have chown ability).

So it's a way to basically recreate everything except for the ownership.
 
  


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
Cannot change ownership jamaso Slackware 11 11-08-2010 12:01 PM
change device ownership ? thllgo Linux - Server 1 10-22-2007 06:10 PM
Change ownership apffal SUSE / openSUSE 1 11-09-2005 03:08 AM
How to change ownership of a drive? raid517 Linux - Software 1 09-15-2005 09:15 AM
change ownership Johng Linux - General 4 04-06-2004 03:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:01 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