Managing Files and Directories
Your desktop file manager is a powerful and important tool for managing files and directories using a graphical interface. This chapter discusses various shell prompt commands that can be used to manage files and directories on your Red Hat Linux system. This chapter also discusses compression tools to create archives of your files for backups, or to send to others conveniently.
Note
Due to system security, unless you are root, you will not be able to gain access to all system-level files and directories. If you do not have the permission to open, delete, or execute a file, you will receive an error message saying your access is denied. This is normal behavior and is used to prevent non-priveleged users from deleting important
system files.
12.1. A Larger Picture of the File System
Every operating system has a method of storing data in files and directories so that it can keep track of additions, modifications, and other changes. In Linux, every file is stored in a directory. Directories can also contain directories; these subdirectories can also contain files and other subdirectories. You might think of the file system as a tree-like structure, in which directories branch off . These directories may contain, or be the "parent" of, other directories which may hold files and directories of their own.
There would not be a tree without a root, and the same is true for the Linux file system. No matter how far away the directories branch, everything is connected to the root directory, which is represented as a single forward slash (/).
Tip
Red Hat Linux uses the term root in several different ways, which might be confusing to new users. There is the root account (the superuser, who has permission to do anything), the root account's home directory (/root) and the root directory for the entire file system (/). When you are speaking to someone and using the term root, be sure you know which root you are talking about. Unless you are a system administrator or have root (super user) access, you probably do not have permission to write to the files and directories outside of your home directory. Certain directories are reserved for specific purposes.
For example, /home is the default location for users' home directories.
Users that are not system administrators might find the following directories useful for finding their home directories, reading documentation, or storing temporary files.
Ø /home -- Default location for users' home directories. For example, a user with the username foo has the home directory /home/foo.
Ø /usr/share/doc -- Location of documentation for installed packages. For example, the documentation for the dateconfig software package is located in /usr/share/doc/dateconfig- <version-number>.
Ø /tmp -- The reserved directory for all users to store temporary files. Files stored here are not permanent. A system process removes old files from this directory on a periodic basis. Do not write any files or directories that you want to keep here.
Your Red Hat Linux system is compatible with many other Linux distributions because of the Filesystem Hierarchy Standard (FHS). The FHS guidelines help to standardize the way system programs and files are stored on all Linux systems.
To learn more about the FHS, refer to the Official Red Hat Linux Reference Guide Reference Guide.
You can also visit the FHS website: http://www.pathname.com/fhs.
12.2. Identifying and Working with File Types
If you are new to Linux, you may see files with extensions you do not recognize. A file's extension is the last part of a file's name after the final dot (in the file sneakers.txt, "txt" is that file's extension).
Here is a brief listing of file extensions and their meanings:
12.2.1. Compressed and Archived Files
Ø .bz2 -- a file compressed with bzip2
Ø .gz -- a file compressed with gzip
Ø .tar -- a file archived with tar (short for tape archive), known as a tar file.
Ø .tbz -- a tarred and bzipped file
Ø .tgz -- a tarred and gzipped file.
For information on working with bzip2, gzip, and tar files, refer to Section 12.3.
12.2.2. File Formats
Ø .au -- an audio file
Ø .gif -- a GIF image file
Ø .html/.htm -- an HTML file
Ø .jpg -- a JPEG image file
Ø .pdf -- an electronic image of a document; PDF stands for Portable
Document Format
Ø .png -- a PNG image file (short for Portable Network Graphic)
Ø .ps -- a PostScript file; formatted for printing
Ø .txt -- a plain ASCII text file
Ø .wav -- an audio file
Ø .xpm -- an image file
12.2.3. System Files
Ø .conf -- a configuration file
Ø .lock -- a lock file; determines whether a program or device is in use
Ø .rpm -- a Red Hat Package Manager file used to install software
12.2.4. Programming and Scripting Files
Ø .c -- a C program language source code file
Ø .cpp -- a C++ program language source code file
Ø .h -- a C or C++ program language header file
Ø .o -- a program object file
Ø .pl -- a Perl script
Ø .so -- a library file
Ø .tcl -- a TCL script
But file extensions are not always used, or used consistently. So what happens when a file does not have an extension, or the file does not seem to be what the extension says it is supposed to be? That is when the file command can be helpful.
For instance, you find a file called saturday without an extension. Using the file command, you can tell what type of file it is by typing:
file Saturday
In the example, the command file saturday will display ASCII text, telling you it is a text file. Any file that is designated as a text file should be readable using the cat, more, or less commands, or using a text editor.
Tip
To learn more about file, read the man page by typing man file.
For more information on helpful commands for reading files, see Chapter 11.
No comments:
Post a Comment