0% found this document useful (0 votes)
2 views

16. File Permission

The document provides a guide on file permissions and commands in a Linux environment, detailing how to list files and directories, create new directories, and manage user permissions. It explains the different file types and their associated permissions, as well as the implications of user ownership and group ownership on access rights. Additionally, it illustrates practical examples of using commands to manipulate files and directories while highlighting permission-related errors encountered by users.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

16. File Permission

The document provides a guide on file permissions and commands in a Linux environment, detailing how to list files and directories, create new directories, and manage user permissions. It explains the different file types and their associated permissions, as well as the implications of user ownership and group ownership on access rights. Additionally, it illustrates practical examples of using commands to manipulate files and directories while highlighting permission-related errors encountered by users.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

File Permission

# ls  listing for current location

# ls -l  long listing of current location

# ls -l <filename/path>  long listing of specified file

# ls -ld <directory name>  long listing of specified directory

# stat <file/directory>  status

[root@localhost ~]# mkdir /data

[root@localhost ~]# ls -ld /data/

d rwx r-x r-x . 2 root root 6 Feb 16 20:15 /data/


1 2 3 4 5 6 7 8 9 10 11

[root@localhost ~]# touch /test

[root@localhost ~]# ls -l /test

-rw-r--r--. 1 root root 0 Feb 16 20:15 /test


1. File type

1. -  normal file

2. d  directory

3. c  character device file (console file)

4. p  pipe file (to merge file)

5. l  link file

6. s  socket file

7. b  block device file

2. (rwx) user owner permission

3. (r-x) group owner permission


4. (r-x) other's permission

5. acl (. --> acl not set, + --> acl set)

6. link count

7. (root) --> user owner

8. (root) --> group owner

9. (6) --> file size

10. date and time (time stamp)

11. (/linux) --> file name

file

r (read)  read data of file. ex: cat <filename>

w (write)  create, modify,delete file and data

x (execute)  not applicable on normal file. (only apply on script file)

directory

r (read)  display the content of directory, Ex: ls <dirname>

w (write)  create file and delete

x (execute)  switch to directory. ex: cd <dir name>

[root@localhost ~]# mkdir /data/red

[root@localhost ~]# ls /data/

red

[root@localhost ~]# useradd peppa  user peppa has others permission on directory

[root@localhost ~]# su - peppa


[peppa@localhost ~]$ pwd

/home/peppa

[peppa@localhost ~]$ touch abc

[peppa@localhost ~]$ ll

total 0

-rw-rw-r--. 1 peppa peppa 0 Feb 16 20:59 abc

[peppa@localhost ~]$ ls -ld .

drwx------. 4 peppa peppa 103 Feb 16 20:59 .

[peppa@localhost ~]$ mkdir redhat

[peppa@localhost ~]$ ll

total 0

-rw-rw-r--. 1 peppa peppa 0 Feb 16 20:59 abc

drwxrwxr-x. 2 peppa peppa 6 Feb 16 21:00 redhat

[peppa@localhost ~]$ cd /data/

[peppa@localhost data]$ pwd

/data

[peppa@localhost data]$ touch apple  user does not have write permission on
directory /data

touch: cannot touch 'apple': Permission denied

[peppa@localhost data]$ ls  user can list the content, bcoz other user has read
permission on directory

red

[peppa@localhost data]$ touch abc

touch: cannot touch 'abc': Permission denied

[peppa@localhost data]$ exit


logout

[root@localhost ~]# su - peppa

[peppa@localhost ~]$ cd /data/

[peppa@localhost data]$ ls

red

[peppa@localhost data]$ rm red

rm: cannot remove 'red': Is a directory

[peppa@localhost data]$ rm -r red

rm: remove write-protected directory 'red'? y

rm: cannot remove 'red': Permission denied

[peppa@localhost data]$ exit

logout

[root@localhost ~]#

[root@localhost ~]#

You might also like