I need help with Unix doing this, instructions or steps Make a script in UNIX th
ID: 3750897 • Letter: I
Question
I need help with Unix doing this, instructions or steps
Make a script in UNIX that permits:
Create a group named cpen452
Create a user which group be cpen 452
Search all the files with extension .txt y and delete them
Create a directory called quiz and create in that 10 files with the same name that the last characters be a consecutive number between 0 and 9; everything has to be realized with the same command.
Realize a copy of the home directory in a usb
List all the processes en the system y ("Kill") one of them with the same name
Send a message to all the users of the system : "Save all your work and close session, the system will turn off in 2 minutes"
Close
I need help with Unix doing this, instructions or steps
Make a script in UNIX that permits:
1. Create a group named cpen452
2. Create a user which group be cpen 452
3. Search all the files with extension .txt y and delete them
4. Create a directory called quiz and create in that 10 files with the same name that the last characters be a consecutive number between 0 and 9; everything has to be realized with the same command.
5. Realize a copy of the home directory in a usb
6. List all the processes en the system y ("Kill") one of them according to relevance
7. Send a message to all the users of the system : "Save all your work and close session, the system will turn off in 2 minutes"
8. Close
*Copy the script in the home directory (of each one of the integrants)
Explanation / Answer
Answer) The script for all the commands I had done. I put # for comments of the answer.
#script starts
#1. Create a group named cpen452
groupadd cpen452
#2. Create a user which group be cpen 452. Linux is the username, -g for groupname
useradd -g cpen452 linux
#3. Search all the files with extension .txt y and delete them
find . -name '*.txt' -exec rm {} ;
#4. Create a directory called quiz and create in that 10 files with the same name that the last #characters be a consecutive number between 0 and 9; everything has to be realized with the same #command.
mkdir quiz
cd quiz
for i in {0..9}; do touch quiz$i; done
cd ..
#5. Realize a copy of the home directory in a usb. /mnt/usb is the mount point of usb
cp -r /home/* /mnt/usb
#6. List all the processes en the system y ("Kill") one of them according to relevance
ps -ef;kill `ps -ef|sort|tr -s " "|cut -d " " -f 2|head -1`
#7. Send a message to all the users of the system : "Save all your work and close session, the #system will turn off in 2 minutes"
wall "Save all your work and close session, the system will turn off in 2 minutes"
#8. close
exit
#script ends
Just create a script file like script.sh, copy all the contents and run sh script1.sh
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.