ICDL Using a Computer Chapter 3. Managing Files

From MEPIS Documentation Wiki

Jump to: navigation, search

http://www.openicdl.org.za/devcourses/mod1/ch02.html

Attribution-ShareAlike 2.5 You are free: To copy, distribute, display, and perform the work, To make derivative works, To make commercial use of the work Under the following conditions: by Attribution. You must attribute the work in the manner specified by the author or licensor who is: David Varley ICDL Foundation Copyright © 2004 ICDL Foundation.

Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder.



Contents

Chapter 3. Managing files

Concepts

Abstract

Understand how an operating system shows drives, folders, files in a hierarchical structure.

To understand the concept of a directory, consider an analogy of an office block containing a number of offices. Each office has a name. Inside each office there are a number of filing cabinets, each of which is named. Files are stored in the filing cabinets. Each file also has a name.

Suppose a file called Lombard is located in the Staff cabinet of the Administration office. This could be described in a shorthand form as /Administration/Staff/Lombard.

In the same way /Stores/Suppliers/Kumar would indicate a file called Kumar in the Suppliers filing cabinet in the Stores office.

Directories on a computer system are similar to the offices and filing cabinets. A directory is a container that can contain files or other directories. A directory located inside another directory is called a sub-directory. Sometimes the word folder is used in place of the word directory. One difference between the analogy and a computer system is that in the former case we are dealing physical objects whereas in the latter we are dealing with a more abstract structure.

Directories, sub-directories and files are arranged in a hierarchical structure called a tree. A typical computer will contain many thousands of files stored in many directories. Each directory contains files that are related in some way. The starting point of the tree is called the root. Do not confuse this usage of the word with the special user that has complete control over the system. root is designated by the / symbol. This symbol is also used to separate the different levels of the hierarchy.

A directory structure may contain many levels of sub-directories. The following diagram illustrates part of a Linux system directory structure. Files are shown in italics.

(screenshot needed)

The full description of the location of a file is called its path. If we wish to describe a file fully, we need to include its path. An example from the previous diagram would be: /home/david/letters/Tax(2004-04-04).

http://www.mepislovers-wiki.org/images/c/cc/Note.png Linux names are case sensitive. Hence the three names tax, Tax and TAX are all different as far as Linux is concerned. Using the wrong case for letters is a common source of errors.

http://www.mepislovers-wiki.org/images/c/cc/Note.png If you have worked with Windows, the Linux directory structure may seem confusing at first. Each system has a single directory system. Drives are located within branches of the structure rather than the structure starting with a drive. Linux goes much further and includes devices such as ports and printers within the directory structure. This follows from the fact that Linux treats files and devices in the same way.

The process of adding components to the Linux directory hierarchy is called mounting and removing them is called unmounting.

The home directory is of special importance in Linux. When a new user is added to the system, Linux creates a sub-directory of the same name in home. For example, if the user dorothy is added, Linux will create the directory /home/dorothy at the same time. This sub-directory is known as the user's home directory. Each user will create a further series of sub-directories in which he/she will store files.

Each user's home directory is private to that user. Apart from the owner of the home directory, the only other user that normally has access to it is the root user.

Each user can access his/her home directory by clicking on the Home icon on the desktop or by using Start Applications->Home.

Storage devices

Abstract

Know that the devices used by an operating system to store files and folders are the hard disk, diskette, CD-ROM, network drives.

For long term storage, files are stored on various secondary memory devices. These include hard disks, floppy disks, CD-ROMs, DVDs, Zip disks, tape and flash memory. These devices were described in module 1.

Although we can think of directories as containers for files and sub-directories, these are logical structures rather than physical areas on a disk. The actual method of physically storing files on disk and organising them in directories is a very technical topic. From a user's perspective, the important thing is to understand directories as providing a logical method of grouping related files together in one place.

Where computers are connected together through a network, each user will see the disk drives on other computers as part of his/her own directory tree. In fact, if the user has not set up the system, he/she will not necessarily even be aware of the physical location of different parts of the directory tree.

