 |
|
Oracle Tips by Burleson |
Directory Commands
What directory am I currently in?
This is one of the many frequent questions that you may have
when using Linux. The directory that you are currently in is
referred to as the ‘working directory’ and can be displayed
using the pwd command (print working directory). The pwd
command displays the fully qualified path name for the current
working directory as demonstrated here:
$ pwd
/home/tclark
In order to eliminate the need to frequently issue the pwd
command to determine your current working directory, many
Linux users choose to display the working directory within the
Linux command prompt.
Some Linux administrators even provide this service for you
when they create your Linux account. If your command
prompt does not contain the working directory, you can
modify the command prompt by changing the PS1 (prompt
string 1) shell variable as demonstrated here:
$
$ PS1="[\u@\h \W]\\$ "
[tclark@appsvr tclark]$
In order to avoid having to modify the prompt each time you
login, you can place the following line of code within the
appropriate .profile file (i.e. .bash_profile for the bash shell)
within your home directory:
export PS1="[\u@\h \W]\\$ "
You’ll notice that user name (\u) and host name (\h) were also
included in the prompt strings specified above. The following
is a list of values that can be displayed within the PS1 and/or
PS2 prompt strings:
Symbo
l
Displayed Value
\!
history number of current
command
\#
command number of current
command
\d
current date
\h
host name
\n
newline
\s
shell name
\t
current time
\u
user name
\W
current working directory
\w
current working directory (full
path)
The above book excerpt is from:
Easy Linux
Commands
Working Examples of Linux Command Syntax
ISBN:
0-9759135-0-6
Terry Clark
http://www.rampant-books.com/book_2005_1_linux_commands.htm |