Changes

Jump to: navigation, search

Tutorial2: Unix / Linux File Management

1,038 bytes added, 03:57, 24 January 2020
Tutorial Reference Material
|- valign="top" style="padding-left:15px;"
|colspan="1" |Course NotesSlides:<ul><li>[https://ict.senecacollege.ca/~uli101/notes/Week02.pdf PDF] | [https://ict.senecacollege.ca/~uli101/notes/Week02.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>
*[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>
|}
 
= KEY CONCEPTS=
===Unix / Linux Directories===
'''Perform the Following Steps:'''
# View the following table of Text File Management commands Your instructor should have demonstrated in class how to use these commands):<br><br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Linux Command</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td>'''touch'''</td><td>Create empty file(s) / Updates Existing File's Date/Time Stamp</td></tr><tr><td>'''cat'''</td><td>Display text file's contents without editing (small files)</td></tr><tr><td>'''more , less'''</td><td>Display / Navigate within large text files without editing</td></tr><tr><td>'''cp'''</td><td>Copy text file(s)</td></tr><tr><td>'''mv'''</td><td>Move / Rename text files</td></tr><tr><td>'''rm'''</td><td>Remove text file(s)</td></tr><tr valign="top"><td>'''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>'''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. head -5 filename will display first 5 lines, tail -5 filename will display last 5 lines).</td></tr><tr valign="top"><td>'''grep'''</td><td>Displays file contents that match a pattern</td></tr><tr valign="top"><td>'''uniq'''</td><td>Displays identical consecutive lines only once</td></tr><tr valign="top"><td>'''diff''' file1 file2</td><td>Displays differences between 2 files</td></tr><tr><td>'''file'''</td><td>Gives info about the contents of the file (e.g. file with no extention)</td></tr><tr valign="top"><td>'''find'''</td><td>To find files matching specified characteristics:<table><tr valign="top"><td width="20%">'''find . -name "file*"'''</td><td>List pathname of any filenames beginning with "file",<br>from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''find . -size +50k'''</td><td>List pathname of any files larger than 50 kb, from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''find . -mmin -5''' </td><td>List files modified less than 5 minutes ago</td></tr><tr> valign="top"><td>'''find -P .'''</td><td>Lists file pathnames in the current directory</td></tr></table></td></tr></table><br><br>
# Make certain that you are located in your '''home''' directory.<br><br>
# Use the '''touch''' command to create the empty files called '''a.txt''', '''b.txt''', and '''c.txt'''<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>
# Edit the '''a.txt''' file and add to the bottom 5 new lines each consisting of the <u>same</u> text: "'''end of line'''" and save changes to your file.<br><br>
# Issue the following Linux command: <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 to get additional practice, then work on your online assignment#1, section 2 labelled "Basic Unix Commands" (parts '''4''' to '''6''') in this section which are respectively labelled: '''Managing Files''' , '''Accessing Files''' and '''Review Exercise'''.<br><br>
= LINUX PRACTICE QUESTIONS =
13,420
edits

Navigation menu