How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask OSXpert Your Own Question

OSXpert
OSXpert, Mac Software Engineer
Category: Mac
Satisfied Customers: 226
Experience:  2 years as a geek squad computer technician, 5 years as a software engineer and unix systems admin
50723742
Type Your Mac Question Here...
OSXpert is online now
A new question is answered every 9 seconds

Unix Question has been asked before. You have been asked

Resolved Question:

<p>Unix Question has been asked before. Question is due 3/21 </p><p>You have been asked by your manager to develop a shell program to automate the security scheme you implemented in a prior project. This is a continuation of your earlier work. You must give the appropriate commands for the appropriate permissions and ownership for all of the files and directories in sales and shipping. You will create the necessary script(s) to implement the security scheme designed previously. You must test whether a file or directory exists before creating it. If a directory or file does exist, make the appropriate permission changes. You decide how to handle the situation where the file or directory does not exist. Then, discuss the various commands, techniques, and/or tools you would use to create the script(s). Note to students: You need access to the UNIX operating system. However, do NOT install UNIX on the PC you normally use. You can install UNIX on a second PC. If that is not possible, you can download a UNIX emulator, which runs under Microsoft Windows. The recommend emulator can be found at the website listed under Unit Resources for this course. You can do everything you need for this class using this emulator. You may have to install it twice; the second time you will need to choose the "vim" or "vi" editor.  </p><p>Details for this are:</p><p>You are to prepare a document regarding security of a proposed KTC system. Your manager wants you to discuss the necessary commands to assign the proper security permissions to the directories below. You are to assume the directory hierarchy currently exists. Note that each item in the graphic below is a directory. Shipping contains a directory name Out for outgoing shipments and a directory named In for incoming shipments. The sales directory has two regions in this scenario: Directory A for region A and directory B for region B.</p><p><img src="http://www.justanswer.com/courses/CS124/Assignment_Assets/2_p2ips.gif" alt="" width="28" height="30" /></p><p>There is a file in the Out directory named <strong>Out1.dat</strong>. There are two files in the In directory: One is named <strong>In1.dat</strong> and the other is named <strong>In2.dat</strong>. Directory A contains the files <strong>A1.dat</strong> and <strong>A2.dat</strong>. Directory B contains the files <strong>B1.dat</strong>, <strong>B2.dat</strong> and <strong>B3.dat</strong>.</p><p> </p><p>There are three groups of users: managers, shippers and sales representatives. Users Pat and Mary are members of the managers group, users Mike and Ving are members of the shipping group, and users Denise, Bob, and Sally are members of the sales group. Denise is a sales supervisor, and Bob and Sally are sales representatives. Bob and Sally must be able to open and modify all files in shipping. Bob is in charge of region A and Sally is in charge of region B. </p><p> </p><p>It has been determined that the current permissions of the files and directories for shipping must be as defined below:</p><p>The shipping directory must be owned by Pat. The group owner of shipping must be managers. The permissions of shipping must be read, write, and execute for Pat, and read and execute for all the others.</p><p>Mike must be the owner of the directory named Out. The group owner of Out must be shippers. The permissions of Out must be read, write, and execute for the owner, read and execute for members in shipping, and read for all the others. Mike must be the owner of all of the files in the Out directory. Users only need to open and modify the files in Out.</p><p>The In directory must be owned by Ving. The group owner of In must be a shipper. The permissions of In must be read, write, and execute for the owner, and read and execute for all others. Ving needs to open, modify, and run the files in the In directory. Shippers only need to open and modify the files in the In directory, and everyone else should only be able to open the files.</p><p>You are charged with the task of discussing the commands needed to create the appropriate permissions for the shipping directory and its subdirectories and files. Give the commands you would use to implement the security requirements for shipping. Additionally, you are to propose a possible security scheme similar in nature to the shipping requirements for the sales directory. Explain the reasons why you are assigning certain permissions and owners (user and group) to the files and directories in sales. Also, give the commands you used in support of your proposal. Prepare a document discussing your implementation of security for KTC.  This is the structure of directories</p><p><img src="http://s3.amazonaws.com/f01.justanswer.com/PLByjoule/2011-03-16_084822_2_p2ips.gif" alt="graphic" width="226" height="157" /></p>
Submitted: 3 years ago.
Category: Mac
Expert:  OSXpert replied 3 years ago.

