Shell scripting and automated account management

Assignment Help Other Subject
Reference no: EM132637185

Assessment item - File Systems and Advanced Scripting

Task 1: Reflection on Hands-on Projects

Project 3-4
In this hands-on project, you display file contents using the cat, tac, head, tail, strings, and od commands.

1. Switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5, and then log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type cat /etc/hosts and press Enter to view the contents of the file hosts, which reside in the directory /etc. Next, type cat -n /etc/hosts and press Enter. How many lines does the file have? At the command prompt, type tac /etc/hosts and press Enter to view the same file in reverse order. The output of both commands should be visible on the same screen. Compare them.
3. To see the contents of the same file in octal format instead of ASCII text, type od /etc/hosts at the command prompt and press Enter.
4. At the command prompt, type cat /etc/inittab and press Enter.
5. At the command prompt, type head /etc/inittab and press Enter. What is displayed on the screen? How many lines are displayed, which ones are they, and why?
6. At the command prompt, type head -5 /etc/inittab and press Enter. How many lines are displayed and why? Next, type head -3 /etc/inittab and press Enter. How many lines are displayed and why?
7. At the command prompt, type tail /etc/inittab and press Enter. What is displayed on the screen? How many lines are displayed; which ones are they and why?
8. At the command prompt, type tail -5 /etc/inittab and press Enter. How many lines are displayed and why? Type the cat -n /etc/inittab command at a command prompt and press Enter to justify your answer.
9. At the command prompt, type file /bin/nice and press Enter. What type of file is it? Should you use a text tool command on this file?
10. At the command prompt, type strings /bin/nice and press Enter. Notice that you can see some text within this binary file. Next, type strings /bin/nice | more to view the same content page- by-page. When finished, press q to quit the more command.
11. Type exit and press Enter to log out of your shell.

Project 3-7
In this hands-on project, you use the grep and egrep commands alongside regular expression metacharacters to explore the contents of text files.

1. Switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type grep "Inn" sample1 and press Enter. What is displayed and why?
3. At the command prompt, type grep -v "Inn" sample1 and press Enter. What is displayed and why? How does this compare to the results from Step 2?
4. At the command prompt, type grep "inn" sample1 and press Enter. What is displayed and why?
5. At the command prompt, type grep -i "inn" sample1 and press Enter. What is displayed and why? How does this compare to the results from Steps 2 and 4?
6. At the command prompt, type grep "I" sample1 and press Enter. What is displayed and why?
7. At the command prompt, type grep " I " sample1 and press Enter. What is displayed and why?
8. At the command prompt, type grep "t.e" sample1 and press Enter. What is displayed and why?
9. At the command prompt, type grep "w...e" sample1 and press Enter. What is displayed and why?
10. At the command prompt, type grep "^I" sample1 and press Enter. What is displayed and why?
11. At the command prompt, type grep "^I " sample1 and press Enter. What is displayed and why?
12. At the command prompt, type grep "(we|next)" sample1 and press Enter. What is displayed? Why?
13. At the command prompt, type egrep "(we|next)" sample1 and press Enter. What is displayed and why?
14. At the command prompt, type grep "Inn$" sample1 and press Enter. What is displayed and why?
15. 15.At the command prompt, type grep "?$" sample1 and press Enter. What is displayed and why? Does the ? metacharacter have special meaning here? Why?
16. 16.At the command prompt, type grep "^$" sample1 and press Enter. Is anything displayed? (Hint: Be certain to look closely!) Can you explain the output?
17. 17.Type exit and press Enter to log out of your shell.

Project 4-5
In this hands-on project, you find files on the filesystem using the find, locate, which, type, and whereis commands.
1. Switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type touch newfile and press Enter. Next, type locate newfile at the command prompt and press Enter. Did the locate command find the file you just created? Why?
3. At the command prompt, type updatedb and press Enter. When the command is finished, type locate newfile at the command prompt and press Enter. Did the locate command find the file? If so, how quickly did it find it? Why?
4. At the command prompt, type find / -name "newfile" and press Enter. Did the find command find the file? If so, how quickly did it find it? Why?
5. At the command prompt, type find /root -name "newfile" and press Enter. Did the find command find the file? How quickly did it find it? Why?
6. At the command prompt, type which newfile and press Enter. Did the whichcommand find the file? Why? Type echo $PATH at the command prompt and press Enter. Is the /root directory listed in the PATH variable? Is the /usr/bin directory listed in the PATH variable?
7. At the command prompt, type which grep and press Enter. Did the which command find the file? Why?
8. At the command prompt, type type grep and press Enter. Next, type whereis grepand press Enter. Do these commands return less or more than the which command did in the previous step? Why?
9. At the command prompt, type find /root -name "sample" and press Enter. What files are listed? Why?
10. At the command prompt, type find /root -type l and press Enter. What files are listed? Why?
11. At the command prompt, type find /root -size 0 and press Enter. What types of files are listed? Type find / -size 0 | more to see all of the files of this type on the system.
12. Type exit and press Enter to log out of your shell.

