Open main menu

CDOT Wiki β

Changes

OPS235 Lab 1 - CentOS7

6 bytes removed, 13:28, 1 April 2015
no edit summary
<span style="font-family:courier;font-weight:bold;padding-left:4px;margin-left:15px;">
&#35;!/bin/bash # Forces script to run in the bash shell<br>
<br>
&#35; Author: *** INSERT YOUR NAME ***<br>
&#35; Date: *** CURRENT DATE ***<br>
&#35;<br>
&#35; USAGE: ./report.bash<br>
<br> <br> if [ $USER != "root" ] # checks to see if user is root, and exits script if not<br> then<br> &nbsp;echo "You must be logged in as root to run the command." >&2 # >&2 is a "redirection trick" to convert output as stderr<br> &nbsp;echo "Either login as root or issue command \"sudo ./report1.bash\"" >&2<br> &nbsp;exit 1<br> fi<br>
</span>
<span style="font-family:courier;font-weight:bold;padding-left:4px;margin-left:15px;">
&#35; Create report title<br>
<br> echo "SOFTWARE ASSET REPORT FOR INSTALLED LINUX SYSTEM" > /root/report.txt<br> echo "Date: $(date +'%A %B %d, %Y (%H:%M:%p)')" >> /root/report.txt<br> echo >> /root/report.txt<br>
<br>
</span>
<span style="font-family:courier;font-weight:bold;padding-left:4px;margin-left:15px;">
echo >> /root/report.txt<br> echo "Hostname: $(hostname)" >> /root/report.txt<br> echo >> /root/report.txt<br> echo >> /root/report.txt<br> echo "Kernel Version: $(uname -rv)" >> /root/report.txt<br> echo >> /root/report.txt<br>
</span>
13,420
edits