In this hands-on project, you create a basic shell script and execute it on the system.1. Switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2 and log in to theterminal using the user name of root and the password of LNXrocks!.2. At the command prompt, type vi myscript and press Enter to open a new file forediting called myscript in your home directory.3. Enter the following text into the myscript file. When finished, save and quit the vi editor.#!/bin/bashecho –e “This is a sample shell script. \t It displays mountedfilesystems \a”mount4. At the command prompt, type ls -l myscript and press Enter. What permissionsdoes the myscript file have? Next, type bash myscript at the command prompt andpress Enter. Did the shell script execute? What do the \t and \a escape sequences do?5. Next, type ./myscript at the command prompt and press Enter. What error messagedid you receive and why?6. At the command prompt, type chmod u+x myscript and press Enter. Next, type./myscript at the command prompt and press Enter. Did the script execute? Why?7. Type exit and press Enter to log out of your shell.
In this hands-on project, you create a basic shell script and execute it on the system.
1. Switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2 and log in to the
terminal using the user name of root and the password of LNXrocks!.
2. At the command prompt, type vi myscript and press Enter to open a new file for
editing called myscript in your home directory.
3. Enter the following text into the myscript file. When finished, save and quit the vi editor.
#!/bin/bash
echo –e “This is a sample shell script. \t It displays mounted
filesystems \a”
mount
4. At the command prompt, type ls -l myscript and press Enter. What permissions
does the myscript file have? Next, type bash myscript at the command prompt and
press Enter. Did the shell script execute? What do the \t and \a escape sequences do?
5. Next, type ./myscript at the command prompt and press Enter. What error message
did you receive and why?
6. At the command prompt, type chmod u+x myscript and press Enter. Next, type
./myscript at the command prompt and press Enter. Did the script execute? Why?
7. Type exit and press Enter to log out of your shell.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images