Showing posts with label Files & Permissions. Show all posts
Showing posts with label Files & Permissions. Show all posts

File Types in Linux






In Linux everything is a file but not all the files are of the same type. There are seven basic types of file types in Linux.

Regular file (-)  
Directory (d) 
Symbolic Link (l)
Character Device (c)
Block Device (b)
Socket files (s)
Named Pipe (p)

You can use the “ls -l” command to see the various types of files. The first character shows the file type.


Special Permissions suid sgid sticky bit in Linux



Special permission (suid, sgid and sticky bit)


Sometimes when you execute a command you need special privileges or permissions in order to accomplish its task. 

Three special types of permissions (suid, sgid, sticky bit) are available for executable files and directories.

For example, when you change your password with the passwd command, your new password is stored in the file /etc/shadow.

As a regular user, you do not have read or write access to this file for security reasons, but when you change your password, you need to have write permission to this file. For this the passwd program has to give you additional permissions so that you can write to the file /etc/shadow. This is done by special permissions.

File Permissions in Linux



Linux File Permissions



If you run the command

$ ls -l

you will get a list of files like below

-rw-r--r--  1  dev                 dev  1892  Jul 10  18:30 linux.txt

Here first part is the file permission symbol, 1 is the no of links of the file or in simple words showing there is one file linking to linux.txt. The file belongs to user dev and group dev or in simple word dev user and dev group owns the file. 1982 is the file size, after that the date and time the file has created. Last one is the file name.


Each file and directory has three user based permission groups:

Owner – It apply only the owner of the file or directory.
Group - The Group permissions apply only to the group that has been assigned to the file or directory.
All other users - The All other Users permissions apply to all other users on the system, this is the permission group that you want to watch the most.