61

In 2008–2009 The Unix Heritage Society managed to reconstruct the source for First Edition Unix kernel and parts of the shell from various sources, including magnetic tapes and paper documents. The details were written up and presented at a USENIX conference in 2009. Warren Toomey (2009). "The Restoration of Early UNIX Artifacts". Proceedings of ...


21

The closest of the feeling of a contemporary system you can get freely in the Internet, and pretty much tested and ready to run, is a version 7 disk image running with the PDP-11 SimH emulator, and even a system III disk image with the actual C sources also with the PDP-11 emulation under SimH. See my post with step-by-step instructions how to download and ...


18

Unix was originally a product, first developed in AT&T's Bell Labs. But today, the word “Unix”, except in historical context, means a family of operating systems, not a single product (similarly to “Linux” meaning a family of distributions, not a single product). This family has a somewhat complex history (see also Evolution of Operating systems from ...


13

. is the POSIX standard. source is a bash builtin synonym for . and is not as portable as . Also note in the Bash reference manual . is listed under 4.1 Bourne Shell Builtins and source is listed under 4.2 Bash Builtin Commands as: A synonym for . (see Bourne Shell Builtins). It's possible that bash named it source because that's what it was called ...


12

Perhaps the answer is the same as part of the answer in this trick question: How do you get down off an elephant? You don't. You get it from a goose. From "The Practice of Programming" by Brian W. Kernighan and Rob Pike, Ch. 6, pg. 158: When Steve Bourne was writing his Unix shell (which came to be known as the Bourne shell), he made a directory of ...


12

Unix was making that distinction since the very beginning, i.e. since version 1 was released in 1971. The system was booting to multi-user mode (i.e. users connected to the available serial interfaces, tty0 to tty5 but provision was made to add four more ttys). Unix v1 manual states for the section 4, tty page: By appropriate console switch settings, it ...


10

Unix was originally and for a long time used in a professional environment. In a professional environment, it is very common to work on the same topic as colleagues. Some files are confidential; for example every email program I've ever seen creates files that are only readable to the owner (mode 600). But it makes sense to have files be publicly readable by ...


8

It may be awkward but I am answering my own question. I found out the source code: https://archive.org/details/ATTUNIXSystemVRelease4Version2


8

IO redirection was not present in the initial PDP-7 implementation (circa 1969) but was added very shortly thereafter. With that, you can implement the moral equivalent of a pipe: prog1 | prog2 could be implemented with prog1 > tempfile prog2 < tempfile rm tempfile In fact, pipes are often explained using this model. The paper The Evolution of the ...


7

The earliest mentioning of the dot command that I can find is in the manual for Stephen Bourne's sh shell in Unix Release 7 (it may be older, but not evidently present as one of the built-in commands in sh in Release 6). . file Read and execute commands from file and return. The search path $PATH is used to find the directory containing file. The ...


6

I don't feel like digging for the sources of 25-year old shells, but It could be a format-string vulnerability. If the shell contains code like printf(str); where str is some string taken from the user's input, the contents of the string will be the format string that printf uses. The %s's tell printf to print a string pointed to by an argument. If the ...


6

There's Steve C. Johnson's 2013 account of this, as a user, where users complain about phototypesetting and — lo! — the problem is fixed two days later. But Douglas McIlroy told the tale slightly differently a quarter of a century earlier. In McIlroy's version, standard error was a natural consequence of Ken Thompson's famous all-nighter ...


5

The 1969 version has been lost to history. But what would you want? The version on day 1? Day 200? The closest thing original Unix had to releases were editions of the manual. The Unix 1st Edition manual was published in 1971, and that's the earliest code that's available. You can browse the source on the The Unix Heritage Society website. The 1st Edition ...


5

From The Art of Unix Programming (emphasis added): After the [1974] paper, research labs and universities all over the world clamored for the chance to try out Unix themselves. Under a 1958 consent decree in settlement of an antitrust case, AT&T (the parent organization of Bell Labs) had been forbidden from entering the computer business. Unix could ...


5

I've done this. This was on a UNIX system running on a PDP-11 sometime around 1980. I created a file called "WhatXNow?". I then used a binary file "editor" to edit the disk device and change the "X" to a "/" in the inode (with the file system unmounted). The victim never figured out how to remove it. Edit: whoops, Barmar is right, I failed to see the ...


4

lseek’s long parameter and return value are both offsets in the file; the addition of long didn’t have any impact on file descriptors. Varying word size did have an impact on the size of usable offsets; see lseek64 for a workaround.


4

Using head and cut: $ variable=$( head -n 1 sample1.txt | cut -c 1-4 ) $ printf 'variable is %s\n' "$variable" variable is ABCD This extracts the first line using head and then cuts out the first four characters using cut. Note that some implementations of cut may return the first four bytes rather than the first four characters (e.g. GNU cut). This would ...


4

At first, I thought that it is a simple sum of bytes modulus 2^16 It is a sum mod 2^16, only that each time it overflows, a 1 will be added to it. Also, the bytes will be sign extended before being added to the sum. Here is a "commented" snippet from the assembly: # r2 is the pointer into the data # r0 is the length of the data # r5 is the sum 2: ...


3

A GNU grep (or compatible) solution: variable=$(grep -o -m1 '^....' file.txt) where -o output match only -m1 stop after one match ^ begin of line .... any char, four times note: -o is a non-standard GNU extension (though now supported by a few other implementations), that will report the first 4 characters of the first line that has at least 4. in ...


3

Assuming historical UNIX by which I'm assuming bash or more recent shells are not supported, you can do it in a POSIX compliant way if IFS= read -r line 2> /dev/null < file; then result="${line%"${line#????}"}" printf '%s\n' "$result" else printf >&2 '%s\n' 'Unable to read file contents or no newline found in the file' fi


3

As far as Bash is concerned the . and source are not aliases for one or the other, it's a simple fact that they're both builtins which call the same underlying function, source_builtin. Take a look at the source.def file from the Bash source code: $PRODUCES source.c $BUILTIN source $FUNCTION source_builtin $SHORT_DOC source filename [arguments] Execute ...


3

The c89 standard would be the place to look; its rationale was published separately (and is not part of the standard). stdlib.h was a creation of the committee working on the standard rather than reflecting existing practice. The X3J11 rationale says: The header <stdlib.h> was invented by the Committee to hold an assortment of functions that were ...


3

https://www.freebsd.org/ FreeBSD is a free Unix-like operating system descended from Research Unix via the Berkeley Software Distribution (BSD). Although for legal reasons FreeBSD cannot use the Unix trademark, it is a direct descendant of BSD, which was historically also called "BSD Unix" or "Berkeley Unix".


3

Looks like Version 6 Unix didn't include many common tools yet that appeared only in Version 7 (like sed and awk). At that point, Unix was also not commercialized yet, so "reverse hex dump" could be missing simply because there was no wide demand for that operation or because Ken (or some other programmer) provided such tool from their unofficial /usr ...


2

AT&T had been forced to open source UNIX, as initially AT&T, SUN, IBM, HP, Tandem, Berkeley Univ, Digital were contributors in developing the UNIX kernel actually developed by Ken Thomson and team. After UNIX became more mature, the source code had to be shared between the above said companies as they wanted to file their own patents and so you see ...


2

May it be because dot is the name of the symbol .. 1 : a small spot


2

The dot command was introduced by the Bourne Shell most likely in 1976. The source command was introduced by the csh in 1977 or 1978. So there is not an alias relation but two different names for an "invention" at the same time. BTW: I can tell you why cd is named this way. The command previously had been called chdir, but this was too long (slow to type) ...


2

I believe this is a misunderstanding. The complete quote from the book is The three symbolic constants—SEEK_SET, SEEK_CUR, and SEEK_END—were introduced with System V. Prior to this, whence was specified as 0 (absolute), 1 (relative to the current offset), or 2 (relative to the end of file). Much software still exists with these numbers hard coded. ...


2

A case-insensitive Ngram search for "Everything is a file,Everything in Unix is a file" doesn't turn up much, but it does give a date to beat: In iPcress everything is a file, including the indexed table of file headers (inode table). This is an extension of the UNIX philosophy that “all files are simply a stream of bytes". - FILE SYSTEM DESIGN USING ...


2

If you use awk: var=$(awk 'NR==1 {print substr($0, 1, 4)}' sample1.txt)


Only top voted, non community-wiki answers of a minimum length are eligible