Changes

Jump to: navigation, search

Tutorial2: Unix / Linux File Management

14,769 bytes added, 06:30, 2 June 2021
Part 2: Viewing Directory Contents / Copying & Moving Directories
=UNIX / LINUX FILE MANAGEMENMANAGEMENT CONCEPTS=
<br>
===Main Objectives of this Practice Tutorial===
:* xUnderstand the purpose of '''directories''' and '''directory pathnames'''.
:* xUse common '''Unix / Linux commands''' to perform '''directory management''' tasks.
:* xUse '''Text Editors''' to create and modify text files
:* xUse Common Unix / Linux commands to '''manage''' and '''manipulate''' text files. :* x :* x :* x<br><br>
===Tutorial Reference Material===
|- valign="top"
|colspan="21" style="font-size:16px;font-weight:bold;border-bottom: thin solid black;border-spacing:0px;"|Course Notes / Software<br>
|colspan="2" style="font-size:16px;font-weight:bold;border-bottom: thin solid black;border-spacing:0px;padding-left:15px;"|Linux Command/Shortcut Reference<br>
|- valign="top" style="padding-left:15px;"
|colspan="21" |Course NotesSlides:<ul><li>[https://ict.senecacollege.ca/~murray.saul/uli101/notes/Week02ULI101-Week2.pdf PDF] | [https://ict.senecacollege.ca/~murray.saul/uli101/notes/Week02ULI101-Week2.pptx PPTX]</li></ul>Tutorials:<ul><li>[http://www.cheat-sheets.org/saved-copy/Nano_Cheat_Sheet.pdf Nano Reference Sheet (PDF)]</li><li>[https://www.smashingmagazine.com/2010/05/vi-editor-linux-terminal-cheat-sheet-pdf Vi Reference Sheet(PDF)]</li><li>[http://czegel.com/seneca/uli101/lectures/Lecture2.html Les Czegel's Week 2 Notes (HTML)]</li></ul>  | style="padding-left:15px;" |Directory and File Management Commands*[ pwd]<br>*[ cd]<br>*[ ls]<br>*[ mkdir]<br>*[ rmdir]<br>*[ cp]<br>*[ mv]<br>*[ rm] , [rm -r]<br>
| style="padding-left:15px;"|Text File Management Commands
*[ cat]<br>
*[ more] , [ less]<br>
*[ touch]<br>
*[ file]<br>
*[ find]<br>
Text Editors
*[ vi]<br>
*[nano]<br>
| style="padding-left:15px;" |File Management
*[http://man7.org/linux/man-pages/man1/pwd.1.html pwd]<br>
*[http://man7.org/linux/man-pages/man1/cd.1p.html cd]<br>
*[http://man7.org/linux/man-pages/man1/ls.1p.html ls]<br>
*[https://www.systutorials.com/docs/linux/man/1-tree/ tree]<br>
*[http://man7.org/linux/man-pages/man1/mkdir.1.html mkdir]<br>
*[http://man7.org/linux/man-pages/man1/rmdir.1.html rmdir]<br>
*[http://man7.org/linux/man-pages/man1/cp.1.html cp]<br>
*[http://man7.org/linux/man-pages/man1/mv.1p.html mv]<br>
*[http://man7.org/linux/man-pages/man1/rm.1.html rm] , [http://man7.org/linux/man-pages/man1/rm.1.html rm -r]<br>
| style="padding-left:15px;"|Text Editors /<br>File Content
*[http://man7.org/linux/man-pages/man1/vi.1p.html vi] , *[https://linux.die.net/man/1/nano nano]<br>
*[http://man7.org/linux/man-pages/man1/cat.1.html cat]<br>
*[http://man7.org/linux/man-pages/man1/more.1.html more] , [http://man7.org/linux/man-pages/man1/less.1.html less]<br>
* [http://man7.org/linux/man-pages/man1/head.1.html head] , [http://man7.org/linux/man-pages/man1/tail.1.html tail]
*[http://man7.org/linux/man-pages/man1/touch.1.html touch]<br>
*[http://man7.org/linux/man-pages/man1/file.1.html file]<br>
*[http://man7.org/linux/man-pages/man1/find.1.html find]<br>
*[http://man7.org/linux/man-pages/man1/diff.1.html diff]<br>
*[http://man7.org/linux/man-pages/man1/sort.1.html sort]<br>
*[http://man7.org/linux/man-pages/man1/uniq.1.html uniq]<br>
*[http://linuxcommand.org/lc3_man_pages/grep1.html grep]<br>
|colspan="1" style="padding-left:15px;" width="30%"|Brauer Instructional Videos:<ul><li>[https://www.youtube.com/watch?v=BEH6i_BKOBoUfAFAipked0&list=PLU1b1f-2Oe90TuYfifnWulINjMv_Wr16N&index=2&t=0s Connecting to Matrix Using SSH Client, Starting the Assignments, and Running UBUNTU Within Windows 10]3 Basic File Actions<br><br></li><li>[https://www.youtube.com/watch?v=3wZmZOKLllk&list=PLU1b1f(touch, ls -l, cp, cp -2Oe90TuYfifnWulINjMv_Wr16N&index=2 Linux File Systemr, mv, mkdir, Basic Navigation (lsmkdir -p, cdrm, pwdrmdir, treerm -r), Absolute and Relative Paths]</li></ul>
|}
===Unix / Linux File Management Concepts==KEY CONCEPTS=
While attending Seneca College, you will be using many different computer systems to perform various operations.Some of these servers include:===Unix / Linux Directories===
{[[Image:directory-structure-1.png|width="100%" cellspacing=thumb|right|350px|In Unix / Linux (as opposed to MS Windows), there are no drive letters (such as '''C:''', or '''D:''').<br><br> All files and directories appear under a single ancestor directory called "0the '''root''' directory".]]To better '''organize''' files (eg. text, images, documents, spreadsheets, programs) within your Matrix account, they should be stored in '''directories'''. To further organize <u>many</u> files, directories<br> may contain '''sub-directories'''.
|-The Unix/Linux file system is '''hierarchical''', like other operating systems such as '''Windows''', '''Mac OSX''', etc.| style="padding-leftIn Unix / Linux (as opposed to MS Windows), there are no drive letters (such as '''C:0px;width''', or '''D:10%''').<br>All files and directories appear under a single ancestor directory called the " |'''my.senecacollege.caroot directory'''| style="padding-left:15px;width:65%" |Learning Content Management System (Student Grades / Notes / Online Quizzes).
|-| style="padding-left:0px;width:10%" |Learning how to issue Linux commands for '''ictnavigating''' and '''manipulating''' directory and files within the the Linux filesystem are '''essential skills''' for Linux users and Linux system administrators (i.senecacollegee.ca''sysadmins''| style="padding-left:15px;width:65%" |Main ICT Webserver).
|-| style=In the Linux (Unix) OS, the "'''root directory'''" / is the starting directory, and other "''child directories''"padding-left:0px;width:10%, " |'''wikigrandchild directories'''", etc.cdotcan be created as required.senecacollegeThe hierarchical structure resembles an "''upside-down tree''".caThere is actually a command called '''| style=tree''' that displays a "padding-left:15px;width:65%'''directory tree diagram'''" |Course WIKIs for Seneca College Students!<br><br>
=== Directory Pathnames ===[[Image:path-name.png|-thumb|right| style="padding-left:0px;width:10%" 180px|A pathname points to a file system location by '''following the directory tree hierarchy'''matrix.senecacollege]]<i>A '''pathname''' is used to specify a '''route to a file''' within the file system.ca<br><br>A pathname '''points''' to a file system location by '''following the directory tree hierarchy''' expressed in a string of characters in which path components, separated by a delimiting character, represent each directory. The '''delimiting character''' is most commonly the slash ("'''/'''| style="padding-left).</i> Reference:15px;widthhttps:65%" |Linux Account for Student Practice and Assignment submission//en.wikipedia.org/wiki/Path_(computing)
|}The following table displays and defines '''commonly used directories'''<br>(listed by directory pathname) for for ALL Unix / Linux Filesystems:<br>
<br><br>
[[Image:clidirectory-promptstructure-2.png|thumb|right|120px500px|A '''shellCommon directory pathnames''' is an interface <br>for for ALL Unix / interpreter to allow a user to communicate with the Linux computer systemFilesystems. ]]Although you need <table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Directory Pathname</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td>'''/'''</td><td>Root directory (ancestor to study concepts throughout this course, you will also need to learn all directories)</td></tr><tr><td>'''/home'''</td><td>Used to store users’ home directories</td></tr><tr><td>'''/home/username'''</td><td>A '''<u>specific</u>''' User's Home Directory</td></tr><tr><td>'''/bin'''</td><td>Common system binaries (commands) </td></tr><tr><td>'''/usr/bin'''issue and memorize simple as well as more advanced Linux </td><td>Common utilities (commands) for users. </td></tr><tr><td>'''/usr/sbin'''</td><td>Common utilities for system administration </td></tr><tr><td>'''/etc'''</td><td>System administration files (eg. This requires that you practice issuing Linux commands on a frequent basis to become more comfortable when working the Unix passwd)</td></tr><tr><td>'''/var'''</td><td>Dynamic files (log and mail files)</td></tr><tr><td>'''/tmp , /var/tmp'''Linux command-line environments</td><td>Temporary files for programs</td></tr><tr><td>'''/dev'''</td><td>Device driver files (terminals, printers, etc.)</td></tr></table><br>
Just like with other operating systems like MS Windows, it is important to learn how to '''open a command prompt in order to issue commands to perform common tasks'''. In Unix/Linux, a '''shell''' is simply an interface / interpreter to allow a user to communicate with the Linux computer system (server). Linux shells have evolved (improved) over a period of time. You will be using the '''Bash Shell''' which is considered to be user-friendly. By understanding how to issue Linux commands, you can create a file consisting of Linux commands and programming techniques called a '''shell script''' (learned later in this course) to automate tasks to make you a more productive user and administrator.
===Layout of the When you log into your Matrix Server===[[Image:matrix-layout.png|thumb|right|350px|The Matrix server consists of several Virtual Computers all connected together account, you are automatically directed to form a your '''clusterhome'''directory. A cluster <br>This directory is a '''cost effective''' alternative where the user can store files, and create subdirectories to larger serversorganize their files. ]]
The Matrix server consists of '''several Virtual Computers connected together''' to form a '''cluster'''. A cluster is a '''cost effective''' alternative to buying larger servers.=INVESTIGATION 1: CREATING &amp; MANAGING DIRECTORIES=
All registered students <span style="color:red;">'''ATTENTION''': Depending on your ULI101 instructor, you may be required to complete this tutorial for '''marks''' in this course should have an account on the Matrix server.You will be using <br>Please refer to your instructor's course notes and lecture notes regarding evaluation for this course.<br><br>The due date for successfully completing this tutorial (i.e. '''tutorial 2''') is by '''Friday by midnight''' next week (i.e. '''Week 3''').<br>If your instructor has NOT assigned marks for completing this account tutorial, you can perform it for the following reasons:'''practice'''.</span><br><br>
:* Issuing In this investigation, you will learn how to '''Linux commandscreate''':* Becoming productive using the Linux , '''command promptnavigate''' (, '''shelllist directory contents'''):* Performing and '''Linux Practice Tutorialsremove''':* Performing '''Linux Assignments''' ('''3'''):* Practice Issuing '''Linux Command Review Questions''' directories in your Matrix account.
In the next investigation, you will learn how to '''connect''' to and '''login''' to your Matrix server account both at a '''college lab workstation''' and from a remote computer such as your '''home computer''' or your '''laptop computer'''.<br><br>
=INVESTIGATION 1: ACCESSING YOUR MATRIX LINUX ACCOUNT='''Directory File Naming Rules'''
<br>In this section, Before you will learn how to access your Matrix Linux account by two different methods:create directories, it is important to understand what represents an appropriate '''directory filename'''.
:* From a <u>workstation</u> ''Listed below are some common 'within''file-naming rules' a '''Seneca College lab''':* From your <u>own</u> computer '''within''' or '''outside''' '''Seneca College''' <br><br>
===Part 1: Access your Matrix Account from a Seneca College Lab ===[[Image:apps-anywhere-main-window.png|thumb|right|250px|* Unix/Linux characters are '''MyAppscase sensitive''' . It is recommended to be consistent (e.g. use all lowercase letters)* Adopt a '''AppsAnywhereconsistent directory naming scheme'''(this will help you to navigate within your directory structure) Main Window ]]You will learn how to connect to * Make your Matrix Linux account from directory names '''meaningful'''* '''Avoid non-alphanumeric characters''', as they may have a workstation in special meaning to the system that will make your computer labs at Seneca collegework more difficult when changing to directories, etc.* '''Avoid using spaces''' for directory names (consider periods, hyphens, and underscores instead)
This would be useful if you do not have a notebook computer and are required to use one of the workstations available in your Seneca computer lab.
'''MyApps''' ('''AppsAnywhere''') is an application streaming service that lets you install software on any Seneca PC on demand. Any software application on the MyApps menu can be used on computers in classrooms, labs, and the Computing Commons.===Part 1: Creating Directories ===
Reference[[Image: https://insidedirectory-structure-3.png|thumb|right|350px|'''Tree Diagram''' of Directory Structure to Create in your '''Home''' Directory (displayed in blue text).senecacollege]]Creating subdirectories within your home directory makes it more '''efficient''' to<br>save and access files on your Linux server.ca/its/software/myapps/
A comparison would be rooms in a '''house'''. If there were no rooms, just one large room in a 3,000 square foot house, it would be "messy" and difficult to locate items. Each '''room''' in a house is used to for a<br>'''specific purpose''' to be more productive to perform a task such as a kitchen, bedroom, bathroom, etc.
You will now use MyApps on your Windows workstation in your Seneca lab room to launch an application<br>to allow you to connect and login to your Matrix server account.[[Image:apps-anywhere.png|thumb|right|250px|Several SSH applications will appear. We will use be creating the application called following '''SSH Clientdirectory structure''' for this practice tutorialwithin your home directory<br>(refer to diagram on the right side). ]]
'''Perform the Following Steps:'''
# Start your workstation in your lab and login to your Seneca Windows account.<br><br># Make certain that the '''MyApps''' window is open. This window should have opened shortly after you logged into your Windows workstation. If the application windows is not open, click on the '''MyApps''' icon on the desktop to launch).<br><br>[[Image:ssh-main-window.png|thumb|right|150px|SSH Client Application Window ]]# Click on the '''Search Apps''' area located in the top right corner of the MyApps window and type the word: <span style="color:blue;font-weight:bold">ssh</span><br><br># Several SSH applications will appear. <br><br>'''NOTE:''' All For several of these applications allow you to connect to your Matrix account.<br>We will use the application called '''SSH Secure Shell Client''' for this practice tutorial.<br><br># Launch the '''SSH Secure Shell Client''' application icon to launch this program.<br><br>[[Image:quick-connect-window.png|thumb|right|150px|Quick Connect Dialog Box ]]'''NOTE:''' Prior to launching the applicationfollowing commands, you can add this to your '''favourites''' which will make it faster<br>to access this application in the future.<br><br> # The main SSH Client window will appear. Click on the ''be using 'Quick Connect''' button.<br><bru>'''NOTE:''' The Connect dialog box allows the user to specify the '''server name''' and your '''account name'''<br>to allow you to connect to the server.<br><br># Click on the textbox labelled Hostnanme and enter the text: <span style="color:blue;font-weight:bold">matrix</span><br><br>'''NOTE:''' You can use the hostname '''matrix''' since you are located <u>inside</u> Senecausername''s network.<br>If you where located <u>outside</u> Seneca's network, then you would need to enter replace the full domain nametext: "'''matrix.senecac.on.ca'''<br><br>[[Image:shareyour-publicseneca-key.png|thumb|right|150px|Dialog Box to Share Public Key on Remote Server ]]# When connecting securely for the '''first timeid''', a dialog box will appear to share a "public key" with your Matrix account in order to make your interaction between your workstation and the remote Linux server secure within the network (i.e. encrypted to prevent unauthorized access by other users)<br><br>'''FYI:''' To make communications over a network secure, a computer generates '''two keys''': a '''private key''' that is kept on the computer, and a '''public key''', which can be shared with other computers. Transmissions from your computer uses the private key to encrypt (scramble) transmission to the remote computer, which in turn, uses the public key to decrypt (unscramble) the transmission. Likewise, the remote computer uses the public key to encrypt (scramble) transmissions and your computer uses the private key to decrypt (unscramble) those transmissions.<br><br>[[Image:ssh-password-prompt.png|thumb|right|150px|Password Dialog Box ]]# Click the '''Yes''' button to share your public keypathname.<br><br># NextFor example, a dialog box will appear prompting you for your Matrix account password in order to gain entry to your Matrix account. Your Matrix password is identical to if your Seneca password. As you type the password, the text will be blocked-out or hidden to prevent others from viewing the screen to obtain your password[[Image:ssh-authentication-response.png|thumb|right|150px|Authentication Response Dialog Box ]]<br><br># Enter your password and click user ID was '''OK''' or press '''ENTERmkhan'''then you would display<br><br>[[Image:ssh-login-error.png|thumb|right|150px|SSH Login Error ]]# Click '''OK''' or press '''ENTER''' at the pathname '''Authentication Response''' dialog box.<br><br>'''NOTE:''' If you encounter an '''error message''', this can occur for several reasons:<ol><li>You mis-spelled the '''name of the server'''</li><li>You mis-spelled your Matrix '''username''' (same username that you connect to my.senecacollege.ca)<home/li><li>You have '''CAPS LOCK''' on by mistake (your username should be '''lowercase''' only).</li><li>You mis-spelled your seneca-id''as: 'password''' (same password that you connect to my.senecacollege.ca)</li><home/ol><br>If you encountered an error logging in, issue the same steps to connect to your Matrix account,<br>but carefully check your server name, username and your password. If you continue to experience the same problems,<br>you can go to the computer help desk in the learning commons to get help.<br><br>[[Image:ssh-shell-window.png|thumb|right|150px|Matrix Shell Command Line Interface ]]#If you entered your password correctly, the main SSH Linux shell should appear where you enter Linux commands.<br><br>The '''Matrix''' server has been configured to allow users to mkhan'''only interact with the Linux OS by issuing commands'''. There are various reasons for this, but the main 2 reasons are to '''force students to learn how to issue Linux commands''' as well as '''limitations to remote access to a graphical Linux server''' due to large number of users (students).<br><br>Later in the course, your instructor may demonstrate other ways of accessing '''graphical versions of Linux''', and how to launch a shell terminal.<br><br>[[Image:ssh-settings-window.png|thumb|right|150px|SSH Settings Dialog Box ]]
# '''Login''' to your matrix account (you should know how to do this from performing [https://wiki.cdot.senecacollege.ca/wiki/Tutorial_1:_Using_Your_Matrix_Server_Account#INVESTIGATION_1:_ACCESSING_YOUR_MATRIX_LINUX_ACCOUNT Tutorial 1 INVESTIGATION 1]]).<br><br># Issue a command to '''confirm''' that you are located in your home directory<br>(you should know how to do this from performing [[https://wiki.cdot.senecacollege.ca/wiki/Tutorial_1:_Using_Your_Matrix_Server_Account#INVESTIGATION_2:_USING_THE_LINUX_SHELL_.2F_ONLINE_ASSIGNMENTS Tutorial 1 INVESTIGATION 2]]<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">mkdir /home/your-seneca-id/uli101xx</span><br>(remember: use <u>your</u> Seneca username instead of "your-seneca-id")<br><br>'''NOTE:''' You should always confirm that you have created a directory.<br>This can be done by issuing the '''configurels''' command.<br><br>[[Image:directory-structure-4.png|thumb|right|350px|'''Creating''' and '''Confirming''' the SSH application Creation of a Directory.]]# Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls /home/your-seneca-id/uli101xx</span><br><br>There are no contents that are contained in this newly-created directory; therefore, no contents appear. A useful option '''-d''' can be used to adjust elements such confirm that the actual <u>directory</u> has been created as opposed to viewing the contents of the directory.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -d /home/your-seneca-id/uli101xx</span><br><br>You should now see just the directory listed. You can also combine the '''window size-d''' and '''text -l''' options to provide more detail regarding the newly-created directory.<br><br># Issue the following Linux command: <span style="color:blue;font type-weight:bold;font-family:courier;">ls -d -l /home/your-seneca-id/uli101xx</span><br><br>How can you confirm from the output of this command that the file uli101xx is a directory?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -ld /home/your-seneca-id/uli101xx</span><br><br>Is the output from this command the same was the output from the previous command?<br>If so, what does this say about how to use multiple options for Linux commands?<br><br># Issue the following Linux command to create the '''acp100xx''' and text '''xyz100xx''' directories:<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir /home/your-seneca-id/acp100xx /home/your-seneca-id/xyz100xx</span><br><br>'''NOTE:''' You can create multiple directories by issuing the '''mkdir''' command with <u>multiple arguments</u>.<br><br># Issue the following Linux command to confirm that those directories have been created:<br><span style="color:blue;font size-weight:bold;font-family:courier;">ls -ld /home/your-seneca-id/acp100xx /home/your-seneca-id/xyz100xx</span><br><br>'''Using a FULL pathname starting from the root directory (i. e. /) requires is a LOT of typing!.<br>Since we are already located in our home directory, we don't have to start from<br>the root directory called a "relative" pathname.'''<br><br># We will now create the subdirectories that are contained in the '''uli101xx''' directory.<br>Issue the following Linux command to move to the '''uli101xx''' directory using a '''relative''' pathname:<br><span style="color:blue;font-weight:bold;font-family:courier;">cd uli101xx</span><br><br># Issue a Linux command to confirm that your current location is in the ''uli101xx'' directory.<br>You should know how to issue this command from a previous tutorial.<br><br># Issue the following Linux command to create the directories called '''notes''', '''tutorials''' and '''samples''':<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir notes tutorials samples</span><br><br># Issue a Linux command to confirm that those directories have been created<br>(you should already know how to do this).<br><br>There are better ways to create the same directory structure without using the '''cd''' command.<br><br>Issuing the '''cd''' command '''<u>prior</u>''' to issuing other commands indicates to others that you are a novice or "'''newbie'''".<br>You can actually '''lose marks''' on quizzes or tests if you issue multiple Linux commands to performed tasks that can be showing performed<br>using a single Linux command with '''pathnames'''.<br><br># Issue the following Linux command to return to your home directory: <span style="color:blue;font-weight:bold;font-family:courier;">cd</span><br><br># Issue a Linux command to confirm that you are now located in your home directory.<br><br>Although we will teach you how to configure your SSH Secure Shell Client'''remove''' directories and their contents in another investigation, but <br>let's remove the other applications can allow created directory structure' and '''recreate''' the same directory structure<br>using just <u>one</u> command using pathnames.<br><br># Issue the following Linux command to remove all of the directories that you have created:<br><span style="color:blue;font-weight:bold;font-family:courier;">rm -r uli101xx acp100xx xyz100xx</span><br><br># Issue a Linux command to confirm that the '''uli101xx''', '''acp100xx''' and '''xyz100xx''' that been removed.<br><br># Issue the following single Linux command to configure create the entire directory structure:<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir -p uli101xx/notes uli101xx/tutorials uli101xx/samples acp100xx xyz100xx</span><br><br>'''NOTE:''' The '''-p''' option allows "parent" directories to be automatically created first to then create their settingssubdirectories.<br><br># Issue the following Linux command to confirm that all of the directories have been created:<br><span style="color:blue;font-weight:bold;font-family:courier;">ls -ld uli101xx/ uli101xx/notes uli101xx/tutorials uli101xx/samples acp100xx xyz100xx</span><br><br>'''Running a Shell Script to Check your Work'''
'''Perform Although you are being asked to create the Following Stepsdirectory structure, you might have made some mistakes:'''<br>For Example:<br> * Forgetting to create a directory.* Making syntax errors (eg. spelling or mixing up character case)* Not creating subdirectories within specified directories.
# Click on the '''Edit''' menu item, and then select '''Settings''' in the Edit drop-down menu.<br><br>
# To change the size of your shell window, under the ''Global Settings'' section, click '''Appearance'''<br><br>
# Change the ''window size'' both horizontal and vertical to larger values.<br><br>
# To change the font size, under the ''Global Settings'' section, click '''Font'''<br><br>
# Select a larger ''font size'' and click '''OK'''<br><br>
# You now should notice that you have customized your SSH shell terminal. You can use the settings screen to also change your background and text colours if you are interested in doing so.<br><br>
# To exit your Matrix session, type the following command and press ENTER: <span style="color:blue;font-weight:bold">exit</span><br><br>'''NOTE:''' You should notice that the colour of the text changes slightly when disconnected and you are unable to issue Linux commands from that window.<br><br>
# After you have disconnected from your account, close the SSH Secure Shell Client application window.<br><br>
# It is recommended to repeat these steps with connecting to your Matrix account from a Seneca lab workstation until you become comfortable with the process.<br><br>
In the next section<table align="right"><tr valign="top"><td>[[Image:script-check-1.png|thumb|right|250px|If all all check pass, then user performed task correctly and can continue.]]</td><td>[[Image:script-check-2.png|thumb|right|450px|If there is a warning, you will learn how then feedback is provided to connect user to your Matrix server account from a different computercorrect and re-run checking script.]]</td><br/table>(To check for example: mistakes, a '''shell script''' has been created to check your laptop computer at Seneca College or work. If the checking shell script detects an '''error''', then it will provide feedback and offer constructive feedback on how to fix that problem so you can re-run the checking shell scripts until your computer at home)work is correct.<br><br>
===Part 2: Access your Matrix Account From your own computer within or outside the Seneca College Network ===
You will learn how to connect to your Matrix Linux account from your own computer whether it be a '''laptopPerform the Following Steps:''' computer or your '''home computer'''.
This would be useful if you want to access # Make certain that your current directory is '''your Matrix home directory'''.<br><br># Issue the following Linux account on your own computer command to practice Linux commands or perform your assignment outside of run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">~uli101/week2-check-1</span><br><br># If you encounter errors, then view the scheduled classfeedback to make corrections, and then re-timerun the checking script. If you receive a congratulation message that there are no errors, then proceed to the next part.<br>
We will be learning to use a different SSH application called "'''Putty'''". In this way, you will be exposed to a few SSH applications to help you decide which SSH application you are most comfortable.===Part 2: Viewing Directory Contents / Copying & Moving Directories===
:'''Perform the following steps:'''# Click on the following link to download the Putty executable file:<br>http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe[[Image:putty-application-icon.png|thumb|right|70px|Putty Application Icon ]]<br><br>'''NOTE:''' If you are interested in downloading and installing other SSH applications (including the<br>SSH Secure Shell Client application used in part 1), refer to week 1 links in the ULI101 Weekly Schedule.<br><br># The putty executable file does <u>not</u> install the Putty program: Instead, run this program, by opening a file manager, moving to the '''Downloads''' directory and double-clicking on the '''putty.exe''' file.<br><br>[[Image:putty-configuration-window.png|thumb|right|250px|Putty Configuration Window ]]# The Putty configuration window will appear.<br><br>You can '''configure''' the SSH application to adjust elements such as the '''window size''' and '''text font type''' and text '''font size'''. We will be showing Now that you have learned how to configure efficiently create your SSH Secure Shell Clientdirectory structure, but the other applications can allow you to configure their settings.<br><br># To change the size of your shell window, click '''Window'''<br><br># Change the '''rows''' and '''columns''' to larger values.<br><br># To change the font size, under the ''Window'' section, click '''Appearance'''<br><br># In the left window under '''Font Settings''', click the '''Change''' button.<br><br># Select a larger ''font size'' and click '''Apply'''<br><br># You will return now learn how to the Putty Configuration window.<br><br># To login to your Matrix issue Linux account, click on '''Sessions'''<br><br># In the Host Name sectionand enter the text: <span style="color:blue;font-weight:bold">matrix</span><br><br>'''NOTE:''' You can use the hostname '''matrix''' since you are located <u>inside</u> Seneca's network.commands<br>If you where located <u>outside</u> Seneca's network, then you would need to enter the full domain name: '''matrix.senecac.on.caview directory contents'''<br><br>[[Image:putty-login-window.png|thumb|right|350px|Login to Matrix Server ]]# Click on the as well as '''Opencopy''' button and the Putty session window should appear.<br><br># Enter your '''usernamemove''' when prompteddirectories.<br><br># Enter your '''password''' when prompted.<br><br>[[Image:putty-public-key.png|thumb|right|250px|Dialog Box to Share Public Key on Remote Server ]]# When connecting securely from the putty application for the '''first time''', a dialog box will appear to share a "public key" with your Matrix account in order to make your interaction between your workstation and the remote Linux server secure within the network (i.e. encrypted to prevent unauthorized access by other users)<br><br># Click the '''Yes''' button to share your public key.<br><br>'''NOTE:''' If you encounter an '''error message''', this can occur for several reasons:<ol><li>You mis-spelled the '''name of the server'''</li><li>You mis-spelled your Matrix '''username''' (same username that you connect to my.senecacollege.ca)</li><li>You have '''CAPS LOCK''' on by mistake (your username should be '''lowercase''' only).</li><li>You mis-spelled your '''password''' (same password that you connect to my.senecacollege.ca)</li></ol><br>If you encountered an error logging in, issue the same steps to connect to your Matrix account,<br>but carefully check your server name, username and your password. If you continue to experience the same problems,<br>you can go to the computer help desk in the learning commons to get help.<br><br>[[Image:putty-shell-window.png|thumb|right|250px|Putty Shell Command Line Interface ]]# If you followed the login sequence correctly, the Putty Shell window will appear where you can issue Linux commands.<br><br># To exit your Matrix session, type the following command and press ENTER: <span style="color:blue;font-weight:bold">exit</span><br><br>'''NOTE:''' You should notice that the Putty application window will disappear.<br><br># It is recommended to repeat these steps with connecting to your Matrix account from a Seneca lab workstation until you become comfortable with the process.<br><br>
In the next investigation, you will learn how to issue Linux commands and how to setup and perform the first two sections of the online ULI101 assignment #1.<br><br>
'''Perform the Following Steps:'''<table align="right"><tr valign="top"><td>[[Image:directory-structure-5.png|thumb|right|250px|Output of the '''tree''' command to display directory structure.]]</td><td>[[Image:directory-structure-6.png|thumb|right|250px|Output of the '''ls -R''' command to display directory structure.]]</td></table># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">tree</span><br><br>'''NOTE:''' You should see the directory structure that you created in the previous investigation. You can also issue the '''tree''' command using a directory pathname to display the directory structure for a specific scope.<br><br>You can also use the '''-R''' option for the '''ls''' command to display all directories and subdirectories for a specified directory path (referred to as a '''recursive directory listing''').<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -lR </span><br><br>What directories do you see?<br><br># Issue the following Linux command: <span style=INVESTIGATION 2"color:blue;font-weight:bold;font-family:courier;">ls -lR uli101xxx</span><br><br>Note the differences between both of these commands (i.e. using and <u>not</u> using a pathname).<br><br>You can copy and move entire directories (and their contents) to other directories.<br><br><table align="right"><tr valign="top"><td>[[Image:directory-structure-7.png|thumb|right|250px|Output of the '''tree''' command to confirm copy of '''uli101xx''' directory (and contents) to the '''xyz100xx''' directory.]]</td><td>[[Image:directory-structure-8.png|thumb|right|300px|Output of the '''tree''' command to confirm movement of '''acp100 directory''' directory (and contents) to the '''xyz100xx''' diredtory.]]</td></tr></table># Issue the following Linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">cp -R uli101xx xyz100xx</span><br><br>#Issue the following Linux command to display the directory structure of your home directory to confirm you copied the uli101xx directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">tree </span><br><br><br><br><br><br># Issue the following Linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">mv acp100xx xyz100xx/uli101xx/tutorials</span><br><br>#Issue the following Linux command to display the directory structure of your home directory to confirm you moved the acp100xx directory:<br><span style="color:blue;font-weight:bold;font-family: USING THE LINUX SHELL courier;">tree </ ONLINE ASSIGNMENTS span><br><br>Let's run a checking script to see if you moved and copied the directories correctly.<br><br># Make certain that your current directory is '''your home directory'''.<br><br># Issue the following Linux command run checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">~uli101/week2-check-2</span><br><br># If you encounter errors. make corrections and re-run the checking script until you receive a congratulations message, and proceed to the next investigation.<br><br>
<br>In this section, you will learn how to use the Linux Shell. Topics in the section include===Part 3:Removing Directories ===
:* Learn the '''Linux command structure''' (arguments and options):* Learn In this investigation, we will 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 #1safely remove'''directories and their contents.<br><br>
===Part 1: Using the Linux Shell ===
The Bash shell in Matrix allows you to interact with your account by issuing commands.'''Perform the Following Steps:'''
Some # Confirm that you are located in your home directory.<br><br>The '''rmdir''' command is used to remove <u>empty</u> directories.<br><br># Issue the following Linux commands can be issued by entering command to remove the empty directory called '''tutorials''': <span style="color:blue;font-weight:bold;font-family:courier;">rmdir uli101xx/tutorials</span><br><br># Issue a command to confirm that you removed the '''tutorials''' directory.<br><br># Issue the following Linux command line without arguments (e.g. to remove the empty directory called '''uli101xx''': <span style="color:blue;font-weight:bold;font-family:courier;">rmdir uli101xx</span><br><br>NOTE: You should get an '''pwderror message''', since the '''uli101xx''' directory is '''dateNOT'''empty.<br><br>To remove non-empty directories, you can use the '''lsrm -r''', command.<br>The '''cal-r''')option stands for recursive,which can travel down the directory paths and their contents.<br><br>but some # Issue the following Linux commands can be issued with arguments command to remove the '''uli101xx''' directory and its contents: <span style="color:blue;font-weight:bold;font-family:courier;">rm -r uli101xx</span><br><br># Issue the '''tree''' command to confirm that the uli101xx directory (e.gcontained in your home directory) and its contents have been removed. <br><br>'''cal 2002NOTE:'''To <u>safely</u> remove non-empty directories, you can add the '''-i'''cd option which will prompt the user if they wish to remove contents as it your travel recursively down a directory to remove directories and their contents.<br><br># Issue the following Linux command (entering "y" when prompted): <span style="color:blue;font-weight:bold;font-family:courier;">rm -ri xyz100xx</binspan><br><br>'''NOTE:'''You should have removed all directories that you have created.<br><br>Let', s run a checking script to confirm that you have correctly removed all of those directories.<br><br># Issue the '''ls -latree''' )command to confirm that all of those recently created directories have been removed.<br><br># Issue the following Linux command to run a checking script to confirm removal of those directories:<br><span style="color:blue;font-weight:bold;font-family:courier;">~uli101/week2-check-3</span><br><br># If you encounter errors, make corrections and re-run the checking script until you receive a congratulations message, and proceed to the next INVESTIGATION.<br><br>
'''Linux Command Structure'''=INVESTIGATION 2: MANAGING TEXT FILES=
<span styletable align="colorright"><tr valign="top"><td>[[Image:blue;fontnano-weighttext-editor-1.png|thumb|right|250px|The '''Nano Text Editor''' is Easy to Operate for Novice Users.]]</td><td>[[Image:bold">command argument1 argument2 .vi-text-editor-1.png|thumb|right|300px|The '''vi Text Editor''', although taking longer to master, has outstanding features and allow the user to be more productive with editing text files. ]]</td></tr></spantable><br>Since IT students will be working in the Unix / Linux command line environment, it is useful to learn a least two common command-line '''text editors'''.
An Although '''argumentprogramming students''' can be a use '''graphical IDE'pathnames'''to code and compile programs, they can '''create source code'''using a texteditor and '''compile their source code''', in the '''optionMatrix''', etcserver to generate executable programs (without having to transfer them for compilation or execution).
For example:* The '''lsNetworking and Tech Support students''' command displays can use a listing of filenames in the current directory* The text editor to '''ls /binedit configuration files''' command displays a listing of filenames . These students in upper grades will become familiar with the /bin directory (as opposed process of installing, configuring, and running network services and text editors are an important tools<br>to your current directory)* The '''ls -lhelp setup but also "tweak" or make ''' command displays a detailed listing of filenames periodic changes in the current directory* The 'networking services configuration''ls -l /bin''' command displays a details listing of files in the /bin directory.
The two most readily-available command line text editors in Linux are '''Nano''' and '''vi'''.<br>The Nano text editor would seem like an easier-to-use text editor, but vi (although taking longer to learn)<br>has outstanding features and allow the user to be more productive with editing text files.
<br><br>
'''Getting Help with Linux Commands'''===Part 1: Creating Text Files Using The Nano Text Editor===
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”.
You will now learn basic editing skills using the '''Nano''' text editor including '''creating''', '''editing''', and '''saving''' text files.
<br><br>
'''Perform the Following Steps:'''
# Make certain that you are logged into located in your Matrix accounthome directory.<br><br>[[Image:directory-structure-10.png|right|150px|thumb|]]# '''Create''' the following directory structure (displayed on the right side) by issuing a '''single Linux command'''<br>(You should know how to do this from the previous INVESTIGATION).<br><br># Issue a Linux command to check that you correctly created those directories.<br><br># Issue the following Linux commandto edit a text file called '''mytext.txt''' in the '''linux/practice''' directory: <br><span style="color:blue;font-weight:bold;font-family:courier;">man mannano textedit/practice/mytext.txt</span><br>How many volume numbers are contained in the man pages (like <br>'''executable commands/programsNOTE:''', When using the '''gamesNano'''text editor, or you are placed in '''system administrator commandsINPUT''')?mode, so you can enter text immediately.<br><br>[[Image:nano-text-editor-2.png|right|400px|thumb|Enter the following text that appears in this diagram.]]# Press Enter the lines shown in the other diagram of the letter <span style="color:blue;font-weight:bold">q</span> to exit nano text editor on the man commandright side.<br><br># Issue the Linux command to get help with the command: '''lsNOTE:'''Refer to the table below for a list of<br><br>common '''NOTE:Nano''' 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)navigation &amp; editing commands:<br><br><table cellpadding="35"><tr><th style="border-bottom: 1px solid black;">Keyboard ShortcutKey(s)</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><trvalign="top"><tdstyle="font-family:courier">'''&lt;ctrl&gt;&lt;SPACEBAR&gt;''',<br>'''ENTER&lt;esc&gt;&lt;6&gt;'''</td><td>Move down forward/backward one lineword</td></tr><trvalign="top"><tdstyle="font-family:courier">'''&lt;ctrl&gt;&lt;a&gt;''',<br>'''SPACEBAR&lt;ctrl&gt;&lt;e&gt;'''</td><td>Move one screen downto beginning/end of line</td></tr><tr><tdstyle="font-family:courier">'''&lt;ctrl&gt;&lt;fk&gt;'''</td><td>Move one screen upCut line</td></tr><tr><tdstyle="font-family:courier">'''/pattern/&lt;esc&gt;6'''</td><td>Search for PatternCopy Line</td></tr><tr><tdstyle="font-family:courier">'''q&lt;ctrl&gt;&lt;u&gt;'''</td><td>quit man utilityPaste Cut/Copied Text</td></tr></tabletr><brtd style="font-family:courier"># Navigate through the man utility for the '''ls&lt;ctrl&gt;&lt;g&gt;''' Linux command and note the option letters that correspond to the following:<br/td><ultd>Display help screen (ctrl-x to exit help screen)<li/td>Include directory entries whose names begin with a dot</litr><litr>List in long format</litd style="font-family:courier"><li>Recursively list subdirectories encountered'''&lt;ctrl&gt;&lt;x&gt;'''</litd><litd>Sort files by sizeSave editing changes and exit</li><litd>Display a slash (`/') immediately after each pathname that is a directory</litr></ultable><br># Exit Referring to the man utility table above, practice navigating and editing your entered lines for the ls commandpractice.<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 To '''man''' utility can be used with the save'''your editing session, press: <span style="color:blue;font-weight:bold;font-k''' option to help list Linux commands that match a text pattern that is contained within the help screen for a Linux command.family:courier;">&lt;ctrl&gt;x</span><br><br># Although we You will not be learning about pipeline commands (using prompted to modify your file: type the | character) until later, try issuing the following pipeline command: letter <span style="font-family:courier;color:blue;font-weight:bold">man -k copy | grep 8y</span><br>How this this pipeline command make it easier to obtain information regarding man command?for '''yes'''.<br><br># If you wish to change your passwordThe name of the file will be displayed, you can change it by issuing the command: Press <span style="color:blue;font-weight:bold;font-family:courier;">passwdENTER</span>.to save editing changes for that file name.<br>What option <br>'''NOTE:''' This prompt for the passwd command can be used file name allows you to change user info (such as the name)?of the file if you wish.<br>By pressing '''Hint:ENTER''' use , it will accept the manpages for default filename.<br><br># Perform some more editing operations based on the passwd commandediting chart above.<br><br># '''NOTE:Save''' 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 editing session and '''exit''' your Matrix password changed at the same time that you change your myseneca passwordtext editor.<br><br>
===Part 2: Creating Text Files Using The vi Text Editor===[[Image:vi-screen.png|right|300px|thumb|Using the '''Command Line Editingvi'''text editor.]]You will now learn basic editing skills using the '''vi''' ('''vim''') text editor including<br>'''creating''', '''editing''', and '''saving''' text files.
Learning The '''shortcut keysvi''' in any OS terminal will allow you ('''vim''') text editor (although taking longer to learn) has outstanding features to be more productive as a sysadminincrease coding productivity. You will focus on learning a few common Bash Shell keyboard shortcut keysThe major different between nano and learn where vi is that '''vi starts in COMMAND LINE mode'''. You need to issue letter commands to enter text. Also you can access online help for additional shortcuts (if required)press colon “: ” in COMMAND mode to enter more complex commands.
'''Perform the Following Steps:'''
# Type Make certain that you are located in your home directory.<br><br># Issue the following Linux command, but DON’T press to edit a text file called '''othertext.txt''' in the ENTER key'''linux/practice''' directory: <br><span style="color:blue;font-weight:bold;font-family:courier;">cd vi textedit/binpractice/othertext.txt</span><br><br>'''NOTE:''' When using the '''vi''' text editor, you are placed in '''COMMAND''' mode,<br>so you need to issue a command to switch to ''INPUT'' mode.<br><br>[[Image:vi-text-editor-a.png|right|200px|thumb|Enter the following text that appears in this diagram.]]# Press Type the following key to enter ''INPUT'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">ctrl-ai</span> key combination<br><br>You should notice you are in ''INSERT'' mode by seeing the notification '''-- INSERT --'''<br>at the bottom left-hand side of the application screen.<br><br># Enter the line shown in the other diagram of the vi text editor on the right side. What happens?<br><br># Press While on the first line, press the following key to enter ''COMMAND'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">alt-FESC</span> key combination <br><br>You should see the ''-- INSERT --'' notification disappear indicating that you are in ''COMMAND'' mode.<br><br>'''NOTE:''' Refer to the table below for a list of<br>the most common '''vi''' (ESC+F for Mac OSx'''vim'''). What happens?navigation &amp; editing commands:<br><br># Press the <span table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Key(s)</th><th style="colorborder-bottom:blue1px solid black;">Purpose</th></tr><tr><td style="font-weightfamily:boldcourier">ctrl'''i'''</td><td>Enter '''INPUT''' mode</td></tr><tr><td style="font-wfamily:courier">'''&lt;esc&gt;'''</td><td>Return to '''COMMAND''' MODE</td></spantr><tr><td style="font-family:courier"> shortcut. What happens?'''x'''<br/td><brtd># Type Delete text to the following commandright in COMMAND mode</td></tr><tr><td style="font-family:courier">'''W'''</td><td>Move forward one word in COMMAND mode</td></tr><tr><td style="font-family:courier">'''B'''</td><td>Move back one word in COMMAND mode</td></tr><tr><td style="font-family: courier">'''dd'''</td><td>Cut line in COMMAND mode</td></tr><span tr><td style="colorfont-family:blue;courier">'''yy'''</td><td>Copy Line in COMMAND mode</td></tr><tr><td style="font-weightfamily:boldcourier">ls'''p / P'''</td><td>Paste Cut/spanCopied Text below/above line in COMMAND mode</td><br/tr><brtr># Press the <span td style="colorfont-family:blue;courier">'''u'''</td><td>Undo previous editing command</td></tr><tr><td style="font-weightfamily:boldcourier">ctrl''':help'''</td><td>Display help screen in COMMAND mode</td></tr><tr><td style="font-efamily:courier">''':x'''</spantd><td> key combination Save editing changes and press exit (in COMMAND mode)</td></tr><tr><span td style="colorfont-family:courier">''':blue;w name'''</td><td>Save editing changes to "name" in COMMAND mode</td></tr><tr><td style="font-weightfamily:boldcourier">ENTER''':q!'''</td><td>Abort editing session and exit (in COMMAND mode)</td></tr></spantable><br>Once you can get used to working in INPUT and COMMAND mode, it is easier to perform<br># Press the up arrow key. What happens?text editing operations in '''vi''' via ''COMMAND'' mode as opposed to nano!<br><br># Press Type the following keys to <u>copy</u> the current line: <span style="color:blue;font-weight:bold;font-family:courier;">ctrl-uyy</span> key combination. What happens?<br><br># Press Type the following key to <u>paste</u> the copied line: <span style="color:blue;font-weight:bold;font-family:courier;">up arrowp</span> key combination, and see what happens when <br><br>What did you press notice?<br><br># Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">BACKSPACEu</span> , <br><br>What did you notice?<br><br># Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">&lt;ctrl&gt;&lt;BACKSPACE&gt;3p</span> <br><br>What did you notice?<br><br>[[Image:vi-text-editor-b.png|right|200px|thumb|Use a combination of '''arrow''' keys and the '''w''' and '''b''' keys while in COMMAND mode to change the correct words for the '''third''' and '''fourth''' lines.]]# Use the up or down '''arrow''' keys to move to the second line.<br><br># Type either the '''w''' and/or '''b''' keys to move the cursor to the beginning of the word: '''first'''.<br><br># Type the '''x''' keys to remove the word called '''first'''.<br><br># Type the '''i''' key to enter INSERT mode.<br><br># Type the word: '''second'''<br><br># Press the '''ESC''' key to enter COMMAND mode.<br><br># Repeat steps '''11''' to '''16''' to change the words for line number for lines '''3''' and '''4'''.<br><br># Move to the 4th line (i.e. last line).<br><br># Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">&lt;ctrl&gt;&lt;h&gt;dd</span><br><br>What did you notice?<br><br>Let's save editing changes and exit the vi text editor. Why is it important to know those series of key combinations?<br><br># Press Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">ctrl:x</span> and press '''ENTER'''<br><br>What did you notice?<br><br># Issue the same command that you performed in '''Step #2''' to confirm that you had properly edited that file.<br><br># '''Save''' and '''exit''' your vi editing session.<br><br>[[Image:vi-text-editor-2.png|right|250px|thumb|The online vi-tutorial provides users "hands-on" experience of using the vi text editor.]]An '''online tutorial''' has been created to give you "hands-on" experience on how to use vi text editor. It is <u>recommended</spanu> key combination that you run this online tutorial in your Matrix account to learn how to clear create and edit text files with the linevi text editor.<br><br># Press Issue the following to run the vi online tutorial:<br><span style="color:blue;font-weight:bold;font-family:courier;">ctrl/home/murray.saul/vi-ltutorial<br></spanbr># In the tutorial menu, select the first menu item labelled "'''USING THE VI TEXT EDITOR'''"<br><br>#Read and follow the instructions in the tutorial. Eventually, it will display a '''simulated''' vi environment<br> key combinationand will provide you with "'''hands-on'''" practice using the vi text editor. What happens? What As far as this author is aware,<br>there is NO "hands-on" tutorial for the advantage of using nano text editor in this key combination then issuing particular format.<br><br># When you have completed that section, you will be returned to the main menu.<br>If you want to get extra practice, you can select the menu item labelled "'''clearREVIEW EXERCISE''' command?".<br><br># When you want to exit the tutorial, select the menu option to exit the tutorial.<br><br>
===Part 2: Performing Online Assignments ===It is recommended to try both text editors, and choose the text editor that you feel that is easier to use.<br><br>
You are required to perform '''===Part 3 online assignments''' during this course. This online assignment is used to teach and reinforce Linux commands are techniques as well as using Linux commands to perform tasks and tests students on their knowledge of issuing Linux commands.: Manage &amp; Manipulate Text File Content===
In We conclude this section, you will learn tutorial by learning to '''select the correct sectionmanage''' for your online assignments, how to perform the '''first two sectionsview''' of assignment #1, how to or '''verifymanipulate the <u>display</u>''' that of text files.<br>This is HIGHLY ADVISED in case you successfully completed both sections, only want to view contents and how to '''exitNOT''' your online assignment #1edit text file contents which can cause accidental erasure of data.
<br>'''Perform the following stepsFollowing Steps:'''[[Image:assign-initial-window.png|thumb|right|250px|Initial Assignment Window to Allow Student to Select Correct Course Section. ]]# In Make certain that you are located in your Matrix account, issue home directory.<br><br># Refer to the following commandtable of '''Text File Management Commands:'''<br><br><span styletable cellpadding="color:blue;font5"><tr><th style="border-weightbottom:bold1px solid black;font-family:courier" width="20%">~uli101/assign1Linux Command</spanth><brth style="border-bottom: 1px solid black;">Purpose<br/th># A screen similar to the one displayed on the right will appear.<br/tr><brtr><span td style="colorfont-family:red;courier">'''WARNINGtouch''': You need to select the CORRECT section for the course which you belong to.<br>If you do NOT select your correct section, your assignment may not be recorded for marks!</spantd><brtd><br># Select the '''letterCreate empty file(s)/ Updates Existing File''' corresponding to the s Date/Time Stamp<u/td>correct</utr><tr><td style="font-family:courier"> '''ULI101 section''' and cat'''professor</td><td>Display text file''' and press s contents without editing (small files)<span style/td></tr><tr><td style="color:blue;font-weightfamily:boldcourier">ENTER'''more , less'''</spantd><brtd>Display / Navigate within large text files without editing<br/td></tr># After you have selected your course section, There will be a screen that provides several important notes before proceeding.<brtr>Please take a few moments to read those notes and press <span td style="color:blue;fontfont-weightfamily:boldcourier">ENTER'''cp'''</spantd> to proceed.<brtd>Copy text file(s)<br/td>[[Image</tr><tr><td style="font-family:assn-section-completion.png|thumb|right|250px|Main Assignment Window to View Which Sections Need to be Completed. ]]# The assignment main menu will then be displayed.<br><br>'''NOTES:'courier">'''mv'''<ul/td><litd>Near the bottom of the window, you will see '''Move / Rename text files</td></tr><tr><td style="You are currently registered tofont-family:courier">''' followed by the rm'''section letter''' and '''instructor name'''. Double-check your course timetable to confirm that this the correct section letter. If you have selected the WRONG section, type <span style/td><td>Remove text file(s)</td></tr><tr valign="color:blue;font-weight:boldtop">C</span> in the menu selection area and press <span td style="color:blue;font-weightfamily:boldcourier">ENTER</span>. You will return back to the original window to select your correct course section.<br><br>'''sort'''</litd><litd>Near the top Sorts (rearranges) order of the window displays the sections to complete in the assignmentfile contents when displayed. You are NOT required to complete all sections at the same timeContent is sorted alphabetically by default. You can check the assignment #1 link on the ULI101 main WIKI page to note the due date for assignment #1. Sections that are NOT completed will be displayed in The '''-n'''''reverse Italic text with a blue background''option sorts numerically, '''-r'. On the other hand, when you compete '' performs a section, then the section will appear as regular textreverse sort<br/td>(i.e not in reverse text).<br/tr><brtr valign="top">[[Image<td style="font-family:assn-completed-window.png|thumb|right|250px|Main Assignment Window to Confirm Which Sections Have or Have Not Been Completed. ]]courier">'''head''' , '''tail'''</litd><litd>If you want to verify that you have completed sections for Displays the assignment, look for first / last 10 lines of a text file by default. An option using a value will display the text '''number of lines (e.g. <span style="Marks earned so far for ULI101 Assignmentfont-family:courier"''' and it >head -5 filename</span> will show how many sections have been completed. When it shows all sections completeddisplay first 5 lines, then your assignment is finished and you should receive full marks provided that you have selected your correct course section.<brspan style="font-family:courier">tail -5 filename<br/span>will display last 5 lines).</litd></ultr># At the menu assignment #1 window, enter <span styletr valign="top"><td style="color:blue;font-weightfamily:boldcourier">1'''grep'''</spantd><td> in the menu selection area to begin the first section called '''"Introduction to Unix Commands"'''.Displays file contents that match a pattern<br/td><br/tr><tr valign="top"># When you have completed this section, you will be returned to the main window.<brtd style="font-family:courier">View the contents of this window to confirm that you completed this section.'''uniq'''</td><td>Displays identical consecutive lines only once<br/td><br/tr># When you have time this week, enter <span styletr valign="top"><td style="color:blue;font-weightfamily:boldcourier">'''diff''' file1 file2</td><td>Displays differences between 2files</spantd></tr><tr><td style="font-family:courier"> in the menu selection area to begin the first section called '''"Basic Unix Commands"file'''.<br/td><brtd># When you have completed this section, you will be returned to Gives info about the contents of the main windowfile (e.g. file with no extention)<br/td></tr>View the contents of this window to confirm that you completed this section.<brtr><brtd style="font-family:courier">'''NOTE:find''' Although you are NOT allowed to use reference sheets for course evaluations, it is recommended to create one for your personal use, and write down Linux commands, their arguments and options, so your can successfully perform quizzes, midterm exam, and final exam.<br/td><td>To find files matching specified characteristics: <br!-- <table><tr># Proceed to the next section to perform additional practice. Linux is about <td width="doing30%"! The more practice questions you perform, the better mark you will achieve for this course and have a better foundation >'''<span style="font-family:courier">find . -name "file*"</span>'''</td><td>List pathname of issuing Linux commands to be more productive in any filenames beginning with "file",<br>from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''<span style="font-family:courier">find . -size +50k</span>'''</td><td>List pathname of any files larger than 50 kb, from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''<span style="font-family:courier">find . -mmin -5</span>''' </td><td>List files modified less than 5 minutes ago</td></tr><tr> valign="top"><td>'''<span style="font-family:courier">find -P .</span>'''</td><td>Lists file pathnames in the current directory</td></tr></table> --> </td></tr></table><br># Issue the following Linux command to create three <u>empty</u> text files in your future coursescurrent directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">touch a.txt b.txt c.txt</span><br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">ls -l a.txt b.txt c.txt</span><br><br>Check the size in the detailed listing to confirm that these newly-created files are empty.<br><br>[[Image:vi-screen-40.png|right|300px|thumb|Nano text editor containing numbers '''1 to 40'''<br>on separate lines.]]# Use the '''nano''' text editor to edit the empty file called '''a.txt'''. <br><br>Type the number "'''1'''" and press '''ENTER'''. On the second line, type the number "'''2'''" and press '''ENTER'''.<br>Continue entering increasing number values until you reach the number '''40''' on line 40<br>(refer to the diagram on the right).<br><br># '''Save''' and '''exit''' your editing session.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cat a.txt</span><br><br>Can you see all of the contents?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">more a.txt</span><br><br>'''NOTE:''' The '''more''' command uses the same navigation keys as with the '''man''' command<br>(refer to week 1 notes for reference). Try using keys that you used to navigate the man pages.<br><br>What is the advantage of using the more command?<br><br># Type the letter "<span style="color:blue;font-weight:bold;font-family:courier;">q</span>" to exit the ''more'' command.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">less a.txt</span><br><br>Is there any difference between the '''more''' and '''less''' commands?<br>(again press '''q''' to quit)<br><br># issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">sort a.txt</span><br><br>Why does the output not look what you expected? Why?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">sort -n a.txt</span><br><br>Try the same command using both the '''-n''' and '''-r''' options to see what happens.<br><br># issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">head a.txt</span><br><br>What is the output from this command display?<br><br># issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">head -7 a.txt</span><br><br>What is the output from this command display?<br><br># issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">tail a.txt</span><br><br>What is the output from this command display?<br>How would you issue this command to display only the '''last line''' contained in that file?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">grep 2 a.txt</span><br><br>What type of output appear? Why did these lines appear (what do they all have in common)?<br><br>[[Image:end-of-line.png|right|200px|thumb|Edit the '''a.txt''' file and add to the bottom 5 new lines each consisting of the <u>same</u> text: "'''end of line'''".]]# Edit the '''a.txt''' file and add to the bottom 5 new lines each consisting<br>of the <u>same</u> text: "'''end of line'''" (refer to diagram on right).<br><br># '''Save''' your editing session and '''exit''' your text editor.<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">uniq a.txt</span><br><br>What do you notice happened to those newly created lines?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp a.txt a.txt.bk</span><br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp a.txt b.txt</span><br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">mv a.txt aa.txt</span><br><br># Issue a Linux command to view the directory contents.<br><br>What happened to the file called '''a.txt'''? Why?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">file b.txt</span><br><br>What sort of information did it provide?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">diff aa.txt b.txt</span><br><br>Was there any output? If not, why?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">diff aa.txt c.txt</span><br><br> What do you think is the purpose of this output?<br><br># Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">find -P . </span><br><br>What is the output of this command?<br><br># Issue the following Linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">rm aa.txt b.txt a.txt.bk c.txt</span><br><br># Issue the '''ls''' command to verify that these files have been removed.<br><br># After you complete the '''LINUX PRACTICE QUESTIONS''' to get additional practice, then work on<br>'''online assignment #1''', '''section 2''' "''Basic Unix Commands''" (parts '''4''' to '''6''') labelled:<br> "''Managing Files''" , "''Accessing Files''" and "''Review Exercise''".<br><br>
= LINUX PRACTICE QUESTIONS =
simulate a quiz:
https://ict.senecacollege.ca/~murray.saul/uli101/uli101_week1_practiceuli101_week2_practice.docx
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
'''Review Questions:'''
# What is For each of the following questions, use a pathname starting from the '''Linux Clusterroot'''directory (i.e. “/? What is an advantage of using ).<br><br> [[Image:tree-diagram.png|right|350px|thumb|]]# Write a single Linux cluster?command to create the directory structure starting from your home directory from the diagram displayed on the right. # List Write a Linux command to display a detailed listing of '''three unique server nameshistory''' at Seneca college and briefly explain the purpose of that serverdirectory. <br>How would this command differ if you wanted to also view hidden files as well?<br># List the steps Write a Linux command to connect and login change to your Matrix Linux server account from a the '''workstationproject''' in a computer lab at Seneca Collegedirectory.<br>What command would you issue to return to your home directory?<br># List Write a Linux command to copy the steps to connect and login to your Matrix Seneca College account on your '''laptopproject''' or your directory and its contents to the '''home computerhistory'''directory.# List 3 unique ways Write a Linux command to move the directory called '''log-outdirectories''' of your Matrix account (not including closing to the SSH window or application)'''history''' directory.# What is the difference between Write a Linux command to remove both directories named '''command1''' and an argument?'''2'''.# What is the purpose of Write a Linux command to remove the '''optionconcepts'''?directory and its contents.# What character(s) is used Write a Linux command to remove the '''separateconcepts''' commands directory and arguments?prompt the user if they want to remove this directory’s contents.<br><br># Create Write a single Linux command to create the following empty files in the concepts directory:<br>'''myfile.txt'''<br>'''yourfile.txt'''<br>'''tablethefile.txt''' listing each <br># Write a Linux command, useful options that were mentioned in to view the contents of the myfile.txt text file to prove it is empty.<br>What is the online assignment #1 and command purpose for difference between the following Linux commands: '''pwdcat''' , '''cdmore''' , and '''less'''?# Write a Linux command to sort the contents of a file called '''lspractice/customers.txt''' , # Write a Linux command to display the first 4 lines of a file called '''calpractice/customers.txt''' , # Write a Linux command to display the last line of a file called '''datepractice/customers.txt''' , # Write a Linux command to match a line containing the pattern '''whoLinux''' , in a file called '''wpractice/customers.txt''' , # Write a Linux command to display unique occurrences of consecutive lines in a file called '''whoamipractice/customers.txt''' , # Create a '''who am Itable''' listing each Linux command, useful options that are displayed near the top of this tutorial labelled: '''clearTutorial Reference Material'''
[[Tutorial2: Unix / Linux File Management]]
[[Category:ULI101]]
13,420
edits

Navigation menu