One of the strengths of Linux is that it fully integrates a network into a single system.

Directories/folders

Abstract

Navigate to a file, folder on a drive.

Browse using the Home icon

Click the Home icon either in Start Applications or on the panel or on the desktop.

Because this tool is so important, it is found in a number of places. After clicking this icon, the Konqueror browser will open with the contents of your home directory displayed. (screenshot of Konqueror required)

The Desktop sub-directory is created automatically at the same time as the home directory. Files that are saved to this sub-directory will be displayed as icons on the desktop.

The navigation icons are displayed on the left of the toolbar. The Up icon displays the directory one up in the hierarchy. This is also known as the parent of the current directory. It is one step closer to the root of the system.(screenshot needed)

  • Click Up twice. This will display the root of the system. This is the starting point of the entire directory system. (screenshot needed)

Although you can see files and directories, you will not be able to manipulate them or delete them. You are only able to work with directories and files to which you have access. Normally these are only files located in your home directory and its sub-directory. Hoswever, the root user is able to give you access rights to files and directories outside your home directory.

The Back and Forward icons allow you to trace your steps back and forward through the directories you have visited during your current session. (screenshot needed)

To return to the home directory at any stage, press the Home icon. (screenshot needed)

To move to a new directory, double click on the icon in the main pane.

  • Double-click on the etc directory. (screenshot needed)

You can also type the name of the directory into the location window if you know its path. Remember that Linux file and directory names are case sensitive.

Create a directory/folder and a further sub-directory/sub-folder

The following example illustrates how to create directories and sub-directories in your home directory.

  1. Click the Home icon.
  2. Edit->New Directory or press F10.
  3. Enter the name for the new directory, Letters. (screenshot needed)
  4. Click OK.
  5. Edit->New Directory or press F10.
  6. Enter the name for the new directory, Articles.
  7. Double-click on the Letters icon in the main pane. Note that the contents of the Location bar now reflect the new directory. (screenshot needed)
  8. Edit->New Directory or press F10.
  9. Enter a name for the new sub-directory, Jan2004.
  10. In the same way create directories called Feb2004 and Mar2004.

These new directories will be displayed as icons. (screenshot needed)

You could, if you wish, enter these sub-directories and create another level of sub-directories within each.

  1. Work out a meaningful directory structure for your own needs.
  2. Create this structure using the method that has just been described.

Open a window to display directory/folder name, size, location on drive

Change the view mode

The default view in Konqueror displays only icons. There are other possible views on a directory.

  1. Click on Home and move up to the root level.
  2. View->View Mode->Tree View (screenshot needed). Note that there are a a number of different view mode options.
  3. Click on Home to expand the directory so that its contents will be displayed.
  4. Click on your own home directory.
  5. Click on the Letters sub-directory.
  6. You should see a display similar to the one on the screenshot.
  7. Click the Home icon.
  8. View->View Mode->->Detailed List View
This view will give you the most detailed listing of information on the contents of a directory.

(screenshot needed)

The following screen illustrates a directory containing a number of different types of files.

(screenshot needed)

This screen gives you full information on each file. The first four columns provide the basic information on file name, size, File Type and when the file was last Modified. As regards the Modified column, it is important that your clock and calendar settings are correct. If not, the information in this column will not be accurate.

Permissions

The permissions column provides information on access rights to the files and directories. Access rights refer to the permissions users have to perform various actions on files and directories.

Each file has an owner and a group associated with it. A group is a set of users collected together under a single group name. The permissions consist of three sets of three characters. The first three refer to the access rights of the owner, the second three of the group and the third set to all other users.

rwx
means read, write and execute rights.
r-x
means read and execute rights only, not write rights.
r--
means read only rights, not write or execute rights.
--x
means execute rights only, not read or write rights.
---
means no rights at all.

If a file has permissions given by rwxr-xr--, this means that the owner has rwx (read, write and execute) rights, the group has r-x (read and execute only) rights and all other users have r-- (read only) rights.

The owner and group associated with a file or directory are specified in the next two columns.

