Tag Info

Hot answers tagged

64

A UNIX system consists of several parts, or layers as I'd like to call them. To start a system, a program called the boot loader lives at the first sector of a hard disk partition. It is started by the system, and in turn it locates the Operating System kernel, and load it. Layering The Kernel. This is the central program which is started by the boot ...


33

The short answer is, fork is in Unix because it was easy to fit into the existing system at the time, and because a predecessor system at Berkeley had used the concept of forks. From The Evolution of the Unix Time-sharing System (relevant text has been highlighted): Process control in its modern form was designed and implemented within a couple of days. ...


28

The tradition in unix tools is to display messages only if something goes wrong. I think this is both for design and practical reasons. The design is intended to make it obvious when something goes wrong: you get an error message, and it's not drowned in not-actually-informative messages. The practical reason is that in unix's very early days, there still ...


28

You can determine the nature of an executable in Unix using the file command and the type command. type You use type to determine an executable's location on disk like so: $ type -a ls ls is /usr/bin/ls ls is /bin/ls So I now know that ls is located here on my system in 2 locations:/usr/bin/ls & /bin/ls. Looking at those executables I can see ...


27

There are several different scenarios; I'll describe the most common ones. The successive macroscopic events are: Input: the key press event is transmitted from the keyboard hardware to the application. Processing: the application decides that because the key A was pressed, it must display the character a. Output: the application gives the order to display ...


23

I can think of three desirable features in a shell: Interactive usability: common commands should be quick to type; completion; ... Programming: data structures; concurrency (jobs, pipe, ...); ... System access: working with files, processes, windows, databases, system configuration, ... Unix shells tend to concentrate on the interactive aspect and ...


20

"Everything is a file" is a bit glib. "Everything appears somewhere in the filesystem" is closer to the mark, and even then, it's more an ideal than a law of system design. For example, Unix domain sockets are not files, but they do appear in the filesystem. You can ls -l a domain socket to display its attributes, cat data to/from one, modify its access ...


19

