Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

NOTE: CentOS Enterprise Linux is built from the Red Hat Enterprise Linux source code. Other than logo and name changes CentOS Enterprise Linux is compatible with the equivalent Red Hat version. This document applies equally to both Red Hat and CentOS Enterprise Linux.

3.3. Managing Files

If you are new to Linux, file names may look strange to you. Linux file names may include extensions you haven't seen before, may have multiple extensions, or may not have any at all. File names may begin with a "." or may have other symbols in their names, including spaces. Below are some guidelines regarding file names in Linux.

3.3.1. File Types

Below are the most common file types in Red Hat Enterprise Linux.

3.3.1.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), also known as a tar file

  • .tbz or .tar.bz — a tarred and bzipped file

  • .tgz or .tar.gz — a tarred and gzipped file

  • .zip — a file compressed with ZIP compression, commonly found in MS-DOS applications; most compressed files for Linux use the gzip compression, so finding a .zip archive for Linux files is rare

For information on working with bzip2, gzip, and tar files, refer to Section 3.4 File Compression and Archiving.

3.3.1.2. File Formats

  • .au — an audio file

  • .gif — a GIF image file (short for Graphics Interchange Format)

  • .html or .htm — an HTML file (short for Hyper Text Markup Language)

  • .jpg — a JPEG image file (short for Joint Photographic Experts Group)

  • .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 (short for X Pixelmap)

3.3.1.3. System Files

  • .conf — a configuration file; configuration files sometimes use the .cfg extension, as well

  • .lock — a lock file; determines whether a program or device is in use

  • .rpm — a Red Hat Package Manager file used to install software

3.3.1.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

  • .py — a Python script

  • .so — a library file

  • .sh — a shell script

  • .tcl — a TCL script

3.3.2. Naming Conventions

3.3.2.1. Dot Files

Files whose name begins with a ".", called "dot" files, are hidden files. These files can be viewed in both graphical file managers like Nautilus and from the shell prompt, but require an extra step to reveal them. In Nautilus, select View => Show Hidden Files. From a shell prompt, list the files in your home directory by entering the command ls -al. If you view the hidden files in your home directory, you may be surprised by the number of files in what you thought was an empty directory. These hidden files are usually configuration files for applications. They are hidden to prevent accidental changes and to remove clutter from the user's home directory.

3.3.2.2. Using Spaces in File Names

While Linux allows file names with spaces in them, manipulating these files from a shell prompt can be quite cumbersome. The shell prompt expects a space to separate two files or commands, and may mis-interpret such a filename. To manipulate files with spaces in their names, surround the name with quotation marks.

3.3.2.3. Using Symbols in File Names

It is possible to use punctuation marks in your file names. However, be aware that these special characters have special meaning to the shell and may cause errors at a shell prompt. It is generally recommended that you avoid using special characters in file names for this reason. If you choose to use file names with special characters, use quotes around the file names when manipulating them from a shell prompt.

There are a few special characters you cannot use in file names. You cannot use a "/" — this indicates a directory. You cannot name a file "." or "..", for reasons discussed in Section 3.2.1 Paths.

3.3.2.4. Files with Multiple Extensions

Filenames can have multiple extensions. There may be a "." in the middle of a file name, or there may actually be multiple extensions. These multiple extensions usually arise when processing a file through multiple programs or commands. The most common file type with multiple extensions is a compressed archive. Compresed files are discussed in detail in Section 3.4 File Compression and Archiving.

3.3.3. Finding the Correct File Extension

File extensions are not always used, or used consistently. 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 example, you find a file called saturday without an extension. The file command enables you to see what type of file it is. Enter file saturday at a shell prompt. In this example, the command responds with ASCII text. Any file that is designated as a text file should be readable by using the cat, more, or less commands, or by using a text editor such as gedit or vi. Refer to Section 4.8 Viewing text files from the shell prompt for more information on cat, more, and less. Refer to Chapter 9 Working with Other Text Applications for more information on gedit and vi.

 
 
  Published under the terms of the GNU General Public License Design by Interspire