How to give root ownership to directory or files in directory?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shwet Srivastava
    New Member
    • Sep 2010
    • 7

    How to give root ownership to directory or files in directory?

    I am log in as user student and i want that if i make any file in a particular directory is owned by root at the time of creation of file or sub-directory.
    I used chown root /root/linux as a root user but it didn't work.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Did you receive an error when you ran the command?

    What does an ls -alh /root/linux show? If you ran that command as root, and it didn't give an error, it should have updated the folder with the desired permissions.

    You can always try running it under sudo as well.

    Comment

    • Shwet Srivastava
      New Member
      • Sep 2010
      • 7

      #3
      No i didn't receive any error message b'coz i am running chown root /root/linux command as a root and root is already owner of that directory. I just want to do -
      # useradd jk ; passwd -d jk
      # useradd kk; passwd -d kk
      # mkdir /data
      # groupadd redhat
      # usermod -G redhat jk ; usermod -G redhat kk
      # chmod g+ws /data
      # su - jk
      $ cd /data
      $ touch a b
      Now as a user jk as a group member of redhat when I make a file in /data directory,it take root ownership not jk.

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        And after you run it, what does the ls show?

        Comment

        • Shwet Srivastava
          New Member
          • Sep 2010
          • 7

          #5
          # chgrp redhat /linux
          I forget to write above line. After that
          su - jk
          $ cd /data
          $ touch a b
          $ ls -l
          -rw-rw-r-- 1 jk redhat 0 Dec 21 01:48 a
          -rw-rw-r-- 1 jk redhat 0 Dec 21 01:48 b
          I want that when i create files in /data directory as jk a group member of redhat, at the time of creating the file that file owned by root user.

          Comment

          • sicarie
            Recognized Expert Specialist
            • Nov 2006
            • 4677

            #6
            But you're not chowning the files.

            What does it show after you chown them to root?

            Comment

            • Shwet Srivastava
              New Member
              • Sep 2010
              • 7

              #7
              It change ownership jk to root. But I want to do this at the time of creating the file by jk.

              Comment

              • sicarie
                Recognized Expert Specialist
                • Nov 2006
                • 4677

                #8
                I don't understand - you create the file, and you can change the owner of that file.

                However, you want the user jk to create a file and have that file owned by root?

                If a user creates a file, it's going to be owned by that user until someone with greater privilege changes that. Security logging is built around that concept.

                Comment

                Working...