File Permissions

Listing Permissions

ls -al will display all files in a list with their owners and permissions

-rw-r–r– 1 irq13 irq13 1006 Jan 24 10:16 .bashrc

Now to break down the above example…

-rw-r–r– is the permissions area.

The first – would be d if the item is directory, otherwise it will be -.

The second 3 dashes indicate read/write/execute for the owner,
the second is r/w/x for the group and third is r/w/x for everyone else.

The next number is the inodes associated with the file. This isn’t important for you to know the basics

Next when it says irq13 irq13 that indicates the owner of the files name group
Changing ownership of a file

chown username:groupname file
Changing permissions of a file

chmod XXX filename

chmod uses a numeric system for assigning ownership.
XXX represents 3 numbers.
The first is the permissions applied to the owning user, 2nd is group, 3rd is everyone else.

1: execute 2: write 3: write & execute 4: read 5: read & execute 6: read & write 7: read, write & execute

Remember that 777 is only to be used as a trouble shooting step to rule fs permissions out.

NEVER leave a dir as 777. Its useful to do ‘ls -alh * > perm_capture.txt’ before messing with a file.

That way you can restore its original permissions.
Attributes

Files also have attributes, similar to the ones found in the windows world.

lsattr filename : Lists the attributes of a file or directory

chattr +-=[ASacDdIijsTtu] filename

to add an attribute use + to remove use –

File Attributes

append only (a)
compressed (c)
no dump (d)
immutable (i)
data journaling (j)
secure deletion (s)
no tail-merging (t)
undeletable (u)
no atime updates (A)
synchronous directory updates (D)
syn-chronous updates (S)
top of directory hierarchy (T)

Use man chattr for an explanation of each attribute
launching scripts and bins

* If an executable file is in your path you may simply type its name from anywhere on the system and it will execute.
* To see what your path is type ‘path’
* To execute a file in the current directory type “./filename
* To execute a file it must have execute permissions for either your username or a group you belong to.

Leave a Reply

Your email address will not be published. Required fields are marked *