Owners, groups and permissions can be changed by users who have the necessary access rights to the files or directories.

Link: Linux allows you to create a symbolic link to a file in another directory. The link allows a file to be treated as if it is located in a directory while residing elsewhere. The link column sets out the details of symbolic links when appropriate.

Working with files

Abstract

Recognise common file types: word processing files, spreadsheet files, database files, presentation files, image files, audio files, video files, compressed files, temporary files.

One way of recognising different types of files is to use the Detailed List View in Konqueror, as illustrated in the previous section. Files can also be recognised by the extension on the file name. This is the part of the file name that follows the final full-stop. The following table illustrates some common file names and examples of each.

Extension Example Description
odt jamaica.odt A Writer text file.
ods opulationSA.ods A Calc spreadsheet file.
ott invoice.ott A template file that can be used as the basis for creating Writer text files.
odp client.odp An Impress presentation.
pdf contract.pdf A picture document format file. This format allows a file to be sent in a format that can only be read and not edited. To read such a file you would need a pdf reader.
htm, html index.html Htm and html files are files that can be read using a web browser.
txt notes.txt A text file containing plain text without any formatting.
rtf plans.rtf A rich text format file. This is a format that can be used for exchanging files between different types of system.
doc jamaica.doc A Microsoft Word document.
xls populationSA.xls A Microsoft Excel spreadsheet file.
ppt, pps client.ppt A Microsoft PowerPoint presentation file.
mdb vendors.mdb A Microsoft Access database file.
zip install.zip A compressed file in zip format.
gz install.gz A compressed file in gzip format.
tar oo-137.i586.tar A tarball file. tar files are used for creating installation packages.
deb 00-137.i586.deb A Debian Package Manager File. deb files are used for creating installation packages.
png sky.png A common format for storing graphic images.
jpg, jpeg sky.jpg A common format for storing graphic images.
tif sky.tif A common format for storing graphic images.
gif sky.gif A common format for storing graphic images.
wav trumpet.wav An audio file
au trumpet.au An audio file.
mpg concert.mpg A video file.
avi concert.avi A video file.
tmp ws0001.tmp A temporary file.

Extensions are a Microsoft Windows concept and are not actually needed in Linux. They are however useful in providing information for users about the contents or format of files.

Count the number of files, files of a particular type, in a folder (including any files in sub-folders)

Count total number of files and sub-directories in a directory

When you access a directory with Konqueror using icon mode, the status bar at the bottom indicates the number of files and directories in the current directory. (sceenshot needed)

However, these figures only count what is in the current directory and not what is in the sub-directories.

To get full information on a directory and its sub-directories:

  1. Click Home.
  2. View->View Mode->Tree View
  3. Click on the directory you wish to analyse.
  4. Expand all the sub-directories you wish to include. You will also need to expand sub-directories within these.

This is illustrated on the following screen.

(screenshot needed)

http://www.mepislovers-wiki.org/images/c/cc/Note.png The status bar at the bottom summarises what can be seen on the screen. The totals exclude the contents of directories that have not been expanded.

Count files of a particular type

Suppose you wish to find the total number of files ending in doc in the sub-directory Letters in your home directory.

  1. Start Applications->Applications->File Tools->Find Files.
  2. Click the Browse button.
  3. Select the Letters sub-directory and click OK.
  4. Enter *doc in the Named window. This means the files and directories can start with any number of letters but must end with the letters doc. If you had entered *.doc, the files located would end in the last four letters. If, for example, the directory contained a file called mydoc, it would be included in the first count but not the second. If you wished to count the number of files and directories starting with the letters le, you would enter le* into the window. (screenshot needed)
  5. Check Include subdirectories.
  6. Uncheck Case sensitive search.
  7. Click OK.

The files that satisfy the search specification will be displayed together with their location. The status bar at the bottom of the screen will display the count of the files.

Change file status: read-only/locked, read-write

The permissions associated with files and directories in the section called "Open a window to display directory/folder name, size, location on drive

Change permissions on a directory

