UNIX Scripting using Gnome

profileMRyn28
michaelryan_cs345__ip1.doc.docx

CS325-1404B-01

Individual Project 1

Michael F. Ryan Jr.

11/28/2014

Contents UNIX Programming 3 UNIX Processes 5 Introduction to Perl 6 Writing Perl Programs 7 UNIX Tools 8 References 9

UNIX Programming

#1/bin/sh

echo “Do you wish to shutdown or reboot {S|R};

read option

case $option

S)

Shutdown –i 0 $message;

;;

R)

Shutdown –i 6 $message;

;;

esac

In my example in which case I am still working on Cygwin to get it operational the above example demonstrates how automated shutdown process can be executed. I will explain each portion of the command line demonstrating my understanding of the process.

The command that I am using is asking if the user wants to shut down or reboot. The system after prompting the user for their selection will read what option the user has selected. The first case scenario or the first option that the user may choose is the shutdown option. In the command line you can see that the shutdown command has a –i 0 command next to it. The command is a UNIX level 0 which drops the system to a full shutdown. The first selection will completely shut down the system itself but will not physically shut down the machine. The next portion of the command line is the -i 6 command which means that the user has decided to reboot the system in which case the whole system including the machine will restart effectively applying the desired action. Finally the esac command represents escape which will allow you to leave the insert mode and test your file that you have just created.

Level 0: At level zero all processes will shut down. When you wish to replace a disk as per the live chat example you can use the following command to execute the described process

Example: # shutdown –y –I 0 –t120 “Disk Replacement”

In this example shutdown is the actual command used to enact the desired process, -y means that you want the command to execute without prompting any questions, -I 0 is the specific UNIX level that you want the system to revert to and -t120 is the amount of time that you want such as how long it will take for the shutdown command to execute.

Level 1(System Administrator Mode): Level one is used when maintenance or other preventative services are occurring. At level one an example of a service would be if a security patch or some other kind of maintenance or upgrade tasks must occur.

Level 2(Multi-User Mode): At level two the multi-user environment terminal starts processing and daemons are spawned

Level 3(Extends Multi-User Mode): At level three the system now has the ability to send and receive local resources the network.

Level 4(Alternate Multi-User Environment Configuration): Level four is defined as an alternative environment but does not require system operation to use and most than likely will not be used.

Level 5(Shuts Down Machine): Level five shuts your machine down unlike the other command levels. Upon giving the level five identifier you can successfully and safely remove power from the system if you are able to.

Level 6(System Reboot): When a level six value is assigned such in the command line it provides the system with direction which reboots the system automatically. The level six command can be used to restart the system to allow the updates or upgrades to be applied after the designated action has occurred.

Example: #shutdown –y –I 6 –t120 “Disk Replace”

In the example upon the disk replacement the system will automatically reboot itself so that the changes can occur.

UNIX Processes

You now need to write a script for user maintenance. Write a script that will perform the following tasks:

· Prompt the system administrator for all valid input parameters

· Generate a menu to ask which task is needed to be performed

· Create a UNIX group

· Groupadd –g GID group e-commerce

· Drop a UNIX group

· Groupdel e-commerce

· Create a user

· Login ID: X: UID: Comment: home_directory: Login_Shell

· Useradd –u 90 –g 600 or other –d /bin/ksh –m /home/Ryan –s /bin/sh –c “This Is new” New User1

· Drop a user

· Userdel –r New User1

A third script that you need to write will kill all of the processes associated with a user. The following are the requirements:

· Prompt the system administrator for the target user name

· List the running processes for that user

· Confirm with the system administrator before killing the processes

· Kill the processes after confirmation

It is very important to note with this task that you should only kill processes for a user and his or her running processes; do not arbitrarily kill running daemons.

· Include a discussion about the difference between user processes and daemons.

· What are daemons, and what are they used for?

· What are the consequences of killing a daemon using this script?

Add the 2 scripts and the discussion about daemons to the project template section "UNIX Processes."

Introduction to Perl

TBD

Writing Perl Programs

TBD

UNIX Tools

TBD

References

Run Levels for Various Unices. (2008, September 11). Retrieved November 28, 2014, from http://saifulaziz.com/tag/unix-run-levels/