OSXpert :

Hi, my name is Britton. Are you available?

OSXpert :

Let's tackle the first problem -- also, I have somewhat of a moral dilemma just giving you the answer to these. Work with me and we'll get you all set.

First, the 'stat' (/usr/bin/stat) command is going to be your friend for the first problem. Not only will it tell you if a file exists, it will also tell you what kind of file it is (e.g. regular file, directory file, named pipe, etc...), it will also tell you the owner, group and the current permissions.

Essentially, you want to run 'stat <filename>' on each file. If stat returns a non-zero number, the file doesn't exist or there was another problem with the file. If stat returns 0, the file. exists and you can read the permissions/owner.

I'll be available for most of today, let me know when you're logged in and I'll get you going in the right direction

OSXpert, Mac Software Engineer
Category: Mac
Satisfied Customers: 226
Experience: 2 years as a geek squad computer technician, 5 years as a software engineer and unix systems admin
OSXpert and 4 other Mac Specialists are ready to help you
Customer: replied 3 years ago.
Please email me so we can get together on this question.
Expert:  OSXpert replied 3 years ago.
What is the objective of the assignment? Are you supposed to write a script or are you just supposed to explain in writing how to accomplish the problem in your description?
Customer: replied 3 years ago.

A 1 to 3 page word document. The first part is the assignment and the second part that starts with Details for this are: from there including the picture is the preassignment I already finished. so the first part is what I'm looking for since I got an F on the preassignment and don't have a clue what I'm doing.

Expert:  OSXpert replied 3 years ago.
Please post the URL to the assignment. The description you put on Justanswer.com has a bunch of HTML elements and it's difficult to read. Second, It will be much easier for me if I can see the original questions.

Here are the commands needed for the preassignment:

chown Pat.managers shipping

chown stands for change owner. The "Pat.managers" part signifies you want the owner to be "Pat" and the group to be "managers". The "shipping" part is the name of the directory, "shipping"

chmod 755 shipping

chmod stands for change mode. Let's break down the 755 above. 7 indicates read, write and execute permission for the OWNER of the directory. We get the 7 from the binary addition of read, write, and execute. The value of read = 4, the value of write = 2 and the value of execute = 1. Add them together, 4+2+1=7, so, 7 denotes permissions of read, write and execute.

The 5 indicates the permissions for member of the GROUP of the directory. We get the 5 from binary addition of read and execute. Again, read = 4, execute = 1. Add them together 4+1=5, thus 5 denotes permissions of read and execute for members of the group.

The last 5 indicates the permissions for all OTHER members (non-owner and non-group). Just remember read=4, write=2 and execute=1. If you remember those, you can always figure out the permissions needed to be given to the chmod command.

chown Mike.shippers Out

This makes Mike the owner and shippers the group of the directory Out.

chmod 754 Out

7 = read, write, execute for the OWNER, Mike
5 = read, execute for the GROUP, shippers
4 = read permission for all OTHER users

chown Mike Out/*

This means change the owner of all (*) the files in the Out/ directory to "Mike"

chmod 666 Out/*

This means change the mode (permissions) of all (*) the files in the Out/ directory to read, write. Again:

read = 4
write = 2
4+2 = 6 for all users, thus 666 (6 for OWNER, 6 for GROUP and 6 for OTHER)

chown Ving.shippers In

Change the owner of the "In" directory to Ving and the group owner to "shippers"

chmod 755 In

Change the permissions for the "In" directory to read, write, execute for the owner. Read, execute for the group and read execute for all other users.

chmod 764 In/*

Change the permissions for all files (*) in the "In" directory to read, write, execute for the owner. Read, write for the group, and read for all other users.
Customer: replied 3 years ago.

It's too late for the preassignment I already got a grade on it. So here is the current one that I need help on.

You have been asked by your manager to develop a shell program to automate the security scheme you implemented in a prior project. This is a continuation of your earlier work. You must give the appropriate commands for the appropriate permissions and ownership for all of the files and directories in sales and shipping. You will create the necessary script(s) to implement the security scheme designed previously. You must test whether a file or directory exists before creating it. If a directory or file does exist, make the appropriate permission changes. You decide how to handle the situation where the file or directory does not exist. Then, discuss the various commands, techniques, and/or tools you would use to create the script(s). Note to students: You need access to the UNIX operating system. However, do NOT install UNIX on the PC you normally use. You can install UNIX on a second PC. If that is not possible, you can download a UNIX emulator, which runs under Microsoft Windows. The recommend emulator can be found at the website listed under Unit Resources for this course. You can do everything you need for this class using this emulator. You may have to install it twice; the second time you will need to choose the "vim" or "vi" editor.

Customer: replied 3 years ago.

Hello? Are you still helping me or no?

Expert:  OSXpert replied 3 years ago.
I'm still here -- but like I asked before, please send me the actual LINK to the assignment. When you paste in the description, it loses all formatting (paragraph breaks, spacing, etc...) making this increddibly hard to follow.
Customer: replied 3 years ago.
You would have to log into the link since I'm a member to it. Otherwise you can't see the question.
Customer: replied 3 years ago.

Here is the question I've acctually typed this in so that formating won't be a problem.

You have been asked by your manager to develop a shell program to automate the security scheme you implemented in a prior project. This is a continuation of your earlier work. You must give the appropriate commands for the appropriate permissions and ownership for all of the files and directories in sales and shipping. You will create the necessary script(s) to implement the security scheme designed previously. You must test whether a file or directory exists before creating it. If a directory or file does exist, make the appropriate permission changes. You decide how to handle the situation where the file or directory does not exist. Then, discuss the various commands, techniques, and/or tools you would use to create the script(s). Note to students: You need access to the UNIX operating system. However, do NOT install UNIX on the PC you normally use. You can install UNIX on a second PC. If that is not possible, you can download a UNIX emulator, which runs under Microsoft Windows. The recommend emulator can be found at the website listed under Unit Resources for this course. You can do everything you need for this class using this emulator. You may have to install it twice; the second time you will need to choose the "vim" or "vi" editor.

Expert:  OSXpert replied 3 years ago.
Great, thanks. But now I'm a little confused, I thought you needed to write a 1-3 page paper. Do you need to write a script (small software program) or an actual paper (e.g. typed in Microsoft Word)?
Customer: replied 3 years ago.
It says script and 1 to 3 page word document.
Customer: replied 3 years ago.

Ok, here is something I've been thinking.

if [ -f fileA.dat ]

then

echo "The file exists"

else

touch fileA.dat

echo "File created"

fi

Expert:  OSXpert replied 3 years ago.
You're off to a good start. A couple of things...first, run this command:

which bash

It will probably return with "/bin/bash" -- you need to put this at the top of your script in the following format:

#!/bin/bash

Extend your script a little bit to check for directories and traverse them like this:

#!/bin/bash

if [ ! -d Shipping ]
then
mkdir Shipping
fi

chown Pat:managers Shipping
chmod 755 Shipping
cd Shipping

if [ ! -d Out ]
then
mkdir Out
fi

chown Mike:shippers Out
chmod 754 Out

cd Out

if [ ! -f Out1.dat ]
then
touch Out1.dat
fi

chmod 666 Out1.dat

cd ..

if [ ! -d In ]
then
mkdir In
fi

chown Ving:shippers In

cd In

if [ ! -f In1.dat ]
then
touch In1.dat
fi

if [ ! -f In2.dat ]
then
touch In2.dat
fi

chmod 764 In1.dat In2.dat

cd ../../



This should create the entire Shipping/ directory tree including files. Run it on your system and ensure I didnt make any mistakes. I can only run it to som extent on my system because I don't have the users/groups for the assignment.

Also, please copy the entire assignment, paste it into a word document (or some format the RETAINS formatting) and upload it to:

www.wikisend.com

Check my script for errors by running it on your system. Also, you may want to add some echo statements that will say things like "directory exists / doesnt exist" etc...
OSXpert, Mac Software Engineer
Category: Mac
Satisfied Customers: 226
Experience: 2 years as a geek squad computer technician, 5 years as a software engineer and unix systems admin
OSXpert and 4 other Mac Specialists are ready to help you
Customer: replied 3 years ago.

Thanks, XXXXX XXXXX would just subsitute sales for shipping for the other side?

 

Customer: replied 3 years ago.
Uploaded as P4IP.docx
Expert:  OSXpert replied 3 years ago.
Pretty much. Take a shot at it and upload the script to wikisend.

Also, you need to post the link to the file you uploaded to wikisend. Post the entire link for the assignment and the updated script here and I'll take a look at it later today.
Expert:  OSXpert replied 3 years ago.
Status check -- as I recall, your assignment is due tomorrow. Just wanted to check and see how things are going.
Customer: replied 3 years ago.
I submitted the script with some modifications hope it turns out well.
Expert:  OSXpert replied 3 years ago.
Good deal, let me know how it goes. I enjoy working on Unix problems and would like to help you in the future if you're interested. You can send future questions to me directly here:

http://www.justanswer.com/profile.aspx?PF=50723742&FID=0

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Hi John, Thank you for your expertise and, more important, for your kindness because they make me, almost, look forward to my next computer problem. After the next problem comes, I'll be delighted to correspond again with you. I'm told that I excel at programing. But system administration has never been one of my talents. So it's great to have an expert to rely on when the computer decides to stump me. God bless, Bill Bill M. Schenectady, New York
< Last | Next >
  • Hi John, Thank you for your expertise and, more important, for your kindness because they make me, almost, look forward to my next computer problem. After the next problem comes, I'll be delighted to correspond again with you. I'm told that I excel at programing. But system administration has never been one of my talents. So it's great to have an expert to rely on when the computer decides to stump me. God bless, Bill Bill M. Schenectady, New York
  • The Expert answered my Mac question and was patient. He answered in a thorough and timely manner, keeping the response on a level that could understand. Thank you! Frank Canada
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
 
 
 

Meet The Experts:

 
 
 
  • Mike

    Mac Medic

    Satisfied Customers:

    6256
    Over 20 years IT experience with Apple computers in publishing, marketing and design.
< Last | Next >
  • http://ww2.justanswer.com/uploads/macthelife/2009-10-20_1899_mikesebaharsquare64.jpg Mike's Avatar

    Mike

    Mac Medic

    Satisfied Customers:

    6256
    Over 20 years IT experience with Apple computers in publishing, marketing and design.
  • http://ww2.justanswer.com/uploads/AS/ashiknasameen/2012-5-15_141836_final2.64x64.jpg Ashik's Avatar

    Ashik

    Mac Helper

    Satisfied Customers:

    5282
    7+ Years of Experience in troubleshooting Macs, iPhone, iPad, iPod etc
  • http://ww2.justanswer.com/uploads/DP/dpean/2012-6-6_172828_avatorme1.64x64.JPG Daniel's Avatar

    Daniel

    Mac Genius

    Satisfied Customers:

    4670
    Apple certified on desktop and portable, help desk qualified. Have owned and used Macs since 1989.
  • http://ww2.justanswer.com/uploads/VI/vinodvmenon2005/1.64x64.jpg Vinod Menon's Avatar

    Vinod Menon

    Support Specialist

    Satisfied Customers:

    2068
    worked as a Tech support Associate for Apple products
  • http://ww2.justanswer.com/uploads/BE/beboo/2011-1-14_201648_n5063313142021801763.64x64.jpg Brandon M.'s Avatar

    Brandon M.

    Mac Support Specialist

    Satisfied Customers:

    1501
    10+ Years Mac Support as contractor and currently an IT Manager for law firm
  • http://ww2.justanswer.com/uploads/MA/MacDruid/IMG_0232.64x64.JPG John T. F.'s Avatar

    John T. F.

    Mac Druid

    Satisfied Customers:

    1408
    20+ years in the computer/Mac industry
  • http://ww2.justanswer.com/uploads/MA/MacHelpdesk/1d2d506.64x64.jpg David's Avatar

    David

    Mac Support Specialist

    Satisfied Customers:

    1236
    BSc, H.Dip, Apple Certified