Linux/Unix – Handling directories.

Changing Directories

Use cd to change the current working directory; give the name of the new directory as an argument. To change the current working directory to `work’, a subdirectory in the current directory, type: $ cd work

To change to the current directory’s parent directory, type: $ cd ..

You can also give the full path name of a directory. To change the current working directory to `/usr/doc’, type: $ cd /usr/doc

This command makes `/usr/doc’ the current working directory.

 

Changing to Your Home Directory

With no arguments, cd makes your home directory the current working directory. To make your home directory the current working directory, type: $ cd

 

Changing to the Last Directory You Visited

To return to the last directory you were in, use cd and give `−’ as the directory name. For example, if you are in the `/home/mrs/work/samples’ directory, and you use cd to change to some other directory, then at any point while you are in this other directory you can type cd − to return the current working directory to `/home/mrs/work/samples’.

To return to the directory you were last in, type: $ cd –

 

Getting the Name of the Current Directory

To determine what the current working directory is, use pwd (“print working directory”), which lists the full path name of the current working directory. To determine what the current working directory is, type:

$ pwd

/home/mrs

In this example, pwd output the text `/home/mrs’, indicating that the current working directory is `/home/mrs’.

Advertisements

About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on March 15, 2009, in Unix/Linux and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: