CIS Header Left CIS Header Center
C-2-100 Mackinac Hall
1 Campus Drive
Allendale, MI 49401

Phone:616-331-2060
Fax:616-331-2106
email: info@cis.gvsu.edu


ABET Accredited Symbol

The Computer Science and Information Systems programs are accredited by the Computing Accreditation Commission of ABET.
Find us on Facebook

Find us on Twitter
Filesystem Basics

Index->Filesystem Basics

Filesystem Basics

Overview and Goals

At the completion of this lab, you will be able to...

  1. Determine the type of a file.
  2. Create a symbolic link.
  3. Use wildcards to select multiple files.
  4. Access USB Flash Drives.

The following utilities are used in this lab: file(1), ln(1), mount(2), umount(2), mkdosfs(8)

Determining a File's Type

Because Linux does not have any pre-defined format for filenames, it is sometimes difficult to determine what application created a file. For example, a filename of "jobs" doesn't tell you much.

Linux has a nice utility that can help you determine where a file came from. The utility is file(1). Typing "file filename" will usually tell you what kind of file it is.

Try typing "file /etc/localtime". What kind of file is it?

Creating Symbolic Links

There are seven different types of files in Linux, only a few of which you will come into regular contact: (1) regular/text files, (2) directories, and (3) symbolic links. The other four file types are special system files. We've already seen two of these three. This section looks at the third.

A symbolic link is a shortcut create in the filesystem. If you're familiar with Windows "shortcuts", it's the same idea. Symbolic links (or just "links") provides convenient access to a file that may live a long way off in the file system.

For example, say from your home directory, you are always accessing the file /usr/java/j2sdk_1.4.2/demo/applets/Blink/example1.html. Every time you have to access that file, you have to type in it's entire pathname. This will get very annoying. The solution is to create a symbolic link.

To create the symbolic link, type "ln -s /usr/java/j2sdk_1.4.2/demo/applets/Blink/example1.html". This will create a file in your current working directory called example1.html. However, you local file is not a copy of the original, it is a link to it. Try running file on it.

Now that the symbolic link is created, you can access example1.html by just giving the short name. For example "cat example1.html".

You can remove symbolic links with the rm command, just as you would remove any other file. Try "rm example1.html". This will remove the symbolic link, not the original file.

Filename Wildcards

Wildcards allow you to select multiple files based on a pattern that you create. For example, you might want to run a command on all the Java files in the current directory. If there are lots of files, typing all of their names individually is not practical. Wildcards are the solution.

A wildcard is a path/filename that uses at least one special wildcard character. The wildcard characters are:

  1. * matches any string, including the empty string
  2. ? matches any single character
  3. [...] matches any character listed in the brackets

Here are some examples:

  • "*.java" matches all files that begin with any string (including the empty string), and end with ".java"
  • "??.o" matches all files that start with any two characters, followed by ".o"
  • "A*.[oc]" matches all files that begin with a capital 'A', followed by anything, followed by ".", followed by either "o" or "c"
  • "[a-z]*a" matches all files that begin with a lower case letter, followed by anything, followed by an "a"

Accessing USB Flash Drives

Our final topic is how to access a USB Flash Drive. The EOS machines are configured to automatically mount drives. This is not necessarily the case on all Linux systems. Follow these instructions:

  1. Insert the USB drive into the USB port on the front (or side) of the computer. Do not attempt to access the back side of the computer.
  2. Wait approximately 3-5 seconds for the OS to recognize the USB drive.
  3. Files on the USB drive can now be accessed in the /media/usbdisk directory. Simply unplug the USB drive when finished. WARNING! When you unplug the drive, all open programs on the USB drive will be terminated.

Questions

Turn in your answers to the following questions.

  1. Try both of these commands "file /root" and "file -b /root". How does the "-b" option change the output of the file command?
  2. Show the output generated by each of the following commands:
    • file -b /lab/web/htdocs/Images/CISHeaderLeft.jpg
    • ls -l /boot/vmlinuz
    • file -b /boot/vmlinuz
    • ls -l /boot/vmlinuz-2*
    • file -b /boot/vmlinuz-2*
  3. Explain what is a wildcard character?
  4. Assume the following files/directories are in the working directory:
    index.html  lab1         lab2       netcheck.c   netcheck.java 
    netcheck.o  network.dia  output.ps  overview.ps  mops        
    runme       tellme
    
    Give commands for each of the following (using wildcards to express filename and as few characters as possible)
    • List all files that begin with "netcheck".
    • List all files that end with "me".
    • List the lab1, lab2, netcheck.c, and netcheck.o files
    • List only the ".ps" files
    • List only files that has "e"
  5. Describe the file names that can match the following wildcard: "[c-i]*.htm"?

Top

This page was last modified October 05 2007.
Send comments to the CIS School Webmaster.
Copyright ©1995 - 2009 Grand Valley State University.
GVSU is an Equal Opportunity/Affirmative Action Institution.