Changing permissions on a file in Linux


To change the attributes (permissions) of a file or folder, use the chmod command:

chmod new_permission filename

Example (see how the attributes of the ubuntu.jpg file changed from 640 to 777):

chmod 777 ubuntu.jpg

ls -l

-rwxrwxrwx 1 mvps mvps 37126 Jun 25 03:15 ubuntu.jpg

Protecting files with chmod


Changing the owner of a file

This can be very simple to do from the terminal using the chown command:

chown new_username:default_group_new_username filename

or (to keep in mind that the dot character ‘.’ after the new user name, automatically adds that user’s default group)

chown new_username. filename

Recent Posts