Changes

Jump to: navigation, search

Tutorial5: Redirection

6,407 bytes removed, 21 January
INVESTIGATION 2: REDIRECTION USING PIPES
<br>
In this section, you will learn how to use the Linux Shell. Topics in the section include:..
:* Learn the '''Linux command structure''' (arguments and options)
:* Learn how to get '''help''' for Linux commands with manpages ('''man''' command).
:* Learn '''Basic Shell Editing'''
:* Learn how to perform '''online assignments'''.
:* Perform the '''first two sections of online assignment #1'''.<br><br>
===Part 1: Using the Linux Shell ===
 
The Bash shell in Matrix allows you to interact with your account by issuing commands.
 
Some Linux commands can be issued by entering the Linux command line without arguments (e.g. '''pwd''', '''date''', '''ls''', '''cal'''),<br>but some Linux commands can be issued with arguments (e.g. '''cal 2002''', '''cd /bin''', '''ls -la''' ).<br><br>
 
'''Linux Command Structure'''
 
<span style="color:blue;font-weight:bold">command argument1 argument2 ... </span>
 
An '''argument''' can be a '''pathname''', '''text''', '''option''', etc.
 
For example:
* The '''ls''' command displays a listing of filenames in the current directory
* The '''ls /bin''' command displays a listing of filenames in the /bin directory (as opposed to your current directory)
* The '''ls -l''' command displays a detailed listing of filenames in the current directory
* The '''ls -l /bin''' command displays a details listing of files in the /bin directory
 
 
'''Getting Help with Linux Commands'''
 
With the Linux OS containing over '''2500''' commands and utilities, it is good for a Linux user or sysadmin to learn about how to use commands “on-the-fly”.
 
The '''man''' command can provide information on how to use a command (i.e. '''usage''', '''arguments''', '''options''', '''examples''').<br>The commands are classified into sections or “volumes”.
'''Perform the Following Steps:'''
# Make certain that you are logged into your Matrix account.x<br><br># Issue the following command: <span style="color:blue;font-weight:bold">man man</span><br>How many volume numbers are contained in the man pages (like '''executable commands/programs''', '''games''', or '''system administrator commands''')?<br><br># Press the letter <span style="color:blue;font-weight:bold">q</span> to exit the man command.<br><br># Issue the Linux command to get help with the command: '''ls'''<br><br>'''NOTE:''' You can use the following short-cut keys within the man command to <br>help navigate throughout this utility to get help with the ls command (refer to table below):<br><br><table cellpadding="3"><tr><th style="border-bottom: 1px solid black;">Keyboard Shortcut</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td>'''ENTER'''</td><td>Move down one line</td></tr><tr><td>'''SPACEBAR'''</td><td>Move one screen down</td></tr><tr><td>'''&lt;ctrl&gt;&lt;f&gt;'''</td><td>Move one screen up</td></tr><tr><td>'''/pattern/'''</td><td>Search for Pattern</td></tr><tr><td>'''q'''</td><td>quit man utility</td></tr></table><br># Navigate through the man utility for the '''ls''' Linux command and note the option letters that correspond to the following:<br><ul><li>Include directory entries whose names begin with a dot</li><li>List in long format</li><li>Recursively list subdirectories encountered</li><li>Sort files by size</li><li>Display a slash (`/') immediately after each pathname that is a directory</li></ul><br># Exit the man utility for the ls command.<br><br># Issue the ls command for each of those option letters you wrote down to see how this command differs for each option.<br><br>NOTE: The '''man''' utility can be used with the '''-k''' option to help list Linux commands that match a text pattern that is contained within the help screen for a Linux command.<br><br># Although we will not be learning about pipeline commands (using the | character) until later, try issuing the following pipeline command: <span style="color:blue;font-weight:bold">man -k copy | grep 8</span><br>How this this pipeline command make it easier to obtain information regarding man command?<br><br># If you wish to change your password, you can change it by issuing the command: <span style="color:blue;font-weight:bold">passwd</span><br>What option for the passwd command can be used to change user info (such as name)?<br>'''Hint:''' use the manpages for the passwd command.<br><br>'''NOTE:''' You are NOT required to change your Matrix password for this tutorial. The Matrix server is "synched" with the my.senecacollege.ca server, so it is better to have your Matrix password changed at the same time that you change your myseneca password.<br><br> '''Command Line Editing''' Learning '''shortcut keys''' in any OS terminal will allow you to be more productive as a sysadmin. You will focus on learning a few common Bash Shell keyboard shortcut keysand learn where you can access online help for additional shortcuts (if required). '''Perform the Following Steps:'''
# Type the following Linux command, but DON’T press the ENTER key: <span style="color:blue;font-weight:bold">cd /bin</span><br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-a</span> key combination. What happens?<br><br>
# Press the <span style="color:blue;font-weight:bold">alt-F</span> key combination (ESC+F for Mac OSx). What happens?<br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-w</span> shortcut. What happens?<br><br>
# Type the following command: <span style="color:blue;font-weight:bold">ls</span><br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-e</span> key combination and press <span style="color:blue;font-weight:bold">ENTER</span><br><br>
# Press the up arrow key. What happens?<br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-u</span> key combination. What happens?<br><br>
# Press the <span style="color:blue;font-weight:bold">up arrow</span> key combination, and see what happens when you press <span style="color:blue;font-weight:bold">BACKSPACE</span> , <span style="color:blue;font-weight:bold">&lt;ctrl&gt;&lt;BACKSPACE&gt;</span> and <span style="color:blue;font-weight:bold">&lt;ctrl&gt;&lt;h&gt;</span>. Why is it important to know those series of key combinations?<br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-u</span> key combination to clear the line.<br><br>
# Press the <span style="color:blue;font-weight:bold">ctrl-l</span> key combination. What happens? What is the advantage of using this key combination then issuing the '''clear''' command?<br><br>
===Part 2: Performing Online Assignments ===

Navigation menu