Open main menu

CDOT Wiki β

Changes

OPS235 Lab 1 - CentOS7

28 bytes added, 13:14, 1 April 2015
no edit summary
# 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;">report.bash</span></code></b> in your current directory.
# Enter the following text content into your text-editing session:
<br>
<span style="font-family:courier;font-weight:bold;padding-left:4px;margin-left:15px;">
#!/bin/bash # Forces script to run in the bash shell<br><br># Author: *** INSERT YOUR NAME ***<br># Date: *** CURRENT DATE ***<br>#<br># Purpose: To present sysadmin to create an software inventory<br># report containing selected elements<br>#<br># USAGE: ./report.bash<br><br>
<br>
# Author: *** INSERT YOUR NAME ***<br> # Date: *** CURRENT DATE ***<br> #<br> # Purpose: To present sysadmin to create an software inventory<br> # report containing selected elements<br> #<br> # USAGE: ./report.bash<br> <br> <br> if [ $USER != "root" ] # checks to see if user is root, and exits script if not<br> then<br>
echo "You must be logged in as root to run the command." >&2 # >&2 is a "redirection trick" to convert output as stderr<br>
echo "Either login as root or issue command \"sudo ./report1.bash\"" >&2<br> exit 1<br> fi<br>
</span>
# 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