Sharing data on our servers

If you are part of the lab, you should be part of the /lmcb/ group. To check, simply type
$ groups
$ # or to check someone else's groups
$ groups username

Changing ownership of the folder

Changing the group ownership can be done using the /chgrp/ command:

$ mkdir testDir
$ ls -lh 
drwxrwxr-x 2 pimentel pimentel 4.0K Sep 17 14:28 testDir
$ chgrp lmcb testDir/
$ ls -lh
drwxrwxr-x 2 pimentel lmcb     4.0K Sep 17 14:28 testDir

Changing file and folder permissions

To view file permissions, you can type an /ls/ command. Here is an example:

$ ls -lh
-rwxr-xr-x 1 pimentel pimentel 60 Sep 16 14:08

From left to right the fields are:
  1. /-/ denotes it is a file, not a directory (would have a /d/ for directory)
  2. the three sets of three digits denote access for owner, group, and everyone else
    1. the 'bits' are ordered read, write, and execute
  3. the number of hard links
  4. the owner (user)
  5. the group owner
  6. the byte size (-H will report in K, M, or G depending on file size)
  7. when it was last modified
  8. the file name

Going back to your first computer science course, recall that with three digits you can represent the base-10 numbers 0-7. To me, the easiest way to change permissions is to use the following method with /chmod/:

  • Owner, group, and everyone else are denoted by one base-10 number (0-7)
  • If you write that number in binary, the relevant flags will be set (i.e. 5 represents 101, meaning read and execute access, no write access)

So, with that knowledge, you can now change the file permissions:

$ chmod 640
$ ls -lh
-rw-r----- 1 pimentel pimentel 60 Sep 16 14:08

Way easier than +r-w, yadda yadda, right?

NB: If you already have an existing folder, you will likely want to use the /-R/ flag, which means recursive so it will apply it to the files inside the folder

Bringing it all together

  1. Make a directory
  2. Change the owner to something everyone that will be using it is in (i.e. /lmcb/)
  3. Change the permissions so that the group can do what you want to allow it to do
  4. Make sure everything works :)