Saturday, September 27, 2008

File Management in UNIX

Finding Large Files in the server

# find . -size +10000 -print
The above command prints all the files whose size is greater than 10,000 bytes. This command is very useful when the disk space is nearing 100%.

Changing File Permissions
Unix Permission Values
4-Read Permission
2-Write Permission
1-Execute Permission
Thus, if a file permission is 751, it means read+write+execute permission to owner. 

# ls -l temp
-rw-rw-rw- 1 root dba 0 Apr 21 11:55 temp

Let me explain what "-rw-rw-rw-" means. 
  1. The first '-' indicates that it is a plain file. If it is a directory, then it would start with 'd'. 
  2. rw means read+write permission. The corresponding numeric values are 4 & 2 respectively. When you add it, you get 6. so the permission of the file is 666.
How to change File Ownership?
To change the current ownership of a file, use 'chown' (change owner) command.
To find the current owners of the files under a directory, just issue the command,

# ls -al
The third column lists out the owners of each file & directory.

Now issue the command,

# chown oracle:ocsinfra *

How to change File Permissions?

# chmod 774 *

By using the above command, you can make the files & directory under the current directory r+w+e for the owner and its group and read permission to the rest.

No comments:

Post a Comment