Problem 1
Write a BASH script to create a user account from the Linux system
on which your script is run. The script should process two
positional parameters.
In your script:
Problem 2
Write a BASH script to delete a user account from the Linux system
on which your script is run. The script should process one
positional parameter.
In your script:
#!/bin/bash
user_name=$1
user_password=$2
if [ -z "$user_name" ] || [ -z "$user_password" ]
then
echo "usage: sudo bash adduser.sh <username>
<password>"
exit 1
elif [ $(id -u) -eq 0 ]; then
egrep "^$user_name" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$user_name exists!"
exit 1
else
pass=$(perl -e 'print
crypt($ARGV[0], "password")' $user_password)
useradd -m -p $pass
$user_name
[ $? -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
homedir=$(getent passwd "$USER" | cut -d: -f6)
if [ $homedir != "/home/"$user_name ]
then
echo "Home directory exists"
exit 3
else
grep $user_name /etc/passwd
fi
Let me know if its working for you so i create part 2 for account deletion script. thanks
Problem 1 Write a BASH script to create a user account from the Linux system on...
LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command line arguments and does NOT use the read command. I will give you no credit if your bash script includes a read command. Also, you need to have at least one for..in loop in your code even if there may be other ways to do this problem. The script will go through a list of entries in the current directory (do not process subdirectories):...
Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment to tell us what you did, why and how. 3. allows a user to enter their name and a number between 1 than 100 (this must be prompted so the user knows what to do) 4. creates a random number between 1 and 100 for you to guess. The command to create a random number is shown below. (if you find a better one...use...
Write a bash script to protect a directory. Your script should notify a user of the following: -New file was created -Permission changes -Ownership changes -File size changes -Modification date changes Your script should have two operation modes, protect and check. Use command line flags, -p <directory> and -c <directory> to decide which mode to operate in. In protect mode, your script should create a file called .protect inside the directory you want to watch. You will use this file...
(In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...
using lubuntu ce the following activities on your Linux virtual machine. Then complete estions. Write a script file which when executed will perform the following: First display today's date in dd.mm.YYYY format (e.g. 20.04.2019). Ask user to enter a name to create a directory. Create a directory by the given directory name above. . . Ask user to enter a name to create a file. Copy the file /etc/passwd to the given filename above inside the newly created directory Copy...
Login to Suse Linux as root. Complete the task working as the root user. 1. What is your current directory. What did you enter at the command prompt to determine your current working directory? 2. Change directories if needed to find your foods (or food) file. Use vi to make the file contain 10 food items. Save your file and quit. Use the cat command, and option, and the argument food to display the food file with numbered lines. Use...
Im trying to create a craps game on linux mint but im definitely not proficient with it. I'm a new student to this class and its done online. I seen a post that was already made with the exact question and requirements that I need to use for my script, but when I run the command it processes wrong, it goes like this... Name the script craps.sh The script will get 2 random numbers between 1-6. The script will display...
In some cases, people who are not strong in Linux may need to run specific Linux commands. To make this easier, you can create a menu-driven program that runs these Linux commands. Such a program allows users to execute the commands without having to actually know about how to execute them. For this scenario, create a menu-driven program that has the following options: 1. List users who are logged in (using the who command) 2. List system information (using the...
Create a Windows batch script. The batch script will contain the following: Ask the user interactively: Boot drive letter of the computer Computer name Computer Model Check to see if the boot drive in #1 exists with the folder newfolder (#1 above) If yes cd BootDrive\newfolder If no, make the directory BootDrive\newfolder Check to see if casefile.txt exists: If yes goto the label DONE Tell the user that data already exists in the newfolder folder and exit the program Output...
In this exercise, you will create a script called file_ops.sh that uses the various file operators The file_ops.sh script will Use one command line argument Use four IF THEN statement to compare the first command line argument Determine which file operators to use that produces the following output when the script run with the arguments shown WARNING: In the IF THEN statements, to avoid syntax error messages, there must be a space before and after each bracket and also between...