May 17, 2008

File specs

File specs

Let's give a quick look at the following listing

[root@server2 collections]#ls –l
total

-rw-r--r--

1 root

root

6 Aug 17

09:09 afile

-rw-r--r--

1 root

root

27 Aug 17

09:46 file2

-rw-r-- r--

1 root

root

14 Aug 17

09:46 myfile

drwxr-xr-x

2 root

root

4096 Aug 17

10:34 another/

-rw-r—r--

1 root

root

14 Aug 17

10:46 original.myfile

[root@server2 collections]#
As you can see on the ls output, it gives you details of who owns the file, types of file and so on.

On the first column –rw-r--r-- drwxr-xr-x these letters represent the rights on the files.

r read

w write

x execute

d means it is a directory

You can also see a column 1 root it means that belongs to root. The third column root means group root. On the very right column it shows the date and hour when it was created. Because of that fact, those files belong to root; only root can modify them. To prove this theory, exit the super user mode go into your user's home directory and subdirectory collections.

Try to backup a file, use the cp command

[user1@server2 collections]$cp file2 file3
cp: can not create regular file 'file3': Permission denied
[user1@server2 collections]$

Now you can see how neat this is, you cannot do anything to those files even though it is sitting in a regular user's home directory because root has ownership of those files.

Try to remove the file using the remove command: rm

[user1@server2 collections]$ rm afile
rm: remove write-protected regular file 'afile'? y
rm: can not remove 'afile': Permission denied

[user1@server2 collections]$

See you cannot even remove the file or work at all in the directory collections. When the directory collection was created by root, it inherited its permission to all files and subdirectories. Only root can change the permission to these files and probably grant some permission to other users.
Now if you go one step up in your home directory, there you can write, delete or remove.

No comments:

Post a Comment

Popular Posts