Project 4-7 (Optional)
In this hands-on project, you apply and modify access permissions on files and directories and test their effects.
1. Switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type touch permsample and press Enter. Next, type chmod 777 permsample at the command prompt and press Enter.
3. At the command prompt, type ls -l and press Enter. Who has permissions to this file?
4. At the command prompt, type chmod 000 permsample and press Enter. Next, type ls -l at the command prompt and press Enter. Who has permissions to this file?
5. At the command prompt, type rm -f permsample and press Enter. Were you able to delete this file? Why?
6. At the command prompt, type cd / and press Enter. Next, type pwd at the command prompt and press Enter. What directory are you in? Type ls -F at the command prompt and press Enter. What directories do you see?
7. At the command prompt, type ls -l and press Enter to view the owner, group owner, and permissions on the foruser1 directory created in Hands-On Project 4-1. Who is the owner and group owner? If you were logged in as the user user1, in which category would you be placed (user, group, other)? What permissions do you have as this category (read, write, execute)?
8. At the command prompt, type cd /foruser1 and press Enter to enter the foruser1 directory. Next, type ls -F at the command prompt and press Enter. Are there any files in this directory? Type cp
/etc/hosts . at the command prompt and press Enter. Next, type ls -F at the command prompt and press Enter to ensure that a copy of the hosts file was made in your current directory.
9. Switch to a different command-line terminal (tty3) by pressing Ctrl1Alt1F3 and log in to the terminal using the user name of user1 and the password of LINUXrocks!.
10. At the command prompt, type cd /foruser1 and press Enter. Were you successful? Why? Next, type ls -F at the command prompt and press Enter. Were you able to see the contents of the directory?
Why? Next, type rm -f hosts at the command prompt and press Enter. What error message did you see? Why?
11. Switch back to your previous command-line terminal (tty5) by pressing Ctrl1Alt1F5. Note that you are logged in as the root user on this terminal and within the /foruser1 directory.
12. At the command prompt, type chmod o+w /foruser1 and press Enter. Were you able to change the permissions on the /foruser1 directory successfully? Why?
13. Switch back to your previous command-line terminal (tty3) by pressing Ctrl1Alt1F3. Note that you are logged in as the user1 user on this terminal and within the /foruser1 directory.
14. At the command prompt, type rm -f hosts at the command prompt and press Enter. Were you successful now? Why?
15. Switch back to your previous command-line terminal (tty5) by pressing Ctrl1Alt1F5. Note that you are logged in as the root user on this terminal.
16. At the command prompt, type cp /etc/hosts . at the command prompt and press Enter to place another copy of the hosts file in your current directory (/foruser1).

