25 pts - Operating Systems Q&A VI
Visit this course in D2L and complete Quiz06 by the due date / time for this assignment.
25 pts - Linux script to test user privileges
Ref: (Video) Using bash script to 'unit test' access privilege | Notes | (bash script) TestAccess.sh (as a text file)
Revisit the context of TechPrac05 Item III with four users (auser, buser, cuser and duser) and three directories (AlphaDir, BetaDir, and GammaDir) each containing files (FileA.txt and FileB.txt) within your admin login Documents folder; that exercise had you establish a variety of permissions for these users among these directories and files.
Double-check you have directories and files setup as indicated in the previous TechPrac item and then install TestAccess.sh in your admin login Documents folder. This script tries a variety of access to the folders and files reporting whether access was successful ... something of a 'black box' test of whether access control permissions have been set correctly. For instance the command (issued with your admin login Documents folder as current working directory)
su -c 'bash TestAccess.sh AlphaDir' auser
will try accessing AlphaDir and its files while logged in as auser; inspection of the results vis-à-vis the requirements for auser access to AlphaDir will let you know whether access permissions are correct.
You could run TestAccess.sh twelve times ... once for each combination of user and directory ... but it helps to create the following UserTests.sh script in the same folder to make all the tests for one user
#!/bin/sh
bash TestAccess.sh AlphaDir
bash TestAccess.sh BetaDir
bash TestAccess.sh GammaDir
Issuing the command
su -c 'bash UserTests.sh' auser > auserResults.txt
will test auser's access for all three directories, placing the test outcomes in the file auserResults.txt.
Deliverables: Use these scripts to test access for all four users in the three target directories, naming the results *userResults.txt where * is a, b, c or d according to the user. Review that your results conform to the requirements of the previous TechPrac item and if they do not then change permissions so that the requirements are met and rerun the test script. Note: Full credit on your TP05.III grade is not an indication that your access controls have been set properly; in grading I looked for a few key items but it is very hard to validate complex access control requirements from these permissions listings which is why we are following up with a scripting approach. Attach your four completed results files to this assignment in D2L.
(25 pts) Backups 101 (Windows version) We will use the Windows GUI to make backup and restore of user folders using a 'local' backup folder. Note: In 'real life' backups should be scheduled for automatic execution, executed from a command line, include system folders in case a server restore is needed, and not back up locally (since if the backup is located on the same computer as that being backed up, in a computer failure we can't get to the backup).
Ref: (Video) Backups 101 in Windows
Ref: (Document) How to create a file share in Windows Server
Ref: (Document) How to backup Windows Server 2016
Complete this exercise in your xxxxWS1 Windows Server VM using, primarily, guidance from How to backup Windows Server 2016 and How to create a file share in Windows Server but also tips from the reference video. Begin a Word document named WindowsBkp.docx to hold the four screen caps that will document your progress with this exercise.
Create a user named Backup Test with login ID bkptest and a password you
choose. Login to your VM as bkptest and
create a text document VIP.txt
saved in Documents (for bkptest) with the
content This is a very important file.
Logout
bkptest and
log back in with your administrator login. In a PowerShell window
with elevated administrator privilege run the
following commands:
Clear-Host;
Get-Date;
Get-ChildItem C:\Users;
Get-Content C:\Users\bkptest\Documents\VIP.txt;
and then grab a screen cap of the results to add to WindowsBkp.docx.
Create a share named bkp
which points to the directory
C:\Temp\Backups
(you will need to create both the Temp
folder and the sub-folder
Backups
first);
it's ok to share with everyone since there is access control on the
folder itself. Make a "Backup
Once" backup of C:\Users
(containing all user's
working directories, not just your own home directory) to the bkp
network share. Make the backup accessible by anyone who can access
the shared directory. In a PowerShell
window run the following commands:
Clear-Host;
Get-Date;
Get-ChildItem \\localhost\bkp;
and then grab a screen cap of the results to add to WindowsBkp.docx.
Execute the following commands from PowerShell with elevated permissions to simulate a disaster which wipes out bkptest's entire user folder and sub-folders; the takeown and icacls commands are fairly advanced Windows commands to give you full access to bkptest's folders and files. Note that the first command may take 15-30 seconds to run and the second might report a few folders as not found; no worries in either case. No screen cap of this needed.
takeown /f c:\users\bkptest /r /d y | Out-Null
icacls c:\users\bkptest /grant administrators:F /T | Out-Null
Remove-Item c:\users\bkptest -Recurse -Force
In a PowerShell window run the following commands:
Clear-Host;
Get-Date;
Get-ChildItem C:\Users;
Get-Content C:\Users\bkptest\Documents\VIP.txt;
The last command should produce an error, natch, because of the 'disaster'. Grab a screen cap of the results to add to WindowsBkp.docx.
Perform a complete restore from the backup just created. In a PowerShell window run the following commands:
Clear-Host;
Get-Date;
Get-ChildItem C:\Users;
Get-Content C:\Users\bkptest\Documents\VIP.txt;
and then grab a screen cap of the results to add to WindowsBkp.docx.
Attach the final version of WindowsBkp.docx to this assignment in D2L.
(25 pts) Work with text data files
Ref: (Video) Text files for data -- CSV, XML, JSON
Use either your xxxxWS1 or xxxxLS1 VM (or your host computer since we really don't need a specialized VM) for this task. Visual Studio Code or NotePad can be used to edit the files but you are welcome to use any other text editing program. Also, my intent is for you to create the files 'by hand' (copying & pasting, re-arranging format) to get a hands-on sense of the file formats but you are welcome to use a conversion tool or other means to create the files.
Attach copies of your three files to this assignment in D2L.
(25 pts) Create a Linux Service
Ref: (Article) Creating a Linux service with systemd
Ref: (Video) Creating a Linux service
Ref: (Notes) Create a Linux Service
Follow guidance the guidance from class and reading to create, deploy, and enable the rot13 service described in your xxxxLS1 VM. When finished execute the following commands in a terminal
date > LinuxService.txt
whoami >> LinuxService.txt
hostname >> LinuxService.txt
systemctl status rot13.service >> LinuxService.txt
nc -u localhost 10000 >> LinuxService.txt
I love AIST3720!
then pressing ctrl+c to close the service connection. Attach LinuxService.txt to this assignment in D2L.