Check Your ProgressBefore continuing on to the next module, check that you are able toaccomplish or answer the following: ❑ Control screen output using control characters ❑ Determine a f
Trang 1Exercise: Using Directory and File Commands
Tasks
12 Change to your home directory and with one command, create adirectory calledhouse with a subdirectory offurniturein yourhome directory
13 Create an empty file calledchairsin the new directory
furniture
14 Using one command, create three directories called letters,
memos, and miscin your home directory
15 Using one command, delete the directories calledmemosand misc
in your home directory
16 Try to delete the directory calledhouse/furniturewith therm
(no options) command What happens?
17 Identify the command to delete a directory that is not empty.Delete the directoryhouse/furniture List the contents of house
to verify thatfurniturehas been deleted
18 From your home directory, redirect the output of thelscommand
to a file calledfile.list
19 Display the contents offile.listusing thecatcommand
20 Append the output of the date command tofile.list
21 Display a calendar and using theteecommand, append theoutput to file.list
22 Use theteecommand to create a file with the names of five of thestudents in the class in it Examine the contents of your class listwith thecatcommand
Trang 2Exercise: Using Directory and File Commands
Workshop Labs
Use what you have learned so far in this course to work through thefollowing:
1 What shell has the system administrator set up for you?
2 Create a directory in which to place all of your personal executablefiles and place a copy of any executable file that currently exists inyour home directory into this new directory
3 While performing a keyword search onshellyou find manycommands that you want to learn more about in your spare time.Since your time is valuable you would like to save a listing of thecommands revealed by the search in a file and refer to it when youhave a free moment Place this file in your home directory to beused for reference later
Trang 3Exercise: Using Directory and File Commands
Exercise Summary
Discussion – Take a few minutes to discuss what experiences, issues,
or discoveries you had during the lab exercises
✓ Manage the discussion here based on the time allowed for this module, which was given
in the “About This Course” module If you find you do not have time to spend on
discussion, then just highlight the key concepts students should have learned from the lab exercise.
● Experiences
✓ Ask students what their overall experiences with this exercise have been You might want
to go over any trouble spots or especially confusing areas at this time.
✓ Explore with students how they might apply what they learned in this exercise to
situations at their workplace.
Trang 4Exercise: Using Directory and File Commands
Exercise Solutions
1 Determine the file type of/etc/passwdand display the contents
of the file
file /etc/passwd cat /etc/passwd
2 Display the contents of the file/usr/dict/wordsone screen at atime Exit after displaying two screens
more /usr/dict/words
To exit, type q or Control-c
3 What command would you most likely use to read the contents of
Trang 5Exercise: Directory and File Commands
cd; mkdir -p house/furniture
13 Create an empty file calledchairsin the new directory
furniture
touch house/furniture/chairs
14 Using one command, create three directories called letters,
memos, and miscin your home directory
mkdir letters memos misc
15 Using one command, delete the directories calledmemosand misc
in your home directory
rmdir memos misc
Trang 6Exercise: Directory and File Commands
18 From your home directory, redirect the output of thelscommand
to a file calledfile.list
cal | tee -a file.list
22 Use theteecommand to create a file with the names of five of thestudents in the class in it Examine the contents of your class listwith thecatcommand
$ tee classlist name1
Trang 7Check Your Progress
Before continuing on to the next module, check that you are able toaccomplish or answer the following:
❑ Control screen output using control characters
❑ Determine a file’s type with thefilecommand
❑ Display the contents of text files using the cat,more,head, and
tailcommands
❑ Determine word, line, and character count using the wccommand
❑ Compare the contents of text files usingdiffand cmp
❑ Create empty files or update access time of existing files using the
touchcommand
❑ Create and remove directories usingmkdirand rmdir
❑ Manage files and directories using themv,cp, andrmcommands
❑ Save the output from a command into a file
❑ Pass output from one command to another using a pipe
❑ Use theteecommand within a pipeline to create text within a file
Trang 8Think Beyond
Why is rm -r *such a dangerous command? What might you do toprevent use of this command?
Trang 10Upon completion of this module, you should be able to:
● Describe the basic concepts of the File Manager
● Demonstrate the drag-and-drop capability of File Manager
● Create and remove folders
● Execute actions from the File Manager’s menu options
● Move a file or a folder onto the workspace backdrop
● Find a file using File Manager’s Locate facility
● Customize the manner in which file and folder information isdisplayed in the File Manager window
Trang 11✓ Present the following question to stimulate the students and get them thinking about the issues and topics presented in this module While they are not expected to know the answer to the question, the answer should be of interest to them and inspire them to learn the content presented in this module.
Discussion – File manipulation is frequently done by using the
graphical user interface What alternatives to using the command linedoes working within the GUI provide?
Trang 12The File Manager
FrontPanelFile Managericon
FileManagerwindowdisplay
FileManagericon
Trang 13The File Manager
The File Manager enables you to graphically organize files into ahierarchical structure of folders and subfolders (directories)
Directories are displayed with folder icons Files are displayed withappropriate icons
The File Manager, by default, opens a view of a folder which is thecurrent directory From that folder, you can change to other folders,both up and down in the hierarchy, to view each directory’s contents.The path to the current folder is always displayed in the top area ofthe File Manager window
Trang 14File and Folder Icons
Trang 15File and Folder Icons
To help you identify files and directories more easily, the File Managerdisplays differing icons depending on the content of the file
The most common file icon you will see will be the standard file icon
If a file is a data file associated with a particular application, thatapplication will be automatically started when you double-click on theicon
If you double-click on a folder icon, the File Manager moves you intothat directory and displays its contents You can only move downthrough the file system hierarchy in this way
There is always a special icon displayed in the upper left corner of theFile Manager display
Double-clicking on this (go up) icon will move you to the next level up
in the hierarchy
Trang 16Moving and Copying Files Using Drag-and-Drop
File is selected then dragged
to the appropriate folder icon
Trang 17Moving and Copying Files Using Drag-and-Drop
Select + Drag + Drop
To move a file from one folder to another, position the mouse pointerover the file icon, hold down the left mouse button and drag the icon
to the appropriate folder icon
Once the file icon is positioned over the folder icon, release the mousebutton and the file will be moved to that folder
Control + Select + Drag + Drop
If you press the Control key before the file icon has been selected andkeep it held down while the drag-and-drop process takes place, the filewill be copied rather than just moved to the other folder
Note – You cannot move or copy file icons to the path icon display in
the top part of the File Manager window display
If you want to move or copy files to the parent directory of the currentfolder, you can drag and drop the file icon to the (go up) icon
Trang 18File Menu Options
The File Menu options enable you to perform the following tasks:
● Create a new folder (directory)
● Create a new file
● Change to your home directory (if your current folder is differentfrom your home folder)
● Go up one level of folder in the hierarchy
● Change to a specified directory
● Find files based on their name or content
● Open a Terminal window (in which to give UNIX commands)
Note – There are keyboard mnemonics which can be used as shortcuts
to the File menu options
Trang 19Creating a New Folder
Trang 20Creating a New Folder
When the New Folder option is chosen, a separate window isdisplayed Type the name of the new directory
Once the name has been applied, you have the choice of left clickingeither OK or Apply
● Clicking OK adds the new folder with the name you just typed,and closes the New Folder window
● Clicking Apply adds the new folder, and keeps the New Folderwindow on the screen display, ready for you to type in the name
of another new folder
If you want to create several new directories, click Apply for all newfolder names except the last When the last folder name has beentyped, click OK to remove the New Folder window
Note – When you click Apply, the name is retained in the typing area
of the New Folder window You must remove the previous foldername using the Backspace key or the equivalent mouse action
Trang 21Creating a New File
As with the New Folder option, a window will be displayed in whichyou must type the name of the file to be created
Trang 22Folder or File Name Conflicts
If you attempt to create a folder or file with the same name as anexisting folder or file, you will be notified by the File ManipulationError window
Click OK, then type an alternative name for the folder or file which is
to be created
Trang 23Changing Folders
The Go To option on the File Manager’s File menu enables you tospecify which folder to change to by specifying a path name
Enter a valid pathname into the appropriate entry box, then click OK
If there are any permission controls which prevent you from changing
to the specified folder, you will be notified with the following windowdisplay:
Trang 24Finding Folders and Files
Trang 25Finding Folders and Files
The Find menu option enables you to search through the file systemhierarchy using search criteria The criteria can be either the name ofthe folder or file or, in the case of a file, the contents
Wildcard characters can be used when specifying the name of the file
to find For example:
a* Finds folder or file names which start with the letter “a”
*s Finds folder or file names which end with the letter “s”
??a Finds three-character folder or file names, where the last
character in the name is the letter “a”
[Aa]* Finds folder or file names which start with the letter “a”
(either uppercase or lowercase)
The search folder name is the starting point when searching the filesystem hierarchy
Note – If you start at the root of the file system (the / directory), the
Find operation may take a considerable amount of time to complete
Trang 26Selected Menu Options
The Selected Menu With a Folder Chosen
Trang 27Selected Menu Options
The Selected Menu With a File Chosen
Trang 28Selected Menu Options
File and Folder icons can be selected by clicking with the left mousebutton Once selected, the File Manager menu options enable you to:
● Move the selected object to another folder location
● Copy the selected object to another folder location or to a differentnamed folder or file
● Link the folder or file to another folder or file name (This optioncreates a symbolic link with the same name as the original file orfolder Links are covered in Module 14.)
● Place the object on the workspace area This placement makes thatobject available whether or not you have a File Manager windowopen
● Place the object in the trash can An alternative to this option is todrag and drop the object over the Trash Can icon on the FrontPanel display
Trang 29Selected Menu Options
● Change the permissions of a folder or file (Permissions arecovered in Module 8.)
● Select or deselect all objects in the current folder Once selected,they can be moved, copied, or deleted as a complete group ofobjects
● Open a folder or file This menu option is the same as clicking on the object icon
double-● Print the file This is same as using drag and drop with the PrintManager icon on the Front Panel
Note – Different options display in the Selected menu, depending on
the type of file or folder selected
Trang 30View Menu Options
Clicking on Open New View in the View menu will open another FileManager window This facilitates moving files between differentdirectory hierarchies
The File Manager window can be set to Show Hidden Objects,allowing viewing of all objects in a directory Setting the Filter Optionsenables you to decide what objects will be hidden objects if you choosenot to have these objects displayed
The Update option of the View menu will redraw the File Managerwindow screen This is useful if objects have been hidden or movedaround during the current File Manager session
Trang 31View Menu Options
Set View Options enables you to choose the way in which the FileManager information is displayed in the window
The choices are as follows:
Trang 32View Menu Options
Tree Display for Folders
Trang 33View Menu Options
By using the Tree display for your folders, it becomes easier to movearound the file system hierarchy
When a folder is selected by double-clicking, another File Managerwindow will automatically be invoked and the contents of the selectedfolder will be displayed in the new File Manager window
Note – For every folder which is selected, a new File Manager window
will be invoked Close the File Manager windows if you have finishedworking with the contents of the folder; otherwise, the performance ofyour workstation will begin to degrade
Trang 34Exercise: Managing Files With File Manager
Exercise objective – In this lab you will use the commands introduced
in this module to create, move, and remove files and directories
Tasks
Complete the following exercises:
1 Open a File Manager window
2 Create a new folder and a new file Try giving the new file thesame name as the new folder (Correct as necessary.)
3 Change the View to a Tree view then back to the original view
4 Use the (go up) icon to change to the root folder (/)
5 Change to your home folder by double-clicking on the appropriatefolder objects
6 Use the Go To menu option change to the root folder
7 Use the appropriate menu option to change to your home folder
8 Delete your new file by dragging and dropping the new file objectonto the Trash Can icon on the Front Panel
Trang 35Exercise: Managing Files With File Manager
Exercise Summary
Discussion – Take a few minutes to discuss what experiences, issues,
or discoveries you had during the lab exercises
✓ Manage the discussion here based on the time allowed for this module, which was given
in the “About This Course” module If you find you do not have time to spend on
discussion, then just highlight the key concepts students should have learned from the lab exercise.
● Experiences
✓ Ask students what their overall experiences with this exercise have been You might want
to go over any trouble spots or especially confusing areas at this time.
✓ Explore with students how they might apply what they learned in this exercise to
situations at their workplace.