In this example you will create a sub-directory in your home directory called Common. You will then give users access to change the contents of this directory.

  1. Click Home.
  2. Edit->New Directory or press F10.
  3. Create a directory called Common.
  4. Right click on Common and select Properties in the context menu.
  5. Click the Permissions tab. (screenshot needed)
  6. Make sure that Show Entries, Write Entries and Enter are checked for all three Classes.
  7. Check Apply changes to all subdirectories and their contents.
  8. Click OK.

Change permissions on a file

By default, Linux locks access to files so that they cannot be changed by anyone other than the owner or members of the group.

  1. Open Konqueror and locate the file whose permissions you wish to view or change.
  2. Right click on the file and select Properties in the Context menu.
  3. Click the Permissions tab. The current permissions will be checked. (screenshot needed)
  4. Add or remove check marks to set the desired permissions.
  5. Click OK.

Sort files by name, size, type, date modified

Files can be sorted by name, type, size and date by clicking on the titles at the top of the pane.

  1. Open application and access the directory you wish to sort.
  2. Click on Name. This will sort the files in ascending alphabetic order by name.
  3. Click on Name a second time. This will now sort the files in descending order of name.

When you sort files, the directories will appear ahead of the files. Directories and files will be sorted separately.

  1. Click Modified. This will sort the files in date order starting with the most recent.
  2. Click Modified a second time. This will now sort them with the oldest appearing first.
  3. Click Size. This will sort the files in order of size with the largest at the top.
  4. Click Size a second time. This will sort them in the reverse order of size.
  5. Click File Type. This will sort the files alphabetically by type.
  6. Click File Type a second time. This will sort them by type in the reverse order.

Understand the importance of maintaining correct file extensions when re-naming files

The part of a file name following the final full stop (period) is called the file extension. This often has a special significance which will be lost if it is changed. For example, the system will recognise that a file having a pdf extension can be opened with a pdf reader or that a file with a png extension is a graphic image.

Some files in Linux may have more than one full stop. Each of these separates a different part of the file name which may be of special significance to the application that will open it. If you do change a file name, only change the part that is to the left of the first full stop.

For example, in the file name kdbg-1.2.8-2.i586.deb, the deb extension means that this is a file containing installation files that can be managed with a package manager such as Synaptic or Kpackage. The i586 component means that this package is designed to run on a Pentium processor. Changing either of these would cause problems if you tried to install the package from the file.

Re-name files, directories/folders

Rename a file

  1. In a Konqueror window, right click on the icon of the file you wish to display a context menu and click Rename or press F2 or click on the label below the icon. (screenshot needed)
  2. This will open a small window around the name of the file.
  3. Edit the name. Keep in mind the need to preserve the extension.
  4. Click outside of the name when done.

Rename a directory

The process is the same as that for a file.

Duplicate, move

Abstract

Select a file, directory/folder individually or as a group of adjacent or non-adjacent files and/or directories/folders.

Before you can performs actions on files such as move, copy or delete you need to select (highlight) them.

Select a single file or directory

  • Click on the icon of the file or directory. A blue highlight will appear round the name.

Select a group of adjacent files or directories

  1. Click on the icon of the first file in the list.
  2. Hold down the Shift key and click on the icon of last file in the list. All the files between the two will also be selected.

Select a group of non-adjacent files or directories

  1. Click on the icon of the first file in the list.
  2. Hold down the Ctrl key and click on the icons of each of the files you wish to select.

Duplicate files, directories/folders between directories/folders and between drives

  1. Open Konqueror and select the files or directories you wish to duplicate. These can include both directories and files.
  2. Edit->Copy.
  3. Navigate to the directory in which to wish to duplicate the files and directories.
  4. Edit->Paste

Move files, directories/folders between directories/folders and drives

  1. Open Konqueror and select the files or directories you wish to move. These can include both directories and files.
  2. Edit->Cut.
  3. Navigate to the directory in which to wish to duplicate the files and directories.
  4. Edit->Paste.

Importance of backups

Abstract

