Files and File Permissions

Types of Files

In Linux there are three basic types of files

1.Ordinary files

These are the text files or contain some data and program instructions.

2.Directory files

These are just like folders in windows. Directory files having Ordinary and Special files also.

3.Special files

These special files provide access to hardware such as hard drives, CD-ROM drives, modems, and Ethernet adaptors. Other special files are similar shortcuts and enable you to access a single file using different names.



Regular file ( text file, binary executable, or hard link)


Block special file. Block input/output device file such as a physical hard drive.


Character special file. Raw input/output device file such as a physical hard drive


Directory file that contains a listing of other files and directories.


Symbolic link file. Links on any regular file.


Named pipe. A mechanism for inter-process communications


Socket used for inter process communication.

Hidden files :

A hidden folder (directory) or hidden file which file system utilities do not display by default when showing a directory listing. Hidden files are begins with “.” and are commonly used for storing user preferences or preserving the state of a utility, and are frequently created implicitly by using various utilities.

To display hidden files use ls -a command.

File Permissions

File system have methods to assign permissions to specific users and groups. File system use permissions to regulate the level of interaction that system processes can have with files and directories.

Permission Types

Each file or directory has three basic permission types:

  • read (r) – user able to read the contents of the file.

  • write (w) – user  able to write or modify a file or directory.

  • execute (x) – user  able to execute a file or view the contents of a directory.

Permission Groups

Each file and directory has three user based permission groups:

  • owner (u)- A single person who owns the file. But ownership may be granted to some one else by certain users

  • group (g) – The group that the file belongs to.

  • others (o) – The other users, i.e. everyone else.

Use the ls command’s -l option to view the permissions for the contents of a directory.

$ ls -l

Changing permissions

chmod is a command in Linux that allows to change the permissions of a file or directory.

Add single permission

$ chmod g+r systemDataFile.txt

Add multiple permissions

$ chmod g+x,o+r User.txt

$ chmod g+wx,o+rw Note.txt

Remove permission

$ chmod o-wx systemDataFile.txt

Clone permission from one file to other by reference.

$ chmod --reference=User.txt Note.txt

Numeric method

chmod can also set permissions using numbers.

Using numbers, allows you to edit the permissions for all three owner, group, and others at the same time.

  • r = 4

  • w = 2

  • x = 1

When you want to set permissions, we just add up the number. For example, to set the permissions to read and write, we will use ‘6’ (4 + 2) for the permission. For read, write and execute, we will use ‘7’ (4 + 2 + 1) for the permission.

Here’s the different permutation.


no permission






write and execute




read and execute


read and write


read , write and execute

Depending on the permissions you want to grant to the file, you just set the number accordingly.

$ chmod 764 systemDataFile.txt

$ chmod 744 User.txt

$ chmod 700 Note.txt