[I'll repeat part of my answer from here.] Why not just have a command that creates a new process from scratch? Isn't it absurd and inefficient to copy one that is only going to be replaced right away? In fact, that would probably not be as efficient for a few reasons: The "copy" produced by fork() is a bit of an abstraction, since the kernel uses a ...


17

About your performance question, pipes are more efficient than files because no disk IO is needed. So cmd1 | cmd2 is more efficient than cmd1 > tmpfile; cmd2 < tmpfile (this might not be true if tmpfile is backed on a RAM disk or other memory device as named pipe; but if it is a named pipe, cmd1 should be run in the background as its output can block ...


16

Originally you had just dumb terminals - at first actually teletypewriters (similar to an electric typewriter, but with a roll of paper), but later screen+keyboard-combos - which just sent a key-code to the computer and the computer sent back a command that wrote the letter on the terminal (ie. the terminal was without local echo, the computer had to order ...


14

In the unix world, each tool is designed to do one job and do it well. Why would cp worry about outputting progress when another tool like pv does it already? In the same vein, why do so many programs dump stuff to the screen without any pagination? Because there are already tools for that job such as more (or less). Why do most programs that require editing ...


14

The directories internal structure is dependent on the filesystem in use. If you want to know precisely what happens, have a look at filesystems implementations. Basically, in most filesystems, a directory is an associative array between filenames(keys) and inodes numbers(values). Something like this¹: 1167010 . 1158721 .. 1167626 subdir 132651 barfile ...


13

Conceptually, a library function is part of your process. At run-time, your executable code and the code of any libraries (such as libc.so) it depends on, get linked into a single process. So, when you call a function in such a library, it executes as part of your process, with the same resources and privileges. It's conceptually the same as calling a ...


12

When you “open a terminal”, you're starting a terminal emulator program, such as xterm, gnome-terminal, lxterm, konsole, … One of the first things the terminal emulator does is to allocate a pseudo terminal (often called a pseudo-tty, or pty for short). The pty is a pair of character device files: the pty master, which is the side that the terminal emulator ...


12

That entirely depends on what services you want to have on your device. Programs You can make Linux boot directly into a shell. It isn't very useful in production — who'd just want to have a shell sitting there — but it's useful as an intervention mechanism when you have an interactive bootloader: pass init=/bin/sh to the kernel command line. All Linux ...


11

UNIX is a strong OS, build on a sound design that has proven successful for more than 40 years (that's almost eternity in computer science). The central technology is based on the C language and a myriad of small programs: the UNIX commands. The basic philosophy has been summarized by McIlroy: Write programs that do one thing and do it well. Write ...


11

The 50,000 foot view is that: A signal is either generated by the kernel internally (for example, SIGSEGV when an invalid address is accessed, or SIGQUIT when you hit control-\), or by a program using the kill syscall (or several related ones). If its by one of the syscalls, then the kernel confirms the calling process has sufficient privileges to send the ...


10

A hardware interrupt is not really part of CPU multitasking, but may drive it. Hardware interrupts are issued by hardware devices like disk, network cards, keyboards, clocks, etc. Each device or set of devices will have its own IRQ (Interrupt ReQuest) line. Based on the IRQ the CPU will dispatch the request to the appropriate hardware driver. (Hardware ...


10

I don't think you will get any printed book on this topic. The best resource you should consider is LFS(Linux from Scratch). It is a type of Linux distribution and book which teaches you how to build your own Linux distribution from source.


9

Summary: you're correct that receiving a signal is not transparent, neither in case i (interrupted without having read anything) nor in case ii (interrupted after a partial read). To do otherwise in case i would require making fundamental changes both to the architecture of the operating system and the architecture of applications. The OS implementation ...


9

It is a binary executable (compiled into machine code, like most of the system). Shell scripts are more like "glue" to join parts together to quickly and flexibly create solutions out of existing stuff. That's the power of *nix. You need the source code (c, sometimes c++, are the most common languages on *nix), not just the compiled executable. As it is ...


8

There are some excellent answers here. However, one thing I think has been left out is how *nix differs from other operating systems, particularly Microsoft Windows. The fundamental concept already covered above "do one thing, do it well" is so central to *nix operating systems that it can sometimes be overlooked. Yet it is this design philosophy that makes ...


8

Sort of. Check out User-mode Linux.


8

The Linux file/directory hierarchy is covered by the File Hierarchy Standard or FHS. How the OS works at a "deeper" level is a far more complicated topic. In general the surface level are the user commands ... mostly those in the /bin and /usr/bin directories which are covered in the chapter 1 section of the man pages. The next level down are the standard ...


8

Nothing. Different Linux distributions, and the LSB, had different standards, so both are present on CentOS to make it easier to run software from different versions. One is just a symbolic link to the other. http://www.centos.org/docs/5/html/5.1/Installation_Guide/s2-boot-init-shutdown-init.html gives details on the boot process, but ultimately all the ...


7

You will notice differences certainly. Most noticable will be differences in the standard userland utilities. FreeBSD does not use GNU ls, GNU cp, and so on. For example, if you're attached to a colorized ls, you may want to alias ls to "ls -G". It does use GNU grep, though. The default shell is a much simpler and less bloated shell than GNU Bash, which ...


7

All modern operating systems support multitasking. This means that the system is able to execute multiple processes at the same time; either in pseudo-parallel (when only one CPU is available) or nowadays with multi-core CPUs being common in parallel (one task/core). Let's take the simpler case of only one CPU being available. This means that if you ...


7

Linux uses both. It uses segmentation to map all the available address space while giving different access rights: basically a kernel and a user space view. You can grep the Linux source code for KERNEL_DS (kernel data segment) for some examples. Paging is then used for implementing virtual memory (Grep for "struct gdt_page" in the kernel, for a starting ...


7

Hey you speak with the computer! (Quote from a child who discovers the shell.) “The shell” is basically a language the computer can recognize, obey to, and reply to if asked. Local or not makes no difference. Think of a remote shell as an equivalent of communication over the phone.


7

No. Trivial counter example, this will interact with the kernel: int main() { volatile char *silly = 0; *silly = 'a'; } That'll call the kernel's page fault handler, ultimately resulting in your process getting a SIGSEGV (presuming the compiler doesn't "optimize" that code to do something other than the obvious, since that's undefined behavior by ...



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