eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to UNIX for Web Developers
The "ls" Utility (And Hidden Files)  
Wow, so now you are zipping all about the file system. However, you still can't do much in any of the directories you move to until you have some means of reading the contents of the directories you have moved to.

To get a directory listing, you will use the "ls" utility which follows the rules described in the table below:

Syntax Example Description
ls options filelist. ls -l /home/selena/public_html/*.html Lists the specified contents of the specified directory according to the options setting.

The options for the "ls" command are described in the table below:

Option Description
-A Lists "ALL" files (including hidden ones) but not the current or parent directories ("." or "..").
-a Lists "ALL" files including hidden ones and both current and parent directories ("." and "..").
-C Lists files in columns sorted from top to bottom, left to right.
-d lists directory names only. This is very useful since "ls directory_name" will give you the listing of that directory rather than showing you if the named directory is actually in the current.
-F Adds a "/" for directories and a "*" for executables.
-i Lists the inode number.
-l Provides a "long" listing with details about such things as file permission, age, date created, date of last modification, etc.
-r Reverses the sort order.
-R Lists sub-directories recursively.
-x Lists files in columns sorted from left to right then top to bottom.

Here are some examples of using the "ls" command. Note that you can use multiple options at one time by simply adding them to the option list.

[Spacer] [LS Command Example]

[Spacer] Hidden Files
Notice in the example above, the ls command turned up quite a different file list than the ls -a even though they were listing the same directory. This is because the ls -a command lists hidden files as well as normal files.

A Hidden File is a file whose name begins with a period. These files are usually administrative files and are often distracting when you are doing your daily work. Thus UNIX hides them unless you specifically ask to see them with the -a option

Okay, here are some more examples of the ls utility

[Spacer] [LS Command Example 2]

[Spacer]

Now you practice using the "ls" utility in some of the directories you moved to in the last section.

Focus on the "-l" Option
Before moving on, we should say a little bit more about the "-l" option because you will find yourself using this one quite a bit when you want to know more information about the files and directories in a listing.

The image below shows a typical "-l" listing. In the image you will see that there are several fields listed for each file.

[Spacer] [LS -l Command Example]

[Spacer]
The following table overviews the information provided by the -l option...

Column Description
File Type Is this a regular file or a directory. "-" denotes a regular file, "d" denotes a directory, "c" denotes a character special file, a "b" specifies a block special file, a "l" represents a symbolic link, and a "p" specified a named pipe.
Permissions User, Group and World privileges. We will discuss this in much greater detail in just a moment
Link Count The number of names for this file or directory
Owner We will discuss this later
Group We will discuss this later
Size The size of the file in bytes
Modification Date The last time the file was modified
File name The name of the UNIX Version. No just kidding. The file's name

The ls -l option also includes several options that affect the listing. These options are shown below:

Option Description
-c Sorts by the last time the inode was changed with the -t option
-t Sorts listing by modification time.
-u Sorts by the last time accessed.

Previous | Next | Table of Contents