Open main menu

CDOT Wiki β

Changes

Tutorial2: Unix / Linux File Management

10,856 bytes removed, 08:40, 6 January 2020
INVESTIGATION 2: USING TEXT EDITORS TO CREATE / MODIFY TEXT FILES
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)x:* Learn how to get '''help''' for Linux commands with manpages ('''man''' command).x:* Learn '''Basic Shell Editing'''x:* Learn how to perform '''online assignments'''.x:* Perform the '''first two sections of online assignment #1'''.<br><br>x
===Part 1: Using the Linux Shell Nano Text Editor ===
The Bash shell in Matrix allows you to interact with your account by issuing commands.x
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 -laPerform the Following Steps:''' ).<br><br>
'''Linux Command Structure'''# x<br><br>
<span style="color:blue;font-weight:bold">command argument1 argument2 ... </span>
An '''argument''' can be a '''pathname''', '''text''', '''option''', etc.===Part 2: Using the VI / VIM Text Editor ===
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 directoryx
<br>
'''Perform the following steps:'''
'''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:'''# x
# Make certain that you are logged into your Matrix account.<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 keys
and 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 === You are required to perform '''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. In this section, you will learn to '''select the correct section''' for your online assignments, how to perform the '''first two sections''' of assignment #1, how to '''verify''' that you successfully completed both sections, and how to '''exit''' your online assignment #1. <br>'''Perform the following steps:'''[[Image:assign-initial-window.png|thumb|right|250px|Initial Assignment Window to Allow Student to Select Correct Course Section. ]]# In your Matrix account, issue the following command:<br><span style="color:blue;font-weight:bold;font-family:courier">~uli101/assign1</span><br><br># A screen similar to the one displayed on the right will appear.<br><br><span style="color:red;">'''WARNING''': 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!</span><br><br># Select the '''letter(s)''' corresponding to the <u>correct</u> '''ULI101 section''' and '''professor''' and press <span style="color:blue;font-weight:bold">ENTER</span><br><br># After you have selected your course section, There will be a screen that provides several important notes before proceeding.<br>Please take a few moments to read those notes and press <span style="color:blue;font-weight:bold">ENTER</span> to proceed.<br><br>[[Image: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:'''<ul><li>Near the bottom of the window, you will see '''"You are currently registered to"''' followed by the '''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="color:blue;font-weight:bold">C</span> in the menu selection area and press <span style="color:blue;font-weight:bold">ENTER</span>. You will return back to the original window to select your correct course section.<br><br></li><li>Near the top of the window displays the sections to complete in the assignment. You are NOT required to complete all sections at the same time. 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 '''reverse text with a blue background'''. On the other hand, when you compete a section, then the section will appear as regular text<br>(i.e not in reverse text).<br><br>[[Image:assn-completed-window.png|thumb|right|250px|Main Assignment Window to Confirm Which Sections Have or Have Not Been Completed. ]]</li><li>If you want to verify that you have completed sections for the assignment, look for the text '''"Marks earned so far for ULI101 Assignment:"''' and it will show how many sections have been completed. When it shows all sections completed, then your assignment is finished and you should receive full marks provided that you have selected your correct course section.<br><br></li></ul># At the menu assignment #1 window, enter <span style="color:blue;font-weight:bold">1</span> in the menu selection area to begin the first section called '''"Introduction to Unix Commands"'''.<br><br># When you have completed this section, you will be returned to the main window.<br>View the contents of this window to confirm that you completed this section.<br><br># When you have time this week, enter <span style="color:blue;font-weight:bold">2</span> in the menu selection area to begin the first section called '''"Basic Unix Commands"'''.<br><br># When you have completed this section, you will be returned to the main window.<br>View the contents of this window to confirm that you completed this section.<br><br>'''NOTE:''' 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><br># Proceed to the next section to perform additional practice. Linux is about "doing"! The more practice questions you perform, the better mark you will achieve for this course and have a better foundation of issuing Linux commands to be more productive in your future courses.<br><br>
= LINUX PRACTICE QUESTIONS =
13,420
edits