26.10.2012 Views

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

directory where you ran the command. To switch to a directory two levels higher than<br />

the current directory, enter cd ../... ls -l ../.. lists the contents <strong>of</strong> the directory<br />

two levels higher.<br />

Examples <strong>of</strong> Addressing a File<br />

The cd commands in Section 3.1.3, “Working with Directories and Files” (page 96)<br />

used relative paths. You can use also absolute paths. For example, suppose you want<br />

to copy a file from your home directory to a subdirectory <strong>of</strong> /tmp:<br />

1 First, from your home directory create a subdirectory in /tmp:<br />

a If your current directory is not your home directory, enter cd ~ to switch<br />

to it. From anywhere in the file system, you can reach your home directory<br />

by entering cd ~.<br />

b In your home directory, enter mkdir /tmp/test. mkdir stands for<br />

“make directory”. This command creates a new directory named test in<br />

the /tmp directory. In this case, use an absolute path to create the directory.<br />

c To check what happened, now enter ls -l /tmp. The new directory<br />

test should appear in the list <strong>of</strong> contents <strong>of</strong> the /tmp directory.<br />

2 Now create a new file in your home directory and copy it to the /tmp/test<br />

directory by using a relative path.<br />

a Enter touch myfile.txt. The touch command with the<br />

myfile.txt option creates a new, empty file named myfile.txt in<br />

your current directory.<br />

b Check this by entering ls -l. The new file should appear in the list <strong>of</strong><br />

contents.<br />

c Enter cp myfile.txt ../tmp/test. This copies myfile.txt to<br />

the directory /tmp/test without changing the name <strong>of</strong> the file.<br />

d Check this by entering ls -l /tmp/test. The file myfile.txt<br />

should appear in the list <strong>of</strong> contents for /tmp/test.<br />

Working with the Shell 97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!