Understand why making a ‘backup’ copy of files to a removable storage device is important.

There are many things that can cause loss of files. These include:

  1. Mechanical failure of a hard drive.
  2. Damage to the system due to natural disasters such as fire, floods and earth movement.
  3. Theft of the system.
  4. Corruption of data due to computer viruses.
  5. Deliberate corruption or deletion of data through criminal activity.

In order to protect data, it is important that copies of important files are made and kept in a separate location so that if loss occurs to the main system, data can be recovered from the copies. Copies of important files are referred to as backups.

Delete, Restore

Delete files, directories/folders to the recycle bin/wastebasket

  1. Select (highlight) the files you wish to delete.
  2. Edit->Move to Trash press the Delete key.
  3. Click Yes or Cancel when asked to confirm that you wish to move the files to Trash.
  4. If the Trash bin already contains files of the same name as those you are deleting, you will be warned and asked if you wish to overwrite the files.

Restore files, directories/folders from the recycle bin/wastebasket/trash

  1. Double click on the Trash icon on the desktop OR click Home and navigate to the Desktop folder in your home directory. From there navigate to Trash.
  2. Select the files you wish to restore.
  3. Edit->Move.
  4. Navigate to the folder in which you wish to restore the files.
  5. Edit->Paste.

To restore a file immediately after deleting it:

  • Edit->Undo: Move or press Ctrl-Z to undo the action.

Empty the recycle bin/wastebasket

With time Trash will accumulate hundreds of files. Rather than waste space, empty Trash on a regular basis.

  1. Right click on the Trash icon on the desktop OR navigate to the Desktop sub-directory of your home directory and right click on the Trash icon.
  2. Click Empty Trash Bin in the context menu.

Searching

Abstract

Use the Find tool to locate a file, directory/folder.

Find files

  1. Start Applications->Applications->Find Files/Folders.
  2. Click the Name/Location tab.
  3. Click the Browse button and navigate to the directory in which you wish to search.
  4. Make sure Subdirectories is checked if you wish to search through all sub-directories with the current directory.
  5. Specify whether you wish the search to be case sensitive or not. Usually it is best to leave this option unchecked.
  6. Enter the name of the file.
  7. Click Find.

In searching for files, the wildcard character, *, plays a very useful role. * represents any number of characters.

For example:

  • doc* means any file with a name beginning with the letters doc.
    • doc means any file with a name ending with the letters doc.
    • doc* means any file containing the letters doc in its name.

A specific example:

  1. Start Applications->Applications->Find Files/Folders.
  2. Click the Name/Location tab.
  3. Click the Browse button and navigate to /etc.
  4. Enter *ie* in the Name window. (screenshot needed)
  5. Click Find. All the files which have the letters ie in their file names will be displayed together with their locations. The number of files that satisfy the search criterion will be displayed in the status bar at the bottom of the window.
  6. Click Close when done.

Search for files by content, date modified, date created, size, wildcards

Search for a file containing text

The previous example searched for a file containing text in its file name. It is also possible for the Find command to look inside files for text.

  1. Start Applications->Applications->File Tools->Find Files
  2. Click the Name/Location tab.
  3. Clear any contents in the Named window or the search will be limited to looking only in files whose names satisfy that criterion.
  4. Click the Browse button and navigate to the directory in which you wish to search.
  5. Click the Contents tab.
  6. Type text that you are searching for in the Containing text window.
  7. Click Find. The following screen illustrates the results of such a search. Entries starting with a full stop (.) in the In Subdirectory column are hidden directories or files. (screenshot needed)
  8. Click Close when done.

Search for files by date

  1. Start Applications->Applications->File Tools->Find Files
  2. Click the Name/Location tab. Clear any contents in the Named window or the search will be limited to looking only in files whose names satisfy that criterion.
  3. Browse to the location at which you wish to begin the search.
  4. Click the Contents tab. Clear any contents in Containing Text window.
  5. Click the Properties tab. (screenshot needed)
  6. Check Find all files created or modified.
  7. Check Between and specify a start and an end date.
  8. Click Find.
  9. Click Close when done.

