Sie sind auf Seite 1von 2

A hidden file on Linux is a file that has a name that starts with a dot.

Try
the following: touch .hidden . Next, type ls . You will not see it. Then type ls -a .
Youll see it.

So, to copy an exact state of your home directory and everything within it to the /tmp directory, use
cp -a ~ /tmp .

cp /somedir/.* /tmp This copies all files that have a name starting with a
dot (the hidden files, that is) to /tmp. It gives an error message for directories
whose name starts with a dot in /somedir, because the -R option was not used.
cp -a /somedir/ . This copies the entire directory /somedir, including its
contents, to the current directory. So, as a result, a subdirectory somedir will
be created in the current directory.
cp -a /somedir/. . This copies all files, regular and hidden, to the current
directory.

In Listing 3.4 , the command that was used is \ ls -l , not ls -l . The ls com-
mand by default is an alias, which takes care of using the different colors when
showing ls output; the \ in front of the command causes the alias not to be used.

Removing links

IF YOU HAVE A TWO ARCHIVE WITH A LINK <original_file> <link_file> AND YOU
WANT TO DELETE THE LINK FILE SO, YOU SHOULD DO rm <link_file> BECAUSE
IF YOU USE rm -rf <link_file> YOU WILL REMOVE THE <original_file>

1. Make a directory test in your home directory: mkdir ~/test .


2. Copy all files that have a name starting with a, b, c, d, or e from /etc to this
directory: cp /etc/[a-e]* ~/test .
3. Make sure that you are in your home directory, by using cd without
arguments.
4. Type ln -s test link .
5. Use rm link . This removes the link. (Do not use -r or -f to remove links, even
if they are subdirectories.)
6. Type ls -l . Youll see that the symbolic link has been removed.
7. Lets do it again. Type ln -s test link to create the link again.
8. Type rm -rf link/ (which is what you would get by using bash command line
completion)
9. Type ls . Youll see that the directory link still exists.
10. Type ls test/ Youll see the directory test is now empty.

Use the option -C /targetdir to specify the target directory where you want to
extract the file in. If you want to put the contents of the file /root/homes.tar in
the directory /tmp, for instance, you can use tar -xvf homes.tar -C /tmp .

Using Compression
Many files contain a lot of redundancy. Compression programs allow you to make
files take less disk space by taking out that redundancy. In all examples of the tar
command that you have seen so far, not a single byte has been compressed. Origi-
nally, after creating the archive, it had to be compressed with a separate compression
utility, such as gzip or bzip2 . After having created home.tar, you can compress it

Think of it like this: You can have multiple terminals open on a console, but you cannot have mul-
tiple consoles open in one terminal.

tail -f /var/log/secure

Das könnte Ihnen auch gefallen