8 ms·
The myriad meanings of pwd in Unix systems
- navanchauhan 6y agoI always thought it meant “present working directory”. Typing it out, I should’ve known that’s incorrect
- 3np 6y agoWhy would that be incorrect? Still makes sense.
- theobeers 6y agoIt 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."
- ben_w 6y agoPresent 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.
- 3np 6y agoAh, now that you say that - I guess the minority response "process" would be the most accurate.
- twic 6y agoThe name "current working directory" is used (eg /proc/self/cwd), and that meaning makes just as much sense.
- lucideer 6y ago> 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?
- ylyn 6y agoThe 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.
- tovej 6y agoThe 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".
- croes 6y agoPathname 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.
- tovej 6y agoIt 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.
- tyingq 6y agoThe 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.c#L17 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/pwd.1#L15 https://github.com/abs0/4.3BSD-Quasijarus/blob/main/man/man1...
- nailer 6y agoTry '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')
- mikl 6y agoHmm, I thought it was `p` for `parent`, though not sure where I got that idea.
- INTPenis 6y agoSame here. But I tended to use the term CWD when I meant pwd, and pwd only when I needed the command pwd.
- capableweb 6y agoThe 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 https://en.wikipedia.org/wiki/Talk:Pwd#PWD_meaning.
- deleted 6y ago[deleted]
- scoot_718 6y agofor the command, sure... but why would the variable have "print" in it?
- ben509 6y agoMy 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.
- amelius 6y agoMy guess: it's probably the name of a variable or field in the kernel, that became an actual command.
- johannes1234321 6y agoI 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.
- lxpz 6y agoI 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 https://github.com/yisooan/unix-v6/blob/master/sys/user.h
- lifthrasiir 6y agoI 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).
- ben509 6y agoWell, 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.
- johnr2 6y ago> 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 https://man.openbsd.org/wd
- arexxbifs 6y agoThey sort of did rewrite Unix and it's called pwd there, too. :) https://9p.io/magic/man2html/1/pwd https://9p.io/magic/man2html/1/pwd
- Joker_vD 6y agoDOS 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).
- jle17 6y agoAnncient 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.
- yonrg 6y agoDoes 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
- arghwhat 6y agoWhile 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.
- arexxbifs 6y agoIt'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 https://9p.io/magic/man2html/1/pwd
- Upvoter33 6y agoI 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...
- arghwhat 6y agos/exact expand form of such deviations/exact expanded form of such abbreviations/
- lovelyviking 6y agoWhat 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 ...
- tomrod 6y agoI was taught years ago it stood for present working directory.
- lovelyviking 6y agoIt can stand for whatever you wish actually, I think. )
- tomrod 6y agoIndeed! "pwd" is the command, regardless what the acronym stood for originally or what connotation we assign to it today.
- ben509 6y ago> 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.
- lovelyviking 6y agoIf 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.
- 6y ago
- bronlund 6y agoThat must be the stupidest article I have read in a long time. This guy is just trolling. How this ended up here, is the real mystery.
- the_mitsuhiko 6y agoI 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?
- taylodl 6y agoFWIW, I've been using *nix-based systems since 1982 and everyone I knew then referred to 'pwd' as 'print working directory.'
- theginger 6y agoPathname 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.
- lovelyviking 6y agoWe 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.
- teknopaul 6y agoIt 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.
- greedo 6y agoEveryone knows that less is more...
- gumby 6y agoI 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.
- mybrid 6y agoGiven '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.