Question

In LINUX Q1 A) Create a user with name “user1” from root directory. B) Change “user1”...

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

c) Option 3: exit.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

sudo useradd user1
[enter your password]
sudo su
[enter your password]
userdel user1

useradd user2

passwd user2
[enter new password]

usermod -a -G java user2

2)

menu_script.sh:

printf "`echo "Enter option: " `"
#prompt for option
read ch
#get input into ch
case $ch in
1)    ls;;
     
2)    printf "`echo "Enter a number n: " `"
       #prompt for a number
       read n  
       #get input into n
       i=1
       while [ $i -le $n ]
       do
       echo $i
       i=$(($i+1))
       done;;
3)    echo "Terminating..."
       exit;;
  
esac

Output:

shyam@shyam:~$ sudo useradd user1 [sudo] password for shyam: shyam@shyam:~$ sudo su root@shyam:/home/shyam# userdel user1 root@shyam:/home/shyam# useradd user2 root@shyam:/home/shyam# passwd user2 Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully root@shyam:/home/shyam# usermod -a -G java user2 root@shyam:/home/shyam# |

shyam@shyam:~/Documents/HomeworkLib/linux$ chmod +x_menu_script.sh

shyam@shyam:~/Documents/HomeworkLib/linux$ ./menu_script.sh Enter option: 1 jane_research lab3.sh looper minor1.sh sorted_orders test.inp traceroute_script2.sh traceroute_script.sh customers progTTL.sh ex7.sh file1.txt newFile.txt report orders script_1.sh script_2.sh sorted_customers 5 awkprof.out customerOrders input shyam@shyam:~/Documents/HomeworkLib/linux$ ./menu_script.sh Enter option: 2 Enter a number n: 10 flights.txt looper2 output menu_script.sh prime.sh 2 3 4 5 10 shyam@shyam:~/Documents/HomeworkLib/linux$ ./menu_script.sh Enter option: 3 Terminating... shyam@shyam:~/Documents/HomeworkLib/linux$ |

Add a comment
Know the answer?
Add Answer to:
In LINUX Q1 A) Create a user with name “user1” from root directory. B) Change “user1”...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 1 Write a BASH script to create a user account from the Linux system on...

    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. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...

  • Using only shell commands, create a directory structure in your Linux file system to organize files...

    Using only shell commands, create a directory structure in your Linux file system to organize files for this course. An example structure may look like the following: osweb homework homework1.c homework2.java homework3.cpp labs lab1 setup.txt projects Include the following by only using shell commands: List the contents of a directory Write data to a text file Print the contents of a text file to the terminal Delete a text file Move a text file to a different directory Rename a...

  • Write a bash script that prompts a user with a menu of choices: Get the total...

    Write a bash script that prompts a user with a menu of choices: Get the total number of shell files from the current directory Get the total size of all the shell files from the current directory Get the total number of empty files in the system from the current directory Each option must be its own specific function. linux only

  • Login to Suse Linux as root. Complete the task working as the root user. 1. What...

    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...

  • UNIX/LINUX Help. I need to modify this script so that the output of the file name...

    UNIX/LINUX Help. I need to modify this script so that the output of the file name is changed from you_someAssignment.txt to You.someAssignment.txt. #!/bin/sh if [ $# -eq 1 ]; then STUDENTNAME=$USER ASSIGNMENT=$1 else echo "usage: `basename $0` [assignment]" exit 1 fi if [ ! -d "$ASSIGNMENT" ]; then # Control will enter here if $ASSIGNMENT doesn't exist. mkdir $ASSIGNMENT fi # Move into the directory cd $ASSIGNMENT # Variable for the filename FILENAME=$USER\_$ASSIGNMENT.txt HOST=$(hostname) DATE=$(date +"%m-%d-%Y") TIME=$(date +"%r") if [...

  • Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a...

    Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a time. Prepend each line with a line number followed by a colon and then a space. Example output: 1: root:x:0:0:root:/root:/bin/bash 2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 3: bin:x:2:2:bin:/bin:/usr/sbin/nologin 4: sys:x:3:3:sys:/dev:/usr/sbin/nologin Exercise 2: Write a shell script that asks the user for the number of lines they would like to display from the /etc/passwd file and display those lines. Example output: How many lines of /etc/passwd would you like...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • Create a python script to manage a user list that can be modified and saved to...

    Create a python script to manage a user list that can be modified and saved to a text file. Input text file consisting of pairs of usernames and passwords, separated by a colon (:) without any spaces User choice: (‘n’-new user account, ‘e’-edit existing user account, ‘d’- delete existing user account, ‘l’- list user accounts, ‘q’-quit) List of user accounts, error messages when appropriate Output text file consisting of pairs of username and passwords, separated by a colon (:) without...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT