Changes

Jump to: navigation, search

OPS235 Lab 6 - CentOS7 - HD2

126 bytes removed, 09:54, 12 October 2016
no edit summary
|}
=== Part 2: Network Connectivity & Network Service Troubleshooting Utilities===
{|width="40%" align="right" cellpadding="10"|- valign="top"|{{Admon/tip|Bash Shell Scripting Tips:|<br>'''<u>Arrays</u>'''<br><br><ul><li>Incredibly useful tool that works like a "storage container" of variables. '''Arrays have names like variables, but are numbered for quick storage and access of related elements'''. Indices are I.D. numbers for array access. The first index starts at <u>'''zero'''</u> instead of '''1'''.<br><br></li><li>Instead of using index numbers, you can use I.D. names: this is referred to as an '''Associative Array'''.<br><br></li><li>Examples:<br><br>''for((x&#61;0; x&lt;5; x++)) # Example of a regular array''<br>''do''<br>'' &nbsp; read -p "Enter item #$((x+1)): " item[xx]''<br>''done''<br>''for((y&#61;0; y&lt;5; y++))''<br>''do''<br> &nbsp; ''echo ${item[y]}''<br>''done''<br><br>''set a b c'' # Example of an "Associative Array"<br>''for x''<br>''do''<br> &nbsp; ''read -p "Enter item $x: " item["$x"]''<br> &nbsp; ''echo item[$x] is: ${item["$x"]}''<br>''done''<br><br></li></ul>'''<u>Working with Temporary Files</u>'''<br><br><ul><li>When creating temporary files, it is important NOT to store on a user's account (to avoid overwriting their existing files). Instead, temporary files can be created in the '''/tmp''' directory.<br><br></li><li>The $$ variable can be used as the filename extension which assigns the current PID of the shell script running to make the filename unique, and allow easy removal at the end of the shell script by deleting ALL files in the /tmp directory with the extension: .$$<br><br></li><li>Example:<br><br>''ls -lR &gt; /tmp/temp-file.$$''<br>''grep secret /tmp/temp-file.$$''<br>''rm /tmp.$$''<br></li></ul> }}|}
Troubleshooting network problems is an extremely important and frequent task for a Linux/Unix system administrator. Since network services (such as file-server, print-servers, web-servers, and email-servers) depend on network connectivity, as Linux/Unix sysadmin must be able to quickly and effectively pin-point sources of network problems in order to resolve them.
===Part 3: Using Arrays to Collect VM Network Information===
{|width="40%" align="right" cellpadding="10"|- valign="top"|{{Admon/tip|Bash Shell Scripting Tips:|<br>'''<u>Arrays</u>'''<br><br><ul><li>Incredibly useful tool that works like a "storage container" of variables. '''Arrays have names like variables, but are numbered for quick storage and access of related elements'''. Indices are I.D. numbers for array access. The first index starts at <u>'''zero'''</u> instead of '''1'''.<br><br></li><li>Instead of using index numbers, you can use I.D. names: this is referred to as an '''Associative Array'''.<br><br></li><li>Examples:<br><br>''for((x&#61;0; x&lt;5; x++)) # Example of a regular array''<br>''do''<br>'' &nbsp; read -p "Enter item #$((x+1)): " item[xx]''<br>''done''<br>''for((y&#61;0; y&lt;5; y++))''<br>''do''<br> &nbsp; ''echo ${item[y]}''<br>''done''<br><br>''set a b c'' # Example of an "Associative Array"<br>''for x''<br>''do''<br> &nbsp; ''read -p "Enter item $x: " item["$x"]''<br> &nbsp; ''echo item[$x] is: ${item["$x"]}''<br>''done''<br><br></li></ul>'''<u>Working with Temporary Files</u>'''<br><br><ul><li>When creating temporary files, it is important NOT to store on a user's account (to avoid overwriting their existing files). Instead, temporary files can be created in the '''/tmp''' directory.<br><br></li><li>The $$ variable can be used as the filename extension which assigns the current PID of the shell script running to make the filename unique, and allow easy removal at the end of the shell script by deleting ALL files in the /tmp directory with the extension: .$$<br><br></li><li>Example:<br><br>''ls -lR &gt; /tmp/temp-file.$$''<br>''grep secret /tmp/temp-file.$$''<br>''rm /tmp.$$''<br></li></ul> }}|}
We finish shell scripting by using arrays by reading and storing networking information for each VM (centos1, centos2, and centos3) to be stored in a report in your c7host machine. We will use the ssh command in order to grab the network information (one VM at a time), and store the network setup into an Associative array in our c7host machine.
# What is a port?
# What command will set your IP configuration to 192.168.55.22/255.255.255.0 ?
# What file contains the systems <code>iptables</code> rules?
# What is the difference between UDP and TCP?
# What port number is used for DHCP servers?
# What is the function of the file <code>/etc/services</code> ?
# What is the function of the file <code>/etc/hosts</code> ?
# What is the purpose of the file <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code> ?
13,420
edits

Navigation menu