Main Content
Where am I and how did I get here? Archive - Originally posted on "The Horse's Mouth" - 2007-07-05 18:19:44 - Graham Ellis
When you as "which directory am I in" with the pwd command, are you told the real directory you are in, or the one you cd'd into? You are normally tod the one you've cd'd to.
What's the difference? you may ask The difference is that you might want to find out where you really are on the file system (not with symbolic links) or how you got where you are (with symbolic links)
[trainee@daffodil webapps]$ pwd
/usr/local/tomcat/webapps
[trainee@daffodil webapps]$ pwd -P
/usr/local/jakarta-tomcat-5.5.9/webapps
[trainee@daffodil webapps]$ pwd -L
/usr/local/tomcat/webapps
[trainee@daffodil webapps]$
The -L option on pwd tells you the directory that you're in following links, and the -P option tells you where you really are. Note that these are the bash built in parameters; other shell's pwd commands may differ
Some other articles
A101 - Linux -An Introduction For Users Packing a tar, jar or war file - best practise The Kernel, Shells and Daemons. Greek Gods in computing Displaying a directory or file system tree - Linux Oops - I typed ci not vi, and have lost my file ... Recording (a macro) in vi Linux - useful tips including history and file name completion Making Linux Politically correct Accidentally typed ci rather than vi? What does x on a linux directory mean? How much space does my directory take - Linux Always use su with minus. And where do programs come from? Running straight from the jar, but not from a tar Ruby, Perl, Linux, MySQL - some training notes sstrwxrwxrwx - Unix and Linux file permissions Keeping on an even keel Some Linux and Unix tips FTP passive mode - a sometimes cure for upload hangs Yank and Push - copy and move in vi ls command - favourite options Selecting file names in a shell - one word or another Copy and paste / cut and paste and other vi techniques Wireless hotel tips - FTP and Skype connections failing awk - a powerful data extraction and manipulation tool Linux run states, shell special commands, and directory structures Work and play at Well House Manor - Football and Shell Shortcuts This article ls -l report, Linux / Unix - types and permssions Copy multiple files - confusing error message from cp Moving files between Windows / DOS and Linux / Unix Cardinal numbers and magic numbers Cottage industry or production line data handling methods THE home directory or MY home directory Linux training Glasgow, Python programming course Dundee Copying files and preserving ownership More or less on the edge of the page Web Application Components Finding where the disc space has gone File permissions of Linux and Unix systems Linux commands - some basics An easy way out Aladdin, or careful what you wish. pushd and popd vi - full circle