Each and every content in Unix/Linux is a file and it supports a several different types of files. To determine the file type, specify the -/ optional to the /s command. The first character of the /s -/ output determines the type of the file. For example the command
$ ls -l /home/user1/file
-rw-r–r– 1 user1 users 10 Jun 22 19:43 /home/user1/file
Here, we can see that the very first character is a hyphen (-). This indicates that the file is a regular file. For special files, the first character will be one of the letters given below.
Character Description
– Regular File
l Symbolic Link
c Character Special
b Block Special
p Named Pipe
s Socket File
d Directory File
File permission provides a secure method for storing files. Every file in UNIX has the following attributes.
- Owner Permissions.- Determines actions owner can perform on the file.
- Group Permissions.- Determines action that owner group can perform on the file.
- Others Permissions.- Determines action that global user can perform on the file.
The following are the actions that can be performed on any of the file.
- Read
- Write
- Execute
- If a user has read permissions, that person can view the contents of a file. A user with write permissions can change the contents of a file, whereas a user with execute can run a file as a program.
We can check the permissions of a file using the /s -/ command. For example.
$ ls -l /home/user1/file
-rw-r–r– 1 user1 users 0 Jun 22 19:43 /home/user1/file
To change the ownership permissions of file using chown command and this command can only be executed by root user.
To change the file actions permissions of a file using chmod command and this can be given by the owner of the file.