17. At the command prompt, type ls -l and press Enter. Who is the owner and group owner of this file? If you were logged in as the user user1, in which category would you be placed (user, group, other)? What permissions do you have as this category (read, write, execute)?
18. Switch back to your previous command-line terminal (tty3) by pressing Ctrl1Alt1F3. Note that you are logged in as the user1 user on this terminal and in the /foruser1 directory.
19. At the command prompt, type cat hosts at the command prompt and press Enter. Were you successful? Why? Next, type vi hosts at the command prompt to open the hosts file in the vi editor. Delete the first line of this file and save your changes. Were you successful? Why? Exit the vi editor and discard your changes.
20. Switch back to your previous command-line terminal (tty5) by pressing Ctrl1Alt1F5. Note that you are logged in as the root user on this terminal and in the /foruser1 directory.
21. At the command prompt, type chmod o+w hosts and press Enter.
22. Switch back to your previous command-line terminal (tty3) by pressing Ctrl1Alt1F3. Note that you are logged in as the user1 user on this terminal and in the /foruser1 directory.
23. At the command prompt, type vi hosts at the command prompt to open the hosts file in the vi editor. Delete the first line of this file and save your changes. Why were you successful this time? Exit the vi editor.
24. At the command prompt, type ls -l and press Enter. Do you have permission to execute the hosts file? Should you make this file executable? Why? Next, type ls -l /usr/bin at the command prompt and press Enter. Note how many of these files to which you have execute permission. Type file
/usr/bin/* | more at the command prompt and press Enter to view the file types of the files in the /bin directory. Should these files have the execute permission?
25. Type exit and press Enter to log out of your shell.
26. Switch back to your previous command-line terminal (tty5) by pressing Ctrl1Alt1F5. Note that you are logged in as the root user on this terminal.
27. Type exit and press Enter to log out of your shell.

Project 5-4
In this hands-on project, you create two new partitions using the GNU Parted utility, and configure the LVM to host an LV using the space within. During this process, you will learn how to create PVs, VGs, and LVs, as well as add storage to extend a VG and LV. Finally, you will edit the /etc/fstab file to ensure that your LV is mounted at boot time.
1. Switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type parted /dev/sda and press Enter. At the parted prompt, type help and press Enter to view the available commands.
3. At the parted prompt, type print and press Enter. Write down the End value for your first logical drive (/dev/sda5): (A). Next, write down the End value for your extended partition (/dev/sda4): (B). These two values represent the start and end of the remainder of the free space on your virtual hard disk.
4. At the parted prompt, type mkpart and press Enter to accept the default of logical drive. Press Enter again to accept the default partition type (Linux ext2). When prompted for the Start of the new partition, enter the (A) value you recorded in Step 3 and press Enter. When prompted for the End of the new partition, enter the (A) value you recorded in Step 3 plus 1GB and press Enter to create a 1GB partition.
5. At the parted prompt, type p and press Enter to view the partition table on your hard disk. What type of partition is /dev/sda6? Write down the End value for your second logical drive (/dev/sda6): (C).
6. At the parted prompt, type mkpart and press Enter to accept the default of logical drive. Press Enter again to accept the default partition type (Linux ext2). When prompted for the Start of the new partition, enter the (C) value you recorded in Step 5 and press Enter. When prompted for the End of the new partition, enter the (C) value you recorded in Step 5 plus 1GB and press Enter to create another 1GB partition.
7. At the parted prompt, type quit and press Enter to save the changes to the hard disk and exit the GNU Parted utility.
8. At the command prompt, type reboot and press Enter to reboot your machine and ensure that the partition table was read into memory correctly. After your Linux system has been loaded, switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
9. At the command prompt, type pvcreate /dev/sda6 and press Enter. Next, type pvscan and press Enter to verify the creation of your PV. Following this, type pvdisplay and press Enter to view the PE size chosen as well as the total size of the PV.
10. At the command prompt, type vgcreate vg00 /dev/sda6 and press Enter. Next, type vgscan and press Enter to verify the creation of your vg00 VG. Following this, type vgdisplay and press Enter to view the PE size chosen as well as the total size of your VG.
11. At the command prompt, type lvcreate -L 0.9GB -n newdata vg00 and press Enter to create a 0.9GB LV called newdata from the vg00 VG. Why couldn't you specify a 1GB size for your LV? Next, type lvscan and press Enter to verify the creation of your LV. Following this, type lvdisplay and press Enter to view the path to the LV device file as well as the total size of your LV.
12. At the command prompt, type mkfs -t ext4 /dev/vg00/newdata and press Enterto format the newdata LV using the ext4 filesystem. Next, type mkdir /newdata and press Enter to create a mount point for the newdata LV. Following this, type mount /dev/vg00/newdata /newdata and press Enter to mount the newdata LV to the /newdata directory.
13. At the command prompt, type df -hT and press Enter to verify that your LV is mounted via the device mapper. Next, type ls -l /dev/vg00/newdata and press Enter, noting it is a symbolic

link to a device mapper device file. Following this, type lsblk and press Enter to note the relationship between your LV and your PV (/dev/sda6).
14. At the command prompt, type ls -F /newdata and press Enter. Is there a lost1found directory available? Why?
15. At the command prompt, type pvcreate /dev/sda7 and press Enter. Next, type pvscan and press Enter to verify the creation of your PV. Following this, type pvdisplay and press Enter to view the PE size chosen as well as the total size of the PV.
16. At the command prompt, type vgextend vg00 /dev/sda7 and press Enter. Next, type vgdisplay and press Enter to view the PE size chosen as well as note that the total size of your VG reflects both PVs.
17. At the command prompt, type lvextend -L +0.9GB -r /dev/vg00/newdata and press Enter to extend your newdata LV by another 0.9GB. Next, type lvdisplay and press Enter, noting the size has doubled. Following this, type df -hT and press Enter, noting the ext4 filesystem was automatically resized to match the new LV capacity.
18. At the command prompt, type lsblk and press Enter to note the relationship between your LV and your two PVs (/dev/sda6 and /dev/sda7).
19. At the command prompt, type vi /etc/fstab and press Enter. Add the following line to the bottom of the file to ensure that the newdata LV is mounted at boot time:
a. /dev/vg00/newdata /newdata ext4 defaults 0 0
20. Save your changes and quit the vi editor.
21. At the command prompt, type reboot and press Enter. After your Linux system has been loaded, switch to a command-line terminal (tty5) by pressing Ctrl1Alt1F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
22. At the command prompt, type df -hT and press Enter to verify that your LV was automatically mounted at boot time.
23. Type exit and press Enter to log out of your shell.

Project 7-3
In this hands-on project, you create and use an alias, as well as view and change existing shell variables. In addition to this, you export user-defined variables and load variables automatically upon shell startup.
1. Switch to a command-line terminal (tty5) by pressing Ctrl+Alt+F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.
2. At the command prompt, type set | less and press Enter to view the BASH shell environment variables currently loaded into memory. Scroll through this list using the cursor keys on the keyboard. When finished, press q to quit the less utility.
3. At the command prompt, type env | less and press Enter to view the exported BASH shell environment variables currently loaded into memory. Scroll through this list using the cursor keys on the keyboard. Is this list larger or smaller than the list generated in Step 2? Why? When finished, press q to quit the less utility.
4. At the command prompt, type PS1="Hello There:" and press Enter. What happened and why? Next, type echo $PS1 at the command prompt and press Enter to verify the new value of the PS1 variable.
5. At the command prompt, type exit and press Enter to log out of the shell. Next, log in to the terminal again using the user name of root and the password of LINUXrocks!. What prompt did you receive and why? How could you ensure that the "Hello There: " prompt occurs at every login?
6. At the command prompt, type vi .bash_profile and press Enter. At the bottom of the file, add the following lines. When finished, save and quit the vi editor.
echo -e "Would you like a hello prompt? (y/n) -->\c "read ANSWERif [ $ANSWER = "y" -o $ANSWER = "Y" ]
thenPS1="Hello There: " fi
Explain what the preceding lines will perform after each login.
7. At the command prompt, type exit and press Enter to log out of the shell. Next, log in to the terminal using the user name of root and the password of LINUXrocks!. When prompted for a hello prompt, type y and press Enter. What prompt did you receive and why?
8. At the command prompt, type exit and press Enter to log out of the shell. Next, log in to the terminal using the user name of root and the password of LINUXrocks!. When prompted for a hello prompt, type n and press Enter to receive the default prompt.
9. At the command prompt, type MYVAR="My sample variable" and press Enterto create a variable called MYVAR. Verify its creation by typing echo $MYVAR at the command prompt, and press Enter.
10. At the command prompt, type set | grep MYVAR and press Enter. Is the MYVAR variable listed? Why?
11. At the command prompt, type env | grep MYVAR and press Enter. Is the MYVAR variable listed? Why?
12. At the command prompt, type export MYVAR and press Enter. Next, type env | grep MYVAR at the command prompt and press Enter. Is the MYVAR variable listed now? Why?
13. At the command prompt, type exit and press Enter to log out of the shell. Next, log in to the terminal using the user name of root and the password of LINUXrocks!.
14. At the command prompt, type echo $MYVAR and press Enter to view the contents of the MYVAR variable. What is listed and why?
15. At the command prompt, type vi .bash_profile and press Enter. At the bottom of the file, add the following line. When finished, save and quit the vi editor.

export MYVAR="My sample variable"
16. At the command prompt, type exit and press Enter to log out of the shell. Next, log in to the terminal using the user name of root and the password of LINUXrocks!.
17. At the command prompt, type echo $MYVAR and press Enter to list the contents of the MYVAR variable. What is listed and why?
18. At the command prompt, type alias and press Enter. Note the aliases that are present in your shell.CHAPTER 7 Working with the BASH
19. At the command prompt, type alias asample="cd /etc ; cat hosts ; cd ~ ; ls -F" and press Enter. What does this command do?
20. At the command prompt, type a sample and press Enter. What happened and why? What environment file could you add this alias to such that it is executed each time a new BASH shell is created?
21. Type exit and press Enter to log out of your shell.Deliverable: Write a 500-600 words (up to two A4 pages) report on lessons learned from these projects. Comment on each project individually within the two-page limit. You can write one lesson learned from each of the projects. You should answer the questions at each hands-on project.

#Task 2 Shell Scripting and automated account management

One of the difficult tasks that Linux administrators face is to manage users or new employees. The difficulty can be to add deletion and change user attributes. In this task, your job is to write a shell script that performs the following tasks:

the script must accept first, last or middle names,

the script must be able to assign a new user to a group of student (if the group does not exist, the script must create user group),

based on the first name and last name, the script should generate a unique username with a length of 5 characters,

the script must check if the username does not exist before adding,

generate a complex password for the new user,

based on username scripts generate an email within the csu.edu.au domain,

the scripts must be written in a Sentinel loop,

Important Note:
you have to submit all of the scripts for the above three tasks.
sufficient instructions to the user once the script has been executed,
the script needs the necessary commands,
the indentation has to be followed.
the script must be in TEXT format NOT screenshots (i.e., image

Reference no: EM132637185

Questions Cloud

Creating threat model : A new medium-sized health care facility just opened and you are hired as the CIO. The CEO is somewhat technical and has tasked you with creating a threat model.
Make a cash budget for the months of january : Make a cash budget for the months of January, February and March 1999 based on the data for 30% of Sales are collected in the month of sale
What is the length of curve : What is the length of curve, the station of PT, the defelection angles and the chord lengths for whole station?
Define axonometric projection and its types : Define Axonometric projection and its types?
Shell scripting and automated account management : Shell Scripting and automated account management - What is displayed on the screen? How many lines are displayed, which ones are they, and why?
Make a classified balance sheet in good form as of December : Accumulated depreciation-equipment $5,500 and Long-term debt $1,100. Make a classified balance sheet in good form as of December 31, 2019
Provide an example of an it project from your readings : Provide an example of an IT project from your readings, experience, and/or other sources and discuss some of the challenges faced in its implementation
Research on hearsay rule in legal proceedings : Do a bit of research on the hearsay rule in legal proceedings.
What were some of failures in the budget and budget process : For the third assignment we continue to look at budget implementation and the challenges and consequences of revenue and appropriation forecasts.

Reviews

Write a Review

Other Subject Questions & Answers

  Explain the transformational leadership in brief

The journal article focus on transformational leadership and knowledge sharing within an organization, please review these concepts and answer the following.

  A statistics professor would like to determine whether

a a statistics professor would like to determine whether students in the class showed improved performance on the final

  What is a performance appraisal

What is a performance appraisal? How can it be used for growth and development purposes?What are some issues with the use of a succession plan

  Find the exact center of data

Yes, if there are no values that occur more than once, the mode cannot be used to determine the measure of center. But if there are values that occur frequently the mode can be used. If there are 2 values that occur with the same greatest freque..

  Building and leading teams

Locate and review the article "Building and Leading Teams" by using the Academic Search Complete database in the CSU Online Library.

  Explain a current issue being debated about american economy

Identify a current issue being debated about the American economy. Explain two competing solutions to this problem. Evaluate which one is preferable.

  Paper- reasoning and uncertainty in artificial intelligence

Write a detailed paper on Reasoning and Uncertainty in artificial intelligence

  What two strategies could you use to assist your learners

What two strategies could you use to assist your learners/trainees with this protocol of learning based on your two noted areas

  Significant methods that health care systems should use

Determine two (2) significant methods that health care systems should use in order to prevent misuse of information and protect data privacy and thus achieve a high level of security of health information. Provide a rationale to support your respo..

  Provide a brief discussion of the article drawing attention

Provide a brief discussion of the article drawing attention to the three most important issues contained within the article (bullet points may be used to facilitate this). Do not provide a lengthy summary of the article. This is what’s making iron or..

  The finger and toes bones of bipedal species tend to

The finger and toes bones of bipedal species tend to be. While humans and African apes are capable of bipedal locomotion. Some australopithecines show adaptations for bipedalism and yet retain other adaptations that appear to point to some

  How did the characters respond to the stereotypes

Discuss three instances of stereotyping in the film. Then, answer the following questions about the stereotypes in the film: How did the stereotypes originate? How did the characters respond to the stereotypes?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd