Hacker News new | past | comments | ask | show | jobs | submit login
The myriad meanings of pwd in Unix systems (qmacro.org)
69 points by quyleanh on Nov 10, 2020 | hide | past | favorite | 64 comments



The first thing to check when you disagree with a Wikipedia article (like "only serves here to undermine the credibility of the Wikipedia entry") is the "Talk Page" where discussions around the article arises. In this case, there is even an existing discussion around this very subject! The author would do good by participating directly in the editing community, rather than dismissing the article as a whole because of the disagreement.

https://en.wikipedia.org/wiki/Talk:Pwd#PWD_meaning.


While the article does end by stating that it doesn't really matter (which is true), I feel like deviated for silly reasons, and ended weird.

Specifically, a lot of the journey was based on the false assumption that manpages will explain abbreviations or naming decisions, and should contain the exact expand form of such deviations - an assumption especially silly for commands as ancient as these, whose names were chosen on a whim by the original authors who were known to be allergic to command names longer than 3 characters.

Finally, despite initial evidence suggesting "pwd" meaning "print working directory", and finally finding rather conclusive evidence for multics documentation showing that "pwd" is an abbreviation of an earlier "print_wdir", the conclusion ends up being "we'll never know for sure".

I don't know about you, but it seems like the author is in denial here.


It's already been said elsewhere in the thread, but Ken Thompson worked on MULTICS before he worked on UNIX.

And in Plan 9, also by Thompson et al, there's pwd and pbd, where pbd is described as "prints the base name of the working (current) directory."[0]

Three OS:es by the same guy(s) all have pwd, as abbreviated from "print" in the first one. So, yeah, it's "print".

[0] https://9p.io/magic/man2html/1/pwd


I had the same reaction. The multics find almost definitively proves it is "print working directory". You'd need a whole heap of other evidence to convince otherwise...


s/exact expand form of such deviations/exact expanded form of such abbreviations/


I don't like the abbreviation "pwd" at all, mainly because it looks too much like "password" which is also often abbreviated to "pwd". I prefer "cwd" which would unambiguously mean the Current Working Directory.

Thinking more about that though, "cd" in the shell universally means "change (the current working) directory" but can also possibly mean the "current directory" as well (and DOS/Windows "cd" without arguments does print the current working directory). Note that similar abbreviations like "md" and "rd" are not as universal, as they are "mkdir" and "rmdir" in *nixes (for the good reason).


DOS actually has "chdir" as another name for "cd".

And of course, the POSIX interface for changing and querying the working directory are wonderfully consistently named chdir and getwd (or getcwd, where "c" stands for something).


Anncient Unix also had chdir as the command name for cd. If I'm not mistaken it was changed to cd for v7 with the Bourne shell replacing the previous shell.


Wouldn't `setwd` (used by R alongside `getwd`) be a more consistent name?


Well, if we ever rewrite Unix, we can just go with "wd".

Because we know it's reading the current or present value, like any other command that reads a value.

And of course we're going to print it, that's the natural thing to do.


They sort of did rewrite Unix and it's called pwd there, too. :)

https://9p.io/magic/man2html/1/pwd


> if we ever rewrite Unix, we can just go with "wd"

Thus confusing anyone who uses the 'wd' hard disk driver.

https://man.openbsd.org/wd


Yes when reading the title I thought of <pwd.h> for reading passwd rather than of the command/variable. Also it's already called cwd in other places (like in /proc, at least on Linux) so that would be more consistent.


The 4.3 BSD source code has a comment up pretty high in the source that says:

"Print working (current) directory"

https://github.com/abs0/4.3BSD-Quasijarus/blob/main/bin/pwd....

And the manpage says:

"prints the pathname of the working (current) directory"

https://github.com/abs0/4.3BSD-Quasijarus/blob/main/man/man1...


I really don't follow. The command was named after the multics command print_wdir (print working directory) which had a "pwd" abbreviation already defined. Why would it mean anything other than print working directory?


> The Wikipedia entry states, on the page for pwd: “the pwd command (print working directory) [...]

> [...]

> UNIX PROGRAMMERS MANUAL - Seventh Edition, Volume 1 - January, 1979 [...]

> DESCRIPTION

> Pwd prints the pathname of the working (current) directory.

> I don’t know about you, but this historic document carries more weight for me than other sources I’ve come across, and it only serves here to undermine the credibility of the Wikipedia entry.

This line seems to be the crux of the article and I don't follow at all. I don't see how this undermines the credibility of the Wikipedia entry. What am I missing here?


The Wikipedia entry says p stands for print, as in print working directory.

The man page implies it stands for pathname, as in pathname of working directory.


The manpage says it "PRINTS the pathname of the WORKING (current) DIRECTORY"; I don't see any implication that either the word "print" or "pathname" make up any specific part of the acronym.

Really the manpage doesn't specify either way. If I were to force any meaning from the manpage, I would tend to go with the 1st word in the sentence starting the acronym, but it's not so much ambiguous as it is just simply not saying anything at all.

The original manpage doesn't give an etymology, so should be discarded as a source.


>The manpage says it "PRINTS the pathname of the WORKING (current) DIRECTORY"

You could say the manpage says: "prints the PATHNAME of the WORKING (current) DIRECTORY" many commands "print" things, doesn't mean it part of the name

>I don't see any implication

How you do not see it? PATHNAME is the only thing that differentiate this command from others, many commands print things ...

It's not simply a set of the words with equal weights. Some words there are more important and define the command, some can be interchanged like : "print" .

You can use "displays", "sends to output" ... but you cannot change "pathname" without ruining the meaning.

Should be obvious, for those who downvote, or simple logic doesn't work for some?


Your argument hinges on interpreting it exactly as YOU read it, while the grandparent argument only requires that multiple readings be possible. As multiple readings are demonstrably possible, your logic shows flaws.

Historical fact is determined by examining sources for how the authors and other contemporary people interpret them, not applying your own snap judgements to them.


>Historical fact is determined ...

Original article talks about MEANINGS of pwd. To determine meaning YOU imply that MEANING is defined ONLY by looking for historical fact, but it is how YOU interpret it. We can look for historical fact and find out that most of the commands literally printed on PAPER.

So IF we talk about MEANINGs, we can take into account historical fact but there is no much use for it, if it doesn't represent the MEANING!

There are no flaws in my logic. There are flows in your suggestion that we should discuss ONLY historical fact to determine MEANING.

>while the grandparent argument only requires that multiple readings be possible

while it does say about multiple readings possible, it uses caps used only in "PRINT" word. I merely pointed out to that imbalance by providing alternative, to ballance it back.

Then I went further and argued that multiple readings are inappropriate there, because it is naive to put the same weight to the words. Some words are ESSENTIAL and some can be used for almost any command in unix/linux. Even grandparent argument discarded manual as source. and we simply -do-not-know- historical fact, So I CAN use manual as source of interpretations in search for !MEANING! not historical fact, which is absent and not very useful even if it will be determined.

convinced ?


The man page is ambiguous, two words beginning with p appear in the description.

I personally trust the Multics etymology. The original developers of UNIX had worked on Multics after all.

"pathname of working directory" is redundant, as is "process' working directory".


Yeah, the Multics thing seems pretty definitive for me, it's clearly "print working directory". It also makes sense in context with the other basic UNIX commands: they're almost all actions or active verb phrases in some form. "Change directory", "list files, "touch", "concatenate", etc. It makes sense, because they're all programs you run that does stuff, they're not variables you read. So "pwd" as the active "print working directory" makes a lot more sense than the noun phrase "pathname of working directory", which sounds much more like a variable name, not a command name.


Pathname of working directory isn't redunant. There are multiple attributes of the working directory like creation time, name, pathname, etc. Pathname is just one of them.


It is more specific to say "pathname of the working directory", you are right about that.

What I meant was: It is redundant in the sense that the pathname is the identifier of the working directory, and if I ask someone to identify something I will receive in answer an identifier.

I.e. If I were to ask a user at their computer "what is the current working directory?" and "what is the pathname of the current working directory?" I will get the same answer.


Pathname there is the ONLY really useful word there, as it defines functionality exactly and filters out other meanings!


Why is that in any way significant or even slightly useful information?


I always thought it meant “present working directory”.

Typing it out, I should’ve known that’s incorrect


The name "current working directory" is used (eg /proc/self/cwd), and that meaning makes just as much sense.


Why would that be incorrect? Still makes sense.


It makes sense enough—I also assumed that pwd stood for "present working directory"—but the more that I think about it, "present" and "working" are almost redundant. i.e., by "working directory," I would understand "the directory in which I'm currently working."


Ah, now that you say that - I guess the minority response "process" would be the most accurate.


Present as in past/present/future would be redundant, but present as in presentation would not be.

That said, when I first learned of it, the pronunciation of “present” was as in past/future.


It doesn't matter as long as you remember it. Same goes for less. What does tar mean, or zip, gzip, unzip, rsync, scp. Do you care? tar is now a verb and a noun in its own right. If you know what it is and what it does, you know what it means.

When you type pwd you mean please do what pwd does.

npm nailed it, npm just means npm.


Everyone knows that less is more...


Given 'pwd -P' may very well print out a different but equally usable path then it brings to my mind the need for two separate commands: rwd "relative working directory" (no sym link resolution) awd "absolute working directory" (sym link resolution)

