Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Revert ownership of files in a directory


    Hi Everyone,

    i had 1 query is there anyway to change the ownership of files in directory to prev owner and list of files that ownership had changed.

    lets say in a directory i had some files with test user and some with demo user. i had changed all the files to test user after changing some functionality is not working so i need to revert the files to demo user which is prev user and list of files that demo is the user.

    waiting for reply

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    4,031
    hi

    Old file and directory owners/groups are not saved.
    So you cannot revert with only the inode informations.

    If the files would have been installed via rpm/deb package, then a reinstall would help.
    But this doesnt seem to be your usecase.

    You need to decide on the user/group for your files/directories and then use
    Code:
    man chown
    You must always face the curtain with a bow.

  3. #3
    Linux User
    Join Date
    Jul 2016
    Posts
    443
    Quote Originally Posted by pratap9959 View Post
    Hi Everyone,
    i had 1 query is there anyway to change the ownership of files in directory to prev owner and list of files that ownership had changed.

    lets say in a directory i had some files with test user and some with demo user. i had changed all the files to test user after changing some functionality is not working so i need to revert the files to demo user which is prev user and list of files that demo is the user.

    waiting for reply
    keep waiting. we arent going to answer your homework questions for you. is this so you can 'get many certs"?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,847
    Quote Originally Posted by pratap9959 View Post
    lets say in a directory i had some files with test user and some with demo user. i had changed all the files to test user after changing some functionality is not working so i need to revert the files to demo user which is prev user and list of files that demo is the user.
    I suspect, by mistake you changed file permission and don't know which file owned by whom?

    Sadly, you can't fix this situation with a single command. You need to remember file and its owner & use chmod

    In future, you can backup file permission/owner bits with
    getfacl -R /path/to/dir >file_perms.acl
    and restore it via

    setfacl --restore=file_perms.acl
    HTH
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  6. #5
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,472
    -->
    Hi.

    Restore from system backup.

    If you have not had a backup plan up to this point, suppose you somehow lost, in some fashion, all of your files. How would you continue?

    A search for advice for backing up computer files linux or unix yields more than 1M hits.

    In my case, in addition to a usual backup with rsnapshot a few times daily, I also use a virtual machine for my main workstation. I take a snapshot of the VM just before serious changes, say from a system update. If the update fails, I can restore the entire system, in under 10 minutes. If it succeeds, then I run it for a week or so, and then merge the snapshot into the running system.

    If I needed to restore a single file, I can connect to the rsnapshot external machine, and retrieve a version of the file from any time period. That has been necessary perhaps 3 times in the recent past (say 5 years, or so).

    More details about this in http://www.linuxforums.org/forum/har...rkstation.html

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •