Tuesday, February 16, 2016

Linux vs Windows File Permission Settings


Linux and Windows have very different ways of setting file permissions.  I personally prefer the Linux method.  I find that it is easier and more efficient once you know how to do it.

In Linux the command ls will show you all the directories and files inside of the directory/folder you are currently in.  In this folder there are 3 items: file1, test.conf and the directory called Directory.



However using the ls command with the -la argument will show all the files and associated permissions with that file.  So the command would look like this: ls -la





As you can see in this directory there 3 files mentioned above with all the associated permissions with them.  There is also 2 other files . and ..these files are hidden files and should not be deleted.  These files are necessary for the Linux file system to work.  The file permissions are located at the beginning of each line.




These file permissions can be very confusing at first.  There are 4 sections of the file permission or 10 dashes ---------- The first dash signifies the file type.  A dash signifies that it is a normal file a d signifies a directory.  The next 3 dashes signify read write and execute permissions for the owner of the file then the next 3 dashes signify the read write and execute permissions for the group and the last 3 dashes signify read write and execute permissions for all users.  In the picture above file1 has the following permissions. -rw-r--r-- In English this means that the owner has read & write permissions the group has read only permissions and all other users have read permissions.

These file permissions can also be expressed in a numeric value.  If we were to look at the same 
file1 again which has -rw-r--r-- for permissions the numeric representation would be 644.  As you can see the picture on the right 6 stands for read & write and 4 stands for read only.  Common file permissions are 777, 755, 700, 666, 644 and 600.  Now that you know all about how file permissions work here is how you change file permissions.  Changing file permissions is fairly easy.  File permissions can only be changed by the owner of the file or a root user.  The command used is chmod  this allows files to be changed.  So if we wanted to change file1 permissions to read,write & execute for all users you would put chmod 777 file1 This would successfully change the file permissions.



File owners and groups are to right of the file permissions.  As you can see in the picture below box 1 is where owner of the file is specified and box 2 is where the group is specified.  As you can see file1 is owned by root and is also in the root group.


To change the file ownership and group owner ship there is an easy and simple command called chown.  If we wanted to change the ownership of file1 we type chown tyler file1 into the command line.  You can also use the chown command to change the group that a file belongs to.  For example chown tyler:test file1 If you wanted to just change the group you would use the chgrp command for example chgrp test file1

Linux color coordinates their file types and directories that way they are easy to find and sort through.  Blue means that it is a directory, Green means that it is an executable or a file that can be ran, Sky Blue is a linked file, Yellow with a black background is a device, Pink is an image file and Red is an archive file.  The 2 files shown below are both an executable file, you can tell because they are green and if you look at the file permissions they have the ability to be executed. 

Windows File permissions

Windows file permissions are a little more complicated than Linux file permissions.  Below is an example of some files and folders.


If we wanted to change the file permissions of file1 we would start by right clicking on the file and choosing the Properties tab.



Once in the Properties tab click on the Security tab which will bring you to the security and file settings.





For file1 there are 3 groups that have one level or another of access to it.  There is SYSTEM, Tyler and Administrator which is like root.  If you wanted another user or group to have access to this file you would simply click Edit... where you will be able to change each user/group permissions along with the ability to add and remove groups and users to the selected file.






No comments:

Post a Comment