Also, "pwd -A" where A means ABSOLUTE is easier to remember than "-P" for physical. I never hear anyone talk about physical directories. When people are talking about resolving sym links they talk about absolute versus relative paths. Seems like a good historical research topic to understand why the canonical usage is "physical" that no one uses versus relative/absolute paths that are actually used.


Does it matter? Things need to have names, and when I need the `cwd` of the process (shell) I type `pwd`

The way I remember this: cwd -> curent working dir, pwd -> print working dir


Pathname actually makes a lot more sense when you really think about it. A print working directory command might be expected to give all sorts of details about the dir path, permissions, access/modify/change dates, contents. If I had to guess I think I might expect it to list the contents, like ls -1 does. Pathname working directory you would pretty much only ever expect to do exactly what PWD does.


Hmm, I thought it was `p` for `parent`, though not sure where I got that idea.


Same here. But I tended to use the term CWD when I meant pwd, and pwd only when I needed the command pwd.


I have always thought of it as "print working directory" but I used the Multics command before I ever used Unix so I brought a bunch of Multics preconceptions with me.


FWIW, I've been using *nix-based systems since 1982 and everyone I knew then referred to 'pwd' as 'print working directory.'


We are arguing about BS because author of the PWD have never dreamed it will be used for anything other then literally "print" on paper. We are suggesting it was very intellectual choice and thus we should stick to this BS forever, just because 'guru' was using paper instead of display and didn't think about the future.

'Pathname' is the ONLY thing that makes sense and useful.

And you can call it as you wish btw, it doesn't matter.


My guess: it's probably the name of a variable or field in the kernel, that became an actual command.


I was looking that up and found that in UNIX v6 source code, the field name in kernel source code is u_cdir, which stands for "current directory of (user) process":

https://github.com/yisooan/unix-v6/blob/master/sys/user.h


I started writing this comment:

A variable holding this most often is called fwd, though (current working directory)

Then I did some thinking and research and there is the PWD environment variables. Might be interesting if that predates the pwd command or not.


for the command, sure... but why would the variable have "print" in it?


My guess is the variable was named the same as the command to avoid confusion.

What's $PWD? Same thing you get from `pwd` without forking.


Try 'system' next:

- The kernel (as in 'system processes' like kswapd, the 'sys' in sysctl)

- The init system (as in 'systemd')

- The OS (as in 'updating the system')


What is really discussion about ? It's obvious

(P)athname of (W)orking (D)rectory is the ONLY meaningful abbreviation.

It simply cannot be just Print Working Directory because there are many meaning of this. What to print about current directory exactly? The same goes for present or whatever ..

Manual states it precisely too about PATHNAME. Many commands print things, most of them do this , but we do not have pfind pgrep pls pcat etc ...


I got the totally opposite take away from the article. It should be “pathname of working directory” but the Multics history pretty clearly points at “print working directory.”

Some commands become embedded so deep in your muscle memory that you’re going to bring them along with you, even if it occurs to you that the name doesn’t make much sense in the present working environment.


>Multics history pretty clearly points at “print working directory.”

It does, but it made sense in the context of Multics, it doesn't in the context of Unix/Linux.

It only shows how unix was designed: "let's tweak a bit and see ... " not too impressive


Are we arguing about what the etymology of the command is, or what it should stand for?

TFA seems to be confused about this too.

Yes, if we had to create a backronym for this, then Pathname of Working Directory makes the most sense (to me anyway).

But, as others have said, that doesn't appear to be what it originally stood for.


We are arguing about BS because author have never dreamed it will be used for anything other then literally "print" on paper.

We are suggesting it was very intellectual choice and thus we should stick to this BS forever, just because 'guru' was using paper instead of display and didn't think about the future.


> but we do not have pfind pgrep pls pcat etc ...

find, globally search regex and print, list, concatenate, change directory, make directory etc. are all commands. They all have some kind of imperative verb in there, so "print" fits that pattern.


If I am not mistaken command sends to stdout which can be anything, so print doesn't fit there at all, while pathname still does. Print is used in a sence of some output, like all commands do. Functionality though is difined by WHAT it actually sends to the output, just as with other commands.


It's obviously print, how could you arrive to your conclusion?


because printing is not unique functionality of this command. Most of the commands do that.


The 'p' in 'grep' actually does mean print.


ok this one yes

https://www.youtube.com/watch?v=NTfOnGZUZDk

so, does it make me incorrect in general idea?

what about ls? echo?


It happens that the p in pwd actually does historically mean print from multics, but honestly I just do not care about that, let the p mean whatever you want. My inner monologue will always be "present working directory" even though I think that option is totally silly, my brain is stuck with it now.

I just thought I was offering an interesting fact about where "grep" comes from.


I was taught years ago it stood for present working directory.


It can stand for whatever you wish actually, I think. )


Indeed! "pwd" is the command, regardless what the acronym stood for originally or what connotation we assign to it today.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: