This is the question I need you to focus on. All of the other stuff I posted wit
ID: 3570803 • Letter: T
Question
This is the question I need you to focus on. All of the other stuff I posted with this question is just so that you know everything else that went into getting to this point.
You have created the directory structure and some base files to be used by the Web server and Web site. For the Web site to be created in a production environment, you need to package your commands in a script so that the patching team can run them on the production environment. Your task for this assignment is the following:
Create a Bourne shell script. The script should do the following:
Explain what the script will do and who is the author in a comment area.
cd to your home directory
Show your current working directory.
List the contents of the current directory.
Create the directory structure and create the files as defined in the previous Individual Project.
For each directory and file, test to see if the file or directory already exists; if it does exist, do not recreate; if it is missing, create it.
In the end, generate a directory listing showing the structure and content of the new directories.
At the beginning of the script, set a variable called INSTALL_DIRECTORY that will contain the location of the directory into which the Web server will be installed. At the end of the script, display the contents of this variable along with a message to the installer about the location in which the directories were created.
A small hint for creating the content of the httpd.conf file: use the echo command in your script. The script is not interactive and should create all objects automatically. Also, the ServerRoot and DocumentRoot should contain correct values based on your directory names.
If you need to test that directories are created or not based on them already existing, remove files and directories ahead of time to ensure you know the exact state of your environment.
This is the finished assignments for the first four weeks of the class. I hope this extra information helps.
First four weeks of assignments:
Week 1
For each of the following commands, execute the command, show the resulting output, and describe what each one does:
Copy and paste a screenshot showing the execute and output of each command. After each screenshot, describe what the command was intended to accomplish and what it actually did.
Week 2
During the initial setup and implementation of the Web site, you have been reviewing some of the documentation, scripts, and sample files that were installed on the Linux and Apache environment. In more than one place, you have noticed several familiar commands, but they have all been on one line. The ability of one command to send the output it generates to the input of a second command is a very important concept for the UNIX environment.
Describe the concepts of filters, pipes, and redirection and explain how and what the following commands are trying to accomplish (if some commands are not yet familiar, you can describe the overall process of each step):
ls /etc | grep conf | grep -v "." | sort > ~/conf
cat /etc/passwd | awk -F":" '{print $1}' | sort >> ~/users 2>&1
The deliverable for the assignment should include the following:
Week 3
To ensure the security of the files used by the new Web site, files need to access controls that limit which users can view and execute them. To further your understanding of file permissions, describe in detail these 5 file listings, explain all items on each line, explain what they specify or mean, and give the chmod command to set files with these permissions:
It is also a necessity to know and understand regular expressions, not only at the UNIX command line, but editors and some programs use them quite extensively.
Explain the following Metacharacters/Regular Expressions:
Explanation / Answer
Week 1 tasks you can run in your machine and share the ouput.
On highlevel I can explain what all command does:
1. cd --> changes to home directory of logged in user, equivalent to "cd ~" command
2. mkdir apache --> Makes "apache" dir in the current dir
3. cd APACHE --> Should fail since the object name in UNIX are case sensitive and there is no folder with APACHE name
4. cd apache --> changes to "apache" dir.
5. pwd --> Present working directory
6. cd ../../../../../../../etc --> Moves down 7 folder from current dir and then changes to etc folder.
7. cd /etc --> changes to root etc folder
8. cat passwd --> dsplays the content of passwd file present in root etc folder.
9. more passwd --> same as cat passwd with additional option to pause at each page of content.
Week 2 tasks
a) ls /etc | grep conf | grep -v "." | sort > ~/conf
ls /etc ==> displays the list of files in /etc folder
| grep conf ==> filters out all the lines from above commands output having "conf" keyword,
| grep -v "." ==> filters out all the lines from above commands output where "." is NOT present.
| sort ==> all the lines of above command output is sorted
> ~/conf ==> Stores the output of after sorting into a new "conf" file in user home directory.
b) cat /etc/passwd | awk -F":" '{print $1}' | sort >> ~/users 2>&1
cat /etc/passwd ==> displays all the lines from "/etc/passwd" file
| awk -F":" '{print $1}' ==> Cuts out the first field by using the field separator ":" from above output.
| sort ==> all the lines of above command output is sorted
>> ~/users ==> Sorted output of above command is appended into a "users" file in user home director if existing else creates the new file and stores the same
2 > &1 ==> If there are any errors occured during any of the commands that is also stored back in the file.
Week 3 tasks
a) -rwxr-xr-- 1 instruct staff 270311 Aug 11 2009 install.sh
- File type | normal file | (- normal, d = directory, s = socket, l = link)
rwx Permission | read/write/exec to owner
r-x Permission | read/exec to group
r-- Permission | read to others
1 Number of links of file
instruct Owner name
staff group name
270311 size of file in bytes
Aug 11 2009 last modified date/time of file.
install.sh filename.
chmod 754 install.sh # here 7 = 111 , 5=101 ,4=100 are octal numbers
b) -rw-r--r-- 1 instruct staff 348039 Aug 12 2008 User_Guide.txt
- File type | normal file | (- normal, d = directory, s = socket, l = link)
rw- Permission | read/write to owner
r-- Permission | read to group
r-- Permission | read to others
1 Number of links of file
instruct Owner name
staff group name
348039 size of file in bytes
Aug 12 2008 last modified date/time of file.
User_Guide.txt filename.
chmod 644 User_Guide.txt # here 6 = 111 , 4=100 ,4=100 are octal numbers
c) -rw-r----- 1 instruct staff 635106 Aug 12 2009 Admin_Guide.txt
- File type | normal file | (- normal, d = directory, s = socket, l = link)
rw- Permission | read/write to owner
r-- Permission | read to group
--- Permission | none to others
1 Number of links of file
instruct Owner name
staff group name
635106 size of file in bytes
Aug 12 2009 last modified date/time of file.
Admin_Guide.txt filename.
chmod 640 Admin_Guide.txt # here 6 = 111 , 4=100 ,0=000 are octal numbers
d) drwxr-xr-x 4 instruct staff 144 Aug 12 2009 Documents
d File type | directory | (- normal, d = directory, s = socket, l = link)
rwx Permission | read/write/execute to owner | execute permission in dir allows user to navigate to that folder.
r-x Permission | read/execute to group | execute permission in dir allows user to navigate to that folder.
r-x Permission | read/execute to others | execute permission in dir allows user to navigate to that folder.
4 Number of links of files/folder in that folder.
instruct Owner name
staff group name
144 size of file in bytes
Aug 12 2009 last modified date/time of folder
Documents folder name
chmod 755 Documents # here 7 = 111 , 5=101 ,5=101 are octal numbers
e) -rwsr-sr-x 1 nobody nobody 169202 Aug 11 2009 httpd
- File type | normal file | (- normal, d = directory, s = socket, l = link)
rws Permission | read/write/execute(s) to owner | (s) execute permission with sticky bit 1 means the the file can be executed with owner of the filename as user.
r-s Permission | read/execute to group | (s) execute permission with sticky bit 1 means the the file can be executed with owner of the filename as user.
r-x Permission | read/execute to others | without root permissions
1 Number of links of files
nobody Owner name
nobody group name
169202 size of file in bytes
Aug 11 2009 last modified date/time of folder
httpd file name
chmod 6755 httpd # here 7 = 111 owner , 5=101 group ,5=101 other are octal numbers and first 6 digit indicates the setguid (s) for owner and group of file both.
Means of regular expressions
* = Anycharacter
? = Any one character
^ = Start of the line
$ = End of the file
[0-9] = Any one numeric character
[a-z] = Any one lower case alphabet character
Regular expressions to match
txt$ = All files that end in txt
?a*sh$ = Files that have a second character of a and end in sh
^[0-9]* = Any file that starts with a number
^$ = A blank line
"([0-9][0-9][0-9]) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]"
=A traditional 10-digit U.S.-based phone number, in the following format (407) 555-1212
Week 4 tasks:
mkdir apache
mkdir apache/bin
mkdir apache/conf
mkdir apache/lib
mkdir www
mkdir www/html
mkdir www/cgi-bin
mkdir www/ftp
chmod -R 755 apache
chmod -R 750 www
chmod -R 771 www/ftp
touch apache/bin/httpd
chmod 755 apache/bin/httpd
touch www/html/index.html
chmod 644 www/html/index.html
chmod 711 www/cgi-bin/process.pl
cat > apache/conf/httpd.conf <<-EOF
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# Do not add a slash at the end of the directory path.
#
ServerRoot "/usr"
#
# DocumentRoot: The directory out of which you will serve your documents.
#
DocumentRoot "/Library/WebServer/Documents"
EOF
chmod 664 apache/conf/httpd.conf
cat apache/conf/httpd.conf
grep -e"ServerRoot" -e"DocumentRoot" apache/conf/httpd.conf
cd www
sed "s_/Library/WebServer/Documents_`pwd`_g" apache/conf/httpd.conf
awk -F":" '{print $1 - $2}' /etc/passwd
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.