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 the bash script Write a script compress_large_files.sh. This script accepts one or more command line arguments. The first argument has to be an integer; let’s call it size. If this is the only command line argument, compress_large_files.sh inspects all files in the current working directory and compresses every file of size at least size. If there is more than one command line argument, all arguments except the first one must be valid directories. In this case, compress_large_files.sh inspects the...
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...
Write a script in MATLAB that prompts the user to do a, b, & c. a.)script that prompts the user to enter the day of the week using the input function. If the information the user enters is equal to “Saturday” or “Sunday”, display “have a nice weekend” in the Command Window. Otherwise, display “Good luck in your class lectures and your studies.” b.)script that prompts the user to input the following array by providing an example in the prompt:...
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...
In LINUX Q1 A) Create a user with name “user1” from root directory. B) Change “user1” shell to “/bin/bash” from root directory. C) Delete the user “user1” from root directory. D) Set a password for “user2” from local user directory. E) Add “user2” to group “java”. Q2: Write a menu script that has 3 option: a) Option 1: list all file in current directory. b) Option 2: ask user enter a number n, and print 1 to n to screen...
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...