Changes

Jump to: navigation, search

Tutorial2: Unix / Linux File Management

5,420 bytes added, 06:30, 2 June 2021
Part 2: Viewing Directory Contents / Copying & Moving Directories
=INVESTIGATION 1: CREATING & MANAGING DIRECTORIES=
<span style="color:red;">'''ATTENTION''': Depending on your ULI101 instructor, you may be required to complete this tutorial for '''marks''' in this course.<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 tutorial, you can perform it for '''practice'''.</span><br><br> 
In this investigation, you will learn how to '''create''', '''navigate''', '''list directory contents''' and '''remove''' directories in your Matrix account.
# 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 '''examplessamples''':<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir notes tutorials examplessamples</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 examples tests if you issue multiple Linux commands to performed tasks that can be 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 '''remove''' directories and their contents in another sectioninvestigation,<br>let's remove the 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 create the entire directory structure:<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir -p uli101xx/notes uli101xx/tutorials uli101xx/examples samples acp100xx xyz100xx</span><br><br>'''NOTE:''' The '''-p''' option allows "parent" directories to be automatically created first to then create their subdirectories.<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/examples samples acp100xx xyz100xx</span>
<br><br>
'''Running a Shell Script to Check your Work'''
# Make certain that your current directory is '''your home directory'''.<br><br>
# Issue the following Linux command to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts~uli101/week2-check-1</span><br><br># If you encounter errors, then view the feedback to make corrections, and then re-run the checking script. If you receive a congratulation message that there are no errors, then proceed to the next sectionpart.
<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 sectioninvestigation. 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="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:courier;">tree </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;">bash /home/murray.saul/scripts~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 sectioninvestigation.<br><br>
===Part 3: Removing Directories ===
In this sectioninvestigation, we will learn how to '''safely remove''' directories and their contents.
# Issue the following Linux command (entering "y" when prompted): <span style="color:blue;font-weight:bold;font-family:courier;">rm -ri xyz100xx</span><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 '''tree''' 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;">bash /home/murray.saul/scripts~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>
=INVESTIGATION 2: MANAGING TEXT FILES=
# Issue a Linux command to check that you correctly created those directories.<br><br>
# Issue the following Linux command to edit a text file called '''mytext.txt''' in the '''linux/practice''' directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">nano textedit/practice/mytext.txt</span><br><br>'''NOTE:''' When using the '''Nano''' text editor, you are placed in '''INPUT''' 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.]]
# Enter the lines shown in the other diagram of the nano text editor on the right side.<br><br>'''NOTE:''' Refer to the table below for a list of the most <br>common '''Nano ''' navigation &amp; editing commands:<br><br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Key(s)</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><trvalign="top"><td style="font-family:courier">'''&lt;ctrl&gt;&lt;SPACEBAR&gt;''',<br>'''&lt;esc&gt;&lt;6&gt;'''</td><td>Move forward /backward one word</td></tr><trvalign="top"><td style="font-family:courier">'''&lt;escctrl&gt;&lt;a&gt;''',<br> '''&lt;ctrl&gt;&lt;SPACEBARe&gt;'''</td><td>Move back one wordto beginning/end of line</td></tr><tr><td style="font-family:courier">'''&lt;ctrl&gt;&lt;k&gt;'''</td><td>Cut line</td></tr><tr><td style="font-family:courier">'''&lt;esc&gt;^6'''</td><td>Copy Line ('''Note</td></tr><tr><td style="font-family:courier">''' to get '''^''' character, type '''&lt;shiftctrl&gt;&lt;u&gt;6''', <u>not</utd> <ctrltd>)Paste Cut/Copied Text</td></tr><tr><td style="font-family:courier">'''&lt;ctrl&gt;&lt;ug&gt;'''</td><td>Paste Cut/Copied TextDisplay help screen (ctrl-x to exit help screen)</td></tr><tr><td style="font-family:courier">'''&lt;ctrl&gt;&lt;gx&gt;'''</td><td>Display help screen (ctrl-x to Save editing changes and exit help screen)</td></tr></table><br>
# Referring to the table above, practice navigating and editing your entered lines for practice.<br><br>
# To '''save''' your editing session, press: <span style="color:blue;font-weight:bold;font-family:courier;">&lt;ctrl&gt;x</span><br><br>
# You will be prompted to modify your file: type the letter <span style="font-family:courier;color:blue;font-weight:bold">y</span> for '''yes'''.<br><br>
# The name of the file will be displayed, Press <span style="color:blue;font-weight:bold;font-family:courier;">ENTER</span>.to save editing changes for that file name.<br><br>'''NOTE:''' This prompt for file name allows you to change the name of the file if you wish.<br>By pressing '''ENTER''', it will accept the default filename.<br><br>
# Practice Perform some more editing operations based on the file ( using the command in editing chart above.<br><br># '''Save'step 2'' ) and perform more editing operations,<br>and then save your editing session and '''exit ''' your text editor.<br><br>
===Part 2: Creating Text Files Using The vi Text Editor===
[[Image:vi-screen.png|right|300px|thumb|Using the '''vi''' text editor.]]
You will now learn basic editing skills using the '''vi''' ('''vim''') text editor including <br>'''creating''', '''editing''', and '''saving''' text files.
The '''vi''' ('''vim''') text editor (although taking longer to learn) has outstanding features to increase coding productivity.
The major different between nano and vi is that '''vi starts in COMMAND LINE mode'''. You need to issue letter commands to perform enter text editing or . Also you can press colon “: ” in COMMAND mode to enter last line mode to issue more complex commands.  '''NOTE:''' Refer to the table below for a list of the most common '''vi''' ('''vim''') navigation &amp; editing commands:<br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Key(s)</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td style="font-family:courier">'''i'''</td><td>Enter '''INPUT''' mode</td></tr><tr><td style="font-family:courier">'''&lt;esc&gt;'''</td><td>Return to '''COMMAND''' MODE</td></tr><tr><td style="font-family:courier">'''W'''</td><td>Move forward one word</td></tr><tr><td style="font-family:courier">'''B'''</td><td>Move back one word</td></tr><tr><td style="font-family:courier">'''dd'''</td><td>Cut line</td></tr><tr><td style="font-family:courier">'''yy'''</td><td>Copy Line</td></tr><tr><td style="font-family:courier">'''&lt;ctrl&gt;u'''</td><td>Paste Cut/Copied Text</td></tr><tr><td style="font-family:courier">''':help'''</td><td>Display help screen ('':q!'' to exit help screen)</td></tr></table><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</u> that you run this online tutorial in your Matrix account to learn how to create and edit text files with the vi text editor. 
'''Perform the Following Steps:'''
# Make certain that you are located in your home directory.<br><br>
# Issue the following Linux command to edit a text file called '''othertext.txt''' in the '''linux/practice''' directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">vi textedit/practice/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.]]
# Type the following key to enter ''INPUT'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">i</span><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.<br><br>
# While on the first line, press the following key to enter ''COMMAND'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">ESC</span><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''' ('''vim''') navigation &amp; editing commands:<br><br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Key(s)</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td style="font-family:courier">'''i'''</td><td>Enter '''INPUT''' mode</td></tr><tr><td style="font-family:courier">'''&lt;esc&gt;'''</td><td>Return to '''COMMAND''' MODE</td></tr><tr><td style="font-family:courier">'''x'''</td><td>Delete text to the right 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><tr><td style="font-family:courier">'''yy'''</td><td>Copy Line in COMMAND mode</td></tr><tr><td style="font-family:courier">'''p / P'''</td><td>Paste Cut/Copied Text below/above line in COMMAND mode</td></tr><tr><td style="font-family:courier">'''u'''</td><td>Undo previous editing command</td></tr><tr><td style="font-family:courier">''':help'''</td><td>Display help screen in COMMAND mode</td></tr><tr><td style="font-family:courier">''':x'''</td><td>Save editing changes and exit (in COMMAND mode)</td></tr><tr><td style="font-family:courier">''':w name'''</td><td>Save editing changes to "name" in COMMAND mode</td></tr><tr><td style="font-family:courier">''':q!'''</td><td>Abort editing session and exit (in COMMAND mode)</td></tr></table><br>Once you can get used to working in INPUT and COMMAND mode, it is easier to perform<br>text editing operations in '''vi''' via ''COMMAND'' mode as opposed to nano!<br><br>
# Type the following keys to <u>copy</u> the current line: <span style="color:blue;font-weight:bold;font-family:courier;">yy</span><br><br>
# Type the following key to <u>paste</u> the copied line: <span style="color:blue;font-weight:bold;font-family:courier;">p</span><br><br>What did you notice?<br><br>
# Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">u</span><br><br>What did you notice?<br><br>
# Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">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;">dd</span><br><br>What did you notice?<br><br>Let's save editing changes and exit the vi text editor.<br><br>
# Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">: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</u> that you run this online tutorial in your Matrix account to learn how to create and edit text files with the vi text editor.<br><br>
# Issue the following to run the vi online tutorial:<br><span style="color:blue;font-weight:bold;font-family:courier;">/home/murray.saul/vi-tutorial<br><br>
# 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>and will receive stepprovide you with "'''hands-byon'''" practice using the vi text editor. As far as this author is aware,<br>there is NO "hands-step instructions on how to use this " tutorial for the nano text editorin this 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 "'''REVIEW EXERCISE'''".<br><br>
# When you want to exit the tutorial, select the menu option to exit the tutorial.<br><br>
: It is recommended to try both text editors, and choose the text editor that you feel that is easier to use.<br><br> ===Part 3: Manage / &amp; Manipulate Text File Content===
We conclude this tutorial by learning to '''manage''', '''view''' or '''manipulate the <u>display</u>''' file content without having to use a of text editorfiles.<br>This is HIGHLY ADVISED in case you only want to view contents and '''NOT ''' edit text file contents by mistakewhich can cause accidental erasure of data.
'''Perform the Following Steps:'''
# Make certain that you are located in your home directory.<br><br># Refer to the following table of '''Text File Management commands Commands:'''<br><br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;" width="20%">Linux Command</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td style="font-family:courier">'''touch'''</td><td>Create empty file(s) / Updates Existing File's Date/Time Stamp</td></tr><tr><td style="font-family:courier">'''cat'''</td><td>Display text file's contents without editing (small files)</td></tr><tr><td style="font-family:courier">'''more , less'''</td><td>Display / Navigate within large text files without editing</td></tr><tr><td style="font-family:courier">'''cp'''</td><td>Copy text file(s)</td></tr><tr><td style="font-family:courier">'''mv'''</td><td>Move / Rename text files</td></tr><tr><td style="font-family:courier">'''rm'''</td><td>Remove text file(s)</td></tr><tr valign="top"><td style="font-family:courier">'''sort'''</td><td>Sorts (rearranges) order of file contents when displayed. Content is sorted alphabetically by default. The '''-n'''''Italic text'' option sorts numerically, '''-r''' performs a reverse sort</td></tr><tr valign="top"><td style="font-family:courier">'''head''' , '''tail'''</td><td>Displays the first / last 10 lines of a text file by default. An option using a value will display the number of lines (e.g. <span style="font-family:courier">head -5 filename</span> will display first 5 lines, <span style="font-family:courier">tail -5 filename</span> will display last 5 lines).</td></tr><tr valign="top"><td style="font-family:courier">'''grep'''</td><td>Displays file contents that match a pattern</td></tr><tr valign="top"><td style="font-family:courier">'''uniq'''</td><td>Displays identical consecutive lines only once</td></tr><tr valign="top"><td style="font-family:courier">'''diff''' file1 file2</td><td>Displays differences between 2 files</td></tr><tr><td style="font-family:courier">'''file'''</td><td>Gives info about the contents of the file (e.g. file with no extention)</td></tr><tr><td style="font-family:courier">'''find'''</td><td>To find files matching specified characteristics: <!-- <table><tr><td width="30%">'''<span style="font-family:courier">find . -name "file*"</span>'''</td><td>List pathname of 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># Confirm that you are located Issue the following Linux command to create three <u>empty</u> text files in your '''home''' current directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">touch a.txt b.txt c.txt</span><br><br># Use Issue the '''touch''' following Linux command to create the empty files called ''': <span style="color:blue;font-weight:bold;font-family:courier;">ls -l a.txt''', '''b.txt''', and '''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>Can '''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 view or at least used to navigate to see all of the contents?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 save changes to '''exit''' your filetext 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 one of the commands you learned to display the contents of the file called '''b.txt''' without editing.<br><br>What happened to this file?<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>What was the Was there any output? Why do you think caused the result of this outputIf 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 reason would do you think is the purpose of this type of output occur?<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 Review Questions sections '''LINUX PRACTICE QUESTIONS''' to get additional practice, then work on your<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 =
13,420
edits

Navigation menu