Avatar of Jack_son_
Jack_son_
Flag for Afghanistan asked on

Linux Script

I'm trying to add these requirements to my script below:
o    The file owner can read, modify and access the scenario company directories
o    The group members can read and access the scenario company directories
o    Everyone else has no access.
·         Create a file in each of the scenario company directories.
o    Set the file permissions for the files in the scenario company directories.
o    The owner can read and modify the file
o    The group members can only read the file
o    Everyone else has no permissions


10 #
      11 # This will create the home ARI directory
      12 #
      13 #
      14 test -d /ARI && echo ">ARI already exists" || mkdir -v /ARI
      15 #
      16 #
      17 # Create Next level of Directories
      18 test –d /ARI/SALES && echo “/ARI/SALES already exists” || mkdir –v /ARI/SALES
      19 test –d  /ARI/IT && echo “/ARI/IT already exists” || mkdir –v /ARI/IT
      20 test –d /ARI/MARKETING && echo “/ARI/SALES already exists” || mkdir –v /ARI/MARKETING
      21 test –d /ARI/FINANCE && echo “/ARI/SALES already exists” || mkdir –v /ARI/FINANCE
      22 #
      23 #
      24 # The next lines create the subfolders under the second level directories
      25 mkdir –v \ARI\SALES\REG_1
      26 mkdir –v \ARI\SALES\REG_2
      27 mkdir –v \ARI\SALES\REG_3
      28 mkdir –v \ARI\IT\OPS
      29 mkdir –v \ARI\IT\DEV
      30 mkdir –v \ARI\IT\RandD
      31 mkdir –v \ARI\MARKETING\FT
      32 mkdir –v \ARI\MARKETING\PT
      33 mkdir –v \ARI\MARKETING\CNT
      34 mkdir –v \ARI\FINANCE\AP
      35 mkdir –v \ARI\FINANCE\AR
      36 mkdir –v \ARI\FINANCE\ADT
      37 #
      38 #
      39 #Create symbolic links from OPS and PT subdirectories to their parent directory
      40 ln-s /ARI/IT /IT/OPS
      41 ln-s /ARI/MARKETING /MARKETING/PT
      42 done
      43 done
LinuxLinux NetworkingLinux OS Dev

Avatar of undefined
Last Comment
Jack_son_

8/22/2022 - Mon
Kerem ERSOY

Hi,

Your requirements require you to customise directory and file permissions before running the script. It is not a part of the script.

A directory should have this if you want the owner can read write and group can read write and others won't have any permission:

chmod 770 /Path/to/directoy

Open in new window


While if ypu want the group can only read but can't write the directory should have this:

chmod 750 /path/to/directory

Open in new window


Cheers,
K.
SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jack_son_

ASKER
Thanks what is the unmask command do?  How do I add to my script. For touch, i can use that and remove mkdir?
SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jack_son_

ASKER
I updated the script, let me know if this looks on track:

12 #
      13 umask 027
      14 test -d /ARI && echo ">ARI already exists" || mkdir -v /ARI
      15 #
      16 #
      17 # Create Next level of Directories
      18 test –d /ARI/SALES && echo “/ARI/SALES already exists” || mkdir –v /ARI/SALES
      19 test –d  /ARI/IT && echo “/ARI/IT already exists” || mkdir –v /ARI/IT
      20 test –d /ARI/MARKETING && echo “/ARI/SALES already exists” || mkdir –v /ARI/MARKETING
      21 test –d /ARI/FINANCE && echo “/ARI/SALES already exists” || mkdir –v /ARI/FINANCE
      22 #
      23 #
      24 # The next lines create the subfolders under the second level directories
      25 mkdir –v /ARI/SALES/REG_1
      26 mkdir –v /ARI/SALES/REG_2
      27 mkdir –v /ARI/SALES/REG_3
      28 mkdir –v /ARI/IT/OPS
      29 mkdir –v /ARI/IT/DEV
      30 mkdir –v /ARI/IT/RandD
      31 mkdir –v /ARI/MARKETING/FT
      32 mkdir –v /ARI/MARKETING/PT
      33 mkdir –v /ARI/MARKETING/CNT
      34 mkdir –v /ARI/FINANCE/AP
      35 mkdir –v /ARI/FINANCE/AR
      36 mkdir –v /ARI/FINANCE/ADT
      37 #
      38 #
      39 #Create symbolic links from OPS and PT subdirectories to their parent directory
      40 ln-s /ARI/IT /IT/OPS
      41 ln-s /ARI/MARKETING /MARKETING/PT
      42 umask 026
      43 #
      44 touch /ARI/SALES/REG_1/SALESFILE
      45 touch /ARI/SALES/REG_2/SALESFILE1
      46 touch /ARI/SALES/REG_3/SALESFILE2
      47 touch /ARI/IT/OPS/ITFILE1
      48 touch /ARI/IT/DEV/ITFILE2
      49 touch /ARI/IT/RandD/ITFILE3
      50 touch /ARI/MARKETING/FT/FILE1
      51 touch /ARI/MARKETING/PT/FILE2
      52 touch /ARI/MARKETING/CNT/FILE3
      53 touch /ARI/FINANCE/AP/FILE1
      54 touch /ARI/FINANCE/AR/FILE2
      55 touch /ARI/FINANCE/ADT/FILE3
      56 #
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jack_son_

ASKER
Great, thanks for the input!  

I'm doing a few more items with the script, but creating a new post. Any contribution is appreciated!