Changes

Jump to: navigation, search

OPS235 Lab 1 - CentOS7

18 bytes added, 09:07, 25 April 2015
no edit summary
# Make certain to log out of your root account and remain as a regular user.
# Open a Shell terminal and use a text editor (such as <b><code><span style="color:#3366CC;font-size:1.2em;">vi</span></code></b> or <b><code><span style="color:#3366CC;font-size:1.2em;">nano</span></code></b>) to create a Bash Shell script called: <b><code><span style="color:#3366CC;font-size:1.2em;">reportmyreport.bash</span></code></b> in your current directory.
# Copy and paste the text below into your vi editing session for your file report.bash<br> (how do you copy and paste efficiently in Linux?)<br>
&#35;<br>
&#35; Purpose: Creates system info report<br>
&#35;<br>&#35; USAGE: ./reportmyreport.bash<br>
<br>
if [ $USER != "root" ] # only runs if logged in as root<br>
</code>
<br>
<ol><li value="4">Save your editing session, assign your report.bash file read and execute permissions (at least for the owner) and run by typing: <b><code><span style="color:#3366CC;font-size:1.2em;">./reportmyreport.bash</span></code></b></li><li>Did it run? If not what do you think you need to do in order to run the Bash Shell Script?</li><li>Issue the command <b><code><span style="color:#3366CC;font-size:1.2em;">su</span></code></b> and run the Bash shell again. Did it work?</li><li>Reopen your text-editing session for reportmyreport.bash and add the following lines of code to the bottom of the shell script file:</ol>
<br>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
</code>
<br>
<ol><li value="8">Save and run the bash shell script. View the contents of the file called "report.txt" that was generated (I hope you are using the up arrow key to issue previously issued command commands in order to save time!). Notice how the redirection symbol &gt; is used at the beginning of the report, and then the other redirection symbol &gt;&gt; is used to help "grow" the report with the other content.</li><li>The only remaining content of the report would be the system information. We can use a shell scripting trick called "command substitution" $( .. ) in order place results from an command to be used by another command (like echo). Re-edit the shell script and add the following code at the bottom of the shell script file:</li></ol>
<br>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
13,420
edits

Navigation menu