This question is on linux system. Please create a bash script that must include
ID: 3802001 • Letter: T
Question
This question is on linux system. Please create a bash script that must include everything asked for below
Please remember, the script has to be executable. name of of the script should be john.smith.sh
#!/bin/bash/
1- Create an I/O redirection to a file (send an output to any sort of file)
2- Then pipe it into something (ex: grep, awk, cut...)
3- Create a sybolic link
4- Use Wild cards
5- Create a user
6- Add the user to multiple groups
7- Create an alias for the script
8- Must include Reademe.md file (describing the script, what the script does)
please make sure it works and is exceutabe before posting the answer.
Explanation / Answer
1. ls -l > john.txt
This redirects the output which is the all the content info in that directory will be redirected to john.txt file and we didnt get any thing on screen.
2. ls -l >john.txt | grep "john" john.txt
This command lists the lines matching with word john and this output will be redirected to john.txt file. ls command is used to list the contents '>' is the redirection symbol which redirects the command output.
3. ln -s john.txt john1.txt
ln is the link command. "-s" is option to create symbolic link, it is mandatory if we want to create symbolic link.
4. ls *.txt
* is one of the wildcard in linux. Here the command lists all the .txt files in the current directory.
5. useradd john
useradd is the command used to create the user in linux followed by username to create.
6. usermod -G group1,group2,group3 john
usermod command with -G option is used to assign the user to the groups followed by groupnames seperated by commas followed by username.
7. alias j="sh john.smith.sh"
alias is the command used to create alias for the commands followed by the alias name which we want to set then followed by the commands in double quotes. Here j is the alias name for the script john.smith.sh.
Just put all this commands in the script file then just enter alias name because we are created alias name for this script file. Other wise you can normally execute the script.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.