Search for files by size

  1. Start Applications->Applications->File Tools->Find Files
  2. Click the Name/Location tab. Clear any contents in the Named window or the search will be limited to looking only in files whose names satisfy that criterion.
  3. Browse to the location at which you wish to begin the search.
  4. Click the Contents tab. Clear any contents in Containing Text window.
  5. Click the Properties tab. (screenshot needed)
  6. Next to File size is, click the drop-down menu, mark none and select At least or At most. Enter a value. In the last drop-down menu, select Bytes, Kb or Mb.
  7. Click Find.
  8. Click Close when done.

View list of recently used files

  1. Start Applications->Applications->File Tools->Find Files.
  2. Click the Name/Location tab. Clear any contents in the Named window or the search will be limited to looking only in files whose names satisfy that criterion.
  3. Browse to the location at which you wish to begin the search.
  4. Click the Contents tab. Clear any contents in the Containing Text window.
  5. Click the Properties tab. (screenshot needed)
  6. Check Find all files created or modified.
  7. Check During the previous and specify a value and interval (hours, days, months, years).
  8. Click Find.
  9. Click Close when done.

http://www.mepislovers-wiki.org/images/c/cc/Note.png You can specify the File type in the Contents tab.

The default is Files and Directories. By selecting Files or Directories or one of the other options, you can restrict the search to looking only for files of a particular type. (screenshot needed)

Compressing files

Abstract

Understand what file compression means.

Each file has a size associated with it. Roughly speaking the amount of space a file occupies of disk is about the same as its file size. In reality, it takes up somewhat more space than this. When files are stored on a CD or transmitted across the Internet, it is important to the amount of disk space they occupy. Special algorithms (methods) have been developed to compress files into smaller sizes.

Sometimes a number of files are compressed into a single file while at other times a single file may be compressed. A compressed file can be recognised by its extension. The most common formats are zip, rar, gz, deb and tar.

There are numerous utilities that enable you to work with compressed files. The next two examples will illustrate the use of Ark.

Compress files in a folder on a drive

  1. Start Applications->Applications->Archiving->Compression->Ark.
  2. File->New.
  3. Navigate to the directory in which you will store the archive. To save to a floppy disk, navigate to /mnt/floppy.
  4. In the Location window, enter a file name and an extension indicating the type. For example, tar, zip or gz. This displays the Ark interface.
  5. Click Save. This will return you to the Ark interface.
  6. Action->Add File or click the icon .
  7. Navigate to the directory in which the file is located and double click on the file. Alternatively, if you wish to select more than one file from a directory, select them as you would select multiple files and click OK.
  8. Repeat until all the files have been added.
  9. Action->Add Directory if you wish to select entire directories.
  10. If you wish to delete a file, right click on it and select Delete in the context menu. (screenshot needed) At this point your screen will look something like the following: (screenshot needed)
  11. File->Close or File->Quit will automatically save the archive. Close closes the current archive but leaves the Ark interface displayed. Quit closes both the current archive and the application.

Add files to an existing archive

  1. Start Applications->Applications->Archiving->Compression->Ark.
  2. File->Open.
  3. Navigate to the archive you wish to open, select it and click OK. The files contained in the archive will be listed.
  4. Action->Add File or Action->Add directory to add additional files to the archive.
  5. To save the archive under a new name use File->Save As. Otherwise use File->Close or File->Quit.

Extract compressed files from a location on a drive

  1. Start Applications->Applications->Archiving->Compression->Ark.
  2. File->Open.
  3. Navigate to the archive you wish to open, select it and click OK. The files contained in the archive will be listed.
  4. Action->Extract.
  5. Click the navigate icon and navigate to the directory in which you wish to extract the files. (screenshot needed)
  6. Click OK.
  7. The path of the target directory is inserted into the Extract to window. If you had known the full path of the target directory, you could have typed it in manually. (screenshot needed)
  8. Click OK.
  9. Click Home and navigate to the target directory to verify that the files have been extracted.
Personal tools