Go to the Going Linux home page
Going Linux

The Podcast
Receive new episodes automatically.
Subscribe for free:
Copy and paste this link into your podcatcher to subscribe to the mp3 feed mp3 feed
Copy and paste this link into your podcatcher to subscribe to the ogg feed ogg  feed

Subscribe via iTunes

Creative Commons License
This work
is licensed under a
Creative Commons Attribution 3.0 License.


Going Linux
Practical Information for Using Linux To Get Things Done
 Home Tab  Show Notes Tab  Articles Tab  Screencasts Tab  About Us Tab  
Linux Concepts - Files
(By Paul Hardy)

If you have used MS Windows you will be pretty familiar with files. This article will help you understand the concept of files. It will also mean that you won't need to start from scratch.

However, you will need to relearn a few concepts to work in Linux. It won't matter which version of Linux you will be using. There are several great things you can do with Linux files that you can't do using MS Windows -- or can't do easily. This may make switching to Linux a good choice.

Files have unique names

This rule is not quite as simple as it seems. There will be no conflict between a file called myfile on the hard-drive and a file called myfile on your CD Rom. You may have two files named myfile on your hard drive, but in different directories. A critical point to remember here is to always backup important files, no matter what the file name, or the operating system you choose to use. This will save you a lot of time later if your files become corrupted or deleted by mistake. I know everyone says that, "It won't happen to me," but this can, and does, happen. From experience, it will always happen at the worst possible minute. If and when this happens, you will be vary glad you took the time to make backup copy's of those files.

Top

Directories

If you think of your hard drive as a filing cabinet, a directory as a folder in that cabinet, and files as pages then each folder (directory) may hold several pages (files) in it.

Linux is case sensitive, this means that Linux distinguishes between a file named Myfile and a file named myfile.  In MS Windows a Myfile and myfile are treated the same, but in Linux they are not. If you are a windows user you will need to change to this idea. It takes a little getting used to -- more so if you have used MS Windows for any length of time.

Try to keep your file names short but meaningful. The maximum length is 255 characters, however working with long file names is no fun at all, and may actually cause a problem later on. Linux file names may not contain the character "/" which has special meaning.

To help avoid problems don't use special characters such as "$" and "&" in file names. These may lead to problems with errors, and also confusion. Also don't call your files by names reserved for use by Linux itself, such as "etc".

Sometimes Linux applies file extensions, for example ".c" to indicate the C-language program and ".htm" or ".html" to show that the file is a web document. Users often avoid using extensions and rely on the file directory to indicate the type of file. Try not to give Linux a misleading file extension.

Use a text editor to create or modify text files. This article was created using gedit, but Linux has several text editor such as vi, and Emacs, and many more can be downloaded for free. 

Top

File Commands

Linux provides a large selection of commands that can be used for processing files. A lot of these commands are in a form that will help you to remember them. For example cp is used to copy files.

A lot of the commands include a wide choice of options. Lets take the ls command. This command is similar to the dir command in MS Windows. It is a simple command, but if you check out the man pages for the ls command, it offers loads of options to make this simple command a powerful one and a lot of these options are not available to MS Windows users with dir.

If you think of Linux commands as an English sentence, you can have more than one verb. A Linux command can have more than one object. Commands contain the command itself, and one or more options. For example, if we wanted to copy our file myfile we not only need to specify cp but we also need to tell it what and where. For example:

cp myfile backup/ 

This means: copy the file myfile to the backup folder.

The Linux command syntax (grammar rules) is strict, and will take some time and practice to learn.

Author: Paul Hardy
Originally posted on the Going Linux website: http://goinglinux.com/articles/LinuxConcepts-Files.html

Paul has granted you the right to reprint this article, but the title and content (including this notice) must remain unchanged and the author's name and contact information must be included.

Top
Search our audio files



Search our site

Google



Updated 15-Oct-2008 Valid HTML 4.01 Transitional Valid CSS! An interoperable Web page