CIS206_4.2_Shell_Scripting_Corey_Adams

docx

School

ECPI University, Greensboro *

*We aren’t endorsed by this school

Course

206

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

2

Uploaded by corada5995

Report
CIS206 – 4.2 – Shell Scripting Research a practical example of where shell scripting is used. Some examples were presented above. Make sure not to repeat an example from your classmates. A shell script is a text file that contains a command sequence for UNIX-based operating systems. It's termed a shell script because it condenses a series of commands that would otherwise have to be typed one at a time on the keyboard into a single script. Shell scripts are often used for a variety of system administration activities, including disk backups, system log analysis, and so on. They're also frequently utilized as complicated program installation scripts. Shell scripts are best for repetitive operations that would take too long to complete by typing one line at a time. Shell scripts can be used for a variety of applications, including: The process of compiling code is becoming automated. Creating a programming environment or running a program. Batch completion. Manipulation of data. Existing programs are being linked together. Backups are being performed on a regular basis. A system is being monitored. Find a useful Linux system administration shell script on the Internet. This script allows the root user or admin to add new users to the system in an easier way by just typing the username and password.
CIS206 – 4.2 – Shell Scripting #!/bin/bash # Script to add a user to Linux system if [ $(id -u) -eq 0 ]; then read -p "Enter username : " username read -s -p "Enter password : " password egrep "^$username" /etc/passwd >/dev/null if [ $? -eq 0 ]; then echo "$username exists!" exit 1 else pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) useradd -m -p $pass $username [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!" fi else echo "Only root may add a user to the system" exit 2 fi
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help