Tag Info

Hot answers tagged

62

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 ...


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 ...


26

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 ...


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 ...


19

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 ...


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 ...


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 ...


13

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 ...


12

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 ...


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 ...


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.


10

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 ...


10

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 ...


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

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 ...


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

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

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 ...


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

A hardware interrupt in 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 ...


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

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.


6

To expand on the post from Stéphane Gimenez, creating a new directory is the process of creating a new inode with the st_mode value of S_IFDIR (with the permissions mode), creating two entries in the first data block of the new inode with the link(2) system call: '.' which points to this new inode and '..' which points to the parent directory, then creating ...


6

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 ...


6

In case you meant "create my own UNIX OS" literally, maybe you're interested in the resources surrounding xv6 ("a simple Unix-like teaching operating system"), or "The Design and Implementation of the 4.4BSD Operating System". Edit Just stumbled upon this, "McIlroy's annotated guide to research Unix", which probably also is related. (And please read ...


6

No, the file is not copied, it stays where it is. What changes is the directory listing. This is why moving even the most gigantic of files on the same partition does not take any time. Keeping files contiguous on (traditional spinning) disks is advantageous, since it makes reading from and writing to them faster -- the head does not have to jump around ...


6

From Wikipedia: Asymmetric multiprocessing (AMP) was a software stopgap for handling multiple CPUs before symmetric multiprocessing (SMP) was available. Linux uses SMP.


6

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 ...


5

Memory management under Linux works exclusively by paging. Linux supports both "small" (usually 4kB) and "large" (2M) pages. The former "just work" without you knowing or doing anything special, and the latter need special treatment (have to be reserved at boot time and mapped via a special device). The only context in which "segment" appears under Linux ...



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