Installation guide

Chapter 12. Managing Files and Directories 129
This command creates an archive file and then compresses it as the file filename.tbz. If you un-
compress the filename.tbz file with the bunzip2 command, the filename.tbz file is removed
and replaced with filename.tar.
You can also expand and unarchive a bzip tar file in one command:
tar -xjvf filename.tbz
To create a tarred and gunzipped compressed file, use the -z option:
tar -czvf filename.tgz
tar files compressed with gzip are conventionally given the extension .tgz.
This command creates the archive file filename.tar and then compresses it as the file file-
name.tgz. (The file filename.tar is not saved.) If you uncompress the filename.tgz file with
the gunzip command, the filename.tgz file is removed and replaced with filename.tar.
You can expand a gzip tar file in one command:
tar -xzvf filename.tgz
Tip
Type the command man tar to read the man page for the tar command.
12.4. Manipulating Files at a Shell Prompt
Files can be manipulated quite easily using one of the graphical managers such as Nautilus and
Konqueror. They can also be manipulated using a shell prompt; this is often faster. This section
explains how.
12.4.1. Creating Files
You can create new files either with applications (such as text editors) or by using the command
touch, which will create an empty file that you can use to add text or data. To create a file with
touch, type the following at a shell prompt:
touch
filename
replacing filename with the name of your choice. You will see if you run a directory listing
that the file contains zero (0) bytes of information because it is an empty file.
[sam@halloween]ls -l newfile
-rw-rw-r-- 1 sam sam 0 Apr 10 17:09 newfile
12.4.2. Copying Files
Like so many other Linux features, there is a variety of ways to manipulate files and directories. You
can also use wildcards, as explained in Section 11.11.5, to make the process of copying, moving, or
deleting multiple files and directories faster.