1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/doc/user-guide

518 lines
19 KiB
Text
Raw Normal View History

2012-12-21 15:22:09 -05:00
Sortix User Guide
=================
Thanks for your interest in Sortix! This document will describe how to use it
and what features are available. Sortix is a small self-compiling Unix-like
Operating System developed since 2011. The system is free software licensed
under the GNU General Public License and other licenses.
Introduction
------------
If you are using a Sortix live medium or a prebuilt harddisk image, you will
likely be met with a bootloader. Normally, GNU GRUB is used as the Sortix
bootloader. In that case, simply pick Sortix from the boot menu. If you have
installed Sortix manually, you will have to configure your bootloader to boot
Sortix.
The bootloader will then load the Sortix kernel and start the system. The
initialization process will spawn a shell shortly. The command line is similar
to those of Unix systems and many common Unix commands are available.
Keyboard Layout
---------------
Only the US Keyboard layout remains supported at this time. Adding new layouts
to the kernel is simple, but the system only supports ASCII text, making support
for international keyboard layouts pointless at this time. Eventually, a program
in user-space will be able to decode the keyboard scancodes, making it no longer
a kernel problem.
Changing the Video Mode
-----------------------
After boot, the screen resolution will be default be in VGA text mode. This only
allows 80 columns and 25 rows of 16 color ASCII text. Naturally, this is very
limited but works on most systems.
You can change the display resolution using the `chvideomode` program. However,
you need a suitable kernel driver to do the mode setting. The current release
only has a simple BGA driver, which works in virtual machines such as Qemu,
VirtualBox or Bochs.
2012-12-21 15:22:09 -05:00
The BGA driver can support virtually any resolution, but since the interface
fails to report which resolutions are appropriate in the current context, I have
simply hard-coded whatever resolutions I found reasonable when I wrote it.
Powering Off
------------
Unless you are using a harddisk image or your initrd has been specially
configured to mount a permanent root filesystem, then this environment is
entirely temporary. You will loose all modifications when powering off the
current system.
The system automatically reboots when the initial shell exits. You can exit the
current shell by entering `exit`, which if entered from the initial shell will
2014-06-11 14:46:47 -04:00
reboot the entire system (losing any changes if the root filesystem is not
2012-12-21 15:22:09 -05:00
permanent). Additionally, you can press Control-D ('^D') to exit the current
shell, but the initial shell will require you to enter a literal `exit` before
it exits and the system reboots.
The init process will restart the shell in the event that it crashes or dies
from a signal. You can use the `kill $$` command to kill the current shell, and
if it is the initial shell, you will get a new shell.
More Documentation
------------------
The system documentation (at least what has been documented so far) is installed
2014-06-28 10:10:20 -04:00
in the `/share/doc` directory. You can view these documents (well, the ones that
2012-12-21 15:22:09 -05:00
are plain text, there is no `man` program yet) using the `editor` program, which
you exit by pressing Control-Q ('^Q'). It is probably a good idea to change
the resolution using the `chvideomode` program if drivers are available.
If your release contains third party software, then this directory may also
contain documentation for this software, which may or may not be easily
viewable using the editor.
Filesystem Structure
--------------------
This as an incomplete list of the common top level directories in Sortix.
2014-06-28 10:10:20 -04:00
* `/boot` - Kernel images, initrd images.
* `/dev` - Device filesystem.
* `/etc` - System-wide configuration.
* `/home` - User directories.
* `/include` - Header files.
* `/root` - Directory of the root user.
* `/share` - Architecture independent files.
* `/share/doc` - Documentation.
* `/src` - System source code.
* `/tmp` - Temporary files.
* `/$cputype` - Files for $cputype.
* `/$cputype/bin` - Programs for $cputype.
* `/$cputype/lib` - Shared libaries for $cputype.
* `/$cputype/libexec` - Shared libaries for $cputype.
2012-12-21 15:22:09 -05:00
Some of these directories not be present or empty on your installation.
Using the Shell
---------------
Sortix features a homemade shell, which at best can be described as hacky.
Despite that, it does have some key features. Here are the features that are
supported:
* Processes can be started in the usual Unix manner.
* Tab-completion.
* Line editing.
* History.
2012-12-21 15:22:09 -05:00
* Background tasks ('&').
* Standard output redirection ('>').
* Piping stdin from a task to stdin of another ('|').
* Stopping the currently running task (Control-C, '^C').
* Waiting for a task to complete and executing the next (';').
* Setting environmental variables ('FOO=bar').
* Using $FOO to insert an environmental variable.
* Listing all environmental variable ('env').
* Setting the hostname ('HOSTNAME=sortix-pc').
* Changing the current directory ('cd /home').
* Removing an environmental variable ('unset FOO').
* Clearing all enviromental variables ('clearenv').
* Executing shell scripts ('sh script param1 param2').
* Escaping some special characters ('\').
* Comments ('#').
* Exiting the shell ('exit') ('exit 42').
* Basic wildcards ('foo*.bar').
* Clearing the screen (Control-L, '^L').
* Deleting the last typed word (Control-W, '^W').
* Deleting everything before the cursor (Control-U, '^U').
* Deleting everything after the cursor (Control-K, '^K').
* Go to start of line (Control-A, '^A', Home).
* Go to end of line (Control-E, '^E', End).
* Move between words (Control-arrows).
2012-12-21 15:22:09 -05:00
These features are missing from the shell:
* Input redirection ('<') ('<<').
* Quotes (''') ('"').
* Proper shell wildcard support ('*/*.foo').
* Escaping newline characters.
* And much more; the shell remains hacky.
Included Programs
-----------------
Sortix comes with a number of home-made programs. Here is an overview:
* `asteroids` - remake of the classic asteroids game
2014-03-08 10:41:05 -05:00
* `basename` - strip directory from filenames
2012-12-21 15:22:09 -05:00
* `benchctxswitch` - useless benchmark
* `benchsyscall` - slightly less useless benchmark
2014-04-21 16:37:44 -04:00
* `carray` - convert a binary file to a C array
2012-12-21 15:22:09 -05:00
* `cat` - display file on terminal
2013-06-18 07:40:12 -04:00
* `chmod` - change file mode bits
2012-12-21 15:22:09 -05:00
* `chroot` - change the root directory
* `chvideomode` - change display resolution
* `clear` - clear terminal
* `colormake` - colorful version of make (if make is available)
* `column` - format lines nicely in columns
* `cp` - copy file
* `date` - display current time and date
2014-03-08 10:42:27 -05:00
* `dirname` - strip last component from file name
2012-12-21 15:22:09 -05:00
* `dispd` - non-existent display server
* `du` - report file and directory disk usage
* `echo` - print command line arguments
* `editor` - text editor
2014-02-28 16:46:58 -05:00
* `env` - run a program in a modified environment
2014-03-06 18:07:11 -05:00
* `expr` - evaluate expressions
2012-12-21 15:22:09 -05:00
* `extfs` - ext2 filesystem server
* `false` - exit with an error status
2012-12-21 15:22:09 -05:00
* `find` - recursively list files
* `head` - display start of file
* `help` - show list of available programs
* `init` - system management deamon
* `initrdfs` - tool for examining initrds
* `install` - installs a program into a system directory
* `kernelinfo` - display kernel information
* `kill` - send signal to process
* `ln` - create filesystem links
* `ls` - list contents of directory
* `mbrfs` - create partitions for master boot record block device
* `memstat` - print memory information
* `mkdir` - create directory
* `mkinitrd` - create an initrd
* `mv` - move a file
* `pager` - display file page by page
* `pwd` - print current directory path
2014-02-20 09:48:20 -05:00
* `regress` - run system tests
2012-12-21 15:22:09 -05:00
* `rm` - remove file
* `rmdir` - remove empty directory
2014-12-04 11:39:41 -05:00
* `sh` - command shell
2014-05-30 21:59:20 -04:00
* `sleep` - delay for a specified amount of time
2014-03-07 20:02:02 -05:00
* `sort` - sort lines of text files
2012-12-21 15:22:09 -05:00
* `tail` - display end of file
* `time` - measure program running time
2014-03-09 10:31:13 -04:00
* `tr` - translate, squeeze and/or delete characters
* `true` - exit with a success status
2012-12-21 15:22:09 -05:00
* `type` - type raw characters directly into the terminal
* `uname` - system information
2014-03-07 23:41:35 -05:00
* `uniq` - report or omit repeated lines
2012-12-21 15:22:09 -05:00
* `uptime` - time since initialization
* `wc` - count words and lines
* `which` - find path to command
2014-11-30 10:49:39 -05:00
* `yes` - repeatedly output a line
2012-12-21 15:22:09 -05:00
Third Party Software
--------------------
In addition, a selection of third-party software has been ported and may be
present on your installation. In particular, the following software packages are
known to work at some level of stability:
* binutils
* bison
* bochs
* bzip2
* cairo
* dbus
* diffutils
* fontconfig
* freetype
* gcc
* gettext
* git
* grep
* groff
* groff
* gzip
* hello (GNU)
* libassuan
* libatk
* libav
* libcairo
* libdaala
* libexpat
* libffi
* libgcrypt
* libgdk-pixbuf
* libglib
* libGL (Mesa)
* libGLU (Mesa)
* libgmp
* libgnutls
* libgpg-error
* libgtk
* libharfbuzz
* libiconv
* libjpeg
* libksba
* libmpc
* libmpfr
* libogg
* libpango
* libpng
* libtheora
* libvorbis
* libwayland
* libxkbcommon
* m4
* make
* nettle
* openssl
* patch (GNU)
* pixman
* python
* quake
* sdl
* sed (GNU)
* tar (GNU)
* xz
* zlib
* (and more)
More software will be ported in the future as the system matures. Your release
may not contain all the ported software because of disk space constraints or
the stability/usefulness of the package or the difficulty to build.
Included Games
--------------
The system comes with a number of small casual games. Note that some games
require running in the correct display mode before they will function.
### Asteroids ###
Mine for crystals in an asteroid field! Start the `asteroids` program and if you
have the needed driver support, you can explore space in a gloriously rendered
asteroid field of bitmap graphics. Use the arrow keys to navigate. Avoid the
white asteroids as they will destroy your space ship. Use the `space` key to
fire a laser beam that breaks the asteroid apart, but beware that the fragments
will accelerate. Alternatively, use the `Left Control` key to shoot a fireworks
of laser beams, but it doesn't reach as far and may split a big asteroid into
many small dangerous asteroids. Your goal is to collect as many blue crystals as
possible without dying. You can use the `B` key to spawn a bot that will
cluelessly follow you and shoot whatever asteroids it deems dangerous. You can
use the `A` key to spawn a black hole (or just a big attracting thing).
System Source Code
------------------
The entire system source code (except third party components) is installed into
2014-06-28 10:10:20 -04:00
the `/src` directory. You can use the `editor` program to view and edit the
system source code. If your release contains the GNU compiler collection (gcc),
you can even modify the system and compile custom programs.
2012-12-21 15:22:09 -05:00
Editing Files
-------------
You can use the `editor` program to edit files. The editor itself is fairly
simple to use. It currently supports these keyboard commands:
* `Ctrl-Q` - Exit
* `Ctrl-O` - Open a file
* `Ctrl-S` - Save a file
* `Ctrl-I` - Go to line
* `ESC tabsize <desired-tab-size>` - change tab size
* `ESC margin <column>` - add right margin at column
* `ESC popen <command>` - open command output
* `ESC language <c or c++>` - enable syntax highlighting
It is not currently possible to port third party editors because the terminal
implementation is not standards-compliant enough and is seriously lacking.
Partitions
----------
If the initialization code didn't automatically create block devices for your
partitions, but the harddisk block device itself is supported, you can use the
`mbrfs` program to create block devices for the partitions.
mbrfs /dev/ata0
The program will output the names of the new block devices.
Mounting Filesystems
--------------------
The `extfs` filesystem server translates a block device formatted with the
second extended filesystem and mounts it at an empty directory. The filesystem
may need to be carefully configured as not all ext2 features are currently
supported. In particular, only the `large_file` and `filetype` features are
supported. There is no support for formatting or checking filesystems yet, this
will have to be done from an external system. You must take care to send the
filesystem server a SIGTERM signal to shut down when you are unfinished,
otherwise the data may not have been synced to disk. This will be done
automatically if the root filesystem was mounted by the initrd. If the device
2014-06-28 10:10:20 -04:00
`/dev/ata0p1` contasins an ext2 filesystem, then it can be mounted using:
2012-12-21 15:22:09 -05:00
mkdir /fs
extfs /dev/ata0 /fs
2014-06-28 10:10:20 -04:00
You can then access the filesystem at `/fs`. There is no real unmount support
and if the file system server shuts down, the system may hang trying to
communicate with a server that isn't there.
2012-12-21 15:22:09 -05:00
Graphical User Interface
------------------------
The `dispd` display server is still under development. Sortix does not feature
any documented graphical user interface at the moment.
Network
-------
Network support is still under development and is not documented at this point.
Unix sockets are available.
Building Sortix under Sortix
----------------------------
You can build Sortix under itself and made modifications to it. It is not yet
possible to build all the the third party software used to build itself, but you
can use the system to improve it until it is possible to build third party
software under it.
2014-06-28 10:10:20 -04:00
You need a version of Sortix that ships its own source code in `/src` and
contains a copy of the GNU Compiler Collection (gcc). Additionally, you should
be booting from a harddisk so that the new kernel is used after a reboot,
otherwise you will have to be satisfied with only using a new user-land.
2012-12-21 15:22:09 -05:00
You can use the `colormake` program instead of regular `make` if you want
colored output, which eases spotting compile warnings and errors. This program
simply invokes the real `make` and colors its output.
2014-06-28 10:10:20 -04:00
The `/src` directory contains a makefile that eases rebuilding the entire
2012-12-21 15:22:09 -05:00
system automatically. To rebuild the entire system simply run:
2014-06-28 10:10:20 -04:00
cd /src
make
make install
This will recompile the entire operating system and install it into the staging
area `/src/sysroot`. This is a full usable image of the root filesystem for a
Sortix installation and you can successfully execute `chroot /src/sysroot init`.
The install target does a single `cp -RT /src/sysroot /` command that replaces
copies all files in `/src/sysroot` onto their root filesystem counterparts, with
the exception that the precious files in /src are not replaced with their
/src/system/src counterparts (even though they usually would be equal).
2012-12-21 15:22:09 -05:00
2014-06-28 10:10:20 -04:00
You will be running a new version of everything upon completion, except the
kernel and programs were previously started will still be running the old
version. If the root filesystem is permanent and the computer has been
configured to boot from it, then you can reboot the system by exiting the
initial shell. You will then be running an entirely new system.
2012-12-21 15:22:09 -05:00
2014-06-28 10:10:20 -04:00
The projects that are part of the core system can be easily built and installed
with the provided makefiles. They can be built with this simple sequence:
2012-12-21 15:22:09 -05:00
2014-06-28 10:10:20 -04:00
cd /src/<package>
2012-12-21 15:22:09 -05:00
make
make install
If you wish to install the package somewhere than the default location, you can
use the `PREFIX` (and, depending on your needs, `EXEC_PREFIX`, `BINDIR`,
`LIBDIR`, ...) environmental variable to specify where the program will be
installed:
make PREFIX=/local
make PREFIX=/local install
Additionally, should you require that the package should be installed into a
temporary location before it is fully installed, use the `DESTDIR` environmental
variable:
make PREFIX=/local
make PREFIX=/local DESTDIR=/temporary-location
This will effectively install the package into `/temporary-location/local`, but
the package will expect that it is installed into `/local` when it is run. This
is useful for package management purposes to capture a copy of all the installed
files before they are installed for real.
2014-06-28 10:10:20 -04:00
### The C library ###
2012-12-21 15:22:09 -05:00
The C library (libc) implements the common functions, data types and constants
required by the C programming language standard, POSIX, other standards, and
various Sortix-specific extensions. Most programs for Sortix directly or
indirectly rely on this core library for basic functionality and system calls.
The build process builds a regular user-space C library as well as a
freestanding C library designed for inclusion into the Sortix kernel. After
rebuilding the C library, you may wish to rebuild the entire user-land since
those programs have an older libc version statically linked into them.
2014-06-28 10:10:20 -04:00
### The Math Library ###
2012-12-21 15:22:09 -05:00
The Math Library (libm) provides useful mathematical functions for manipulating
floating-point numbers of various sizes. This implements the <math.h> header as
known from standard C. Like the C library, you will likely want to recompile
large parts of user-land if you update this library.
2014-06-28 10:10:20 -04:00
### The Pthread Library ###
2013-08-31 07:15:53 -04:00
The Pthread Library (libpthread) provides a threading implementation through the
standard header <pthread.h> as known from POSIX. Like the C library, you will
likely want to recompile large parts of user-land if you update this library.
2014-06-28 10:10:20 -04:00
### The Display Daemon ###
2012-12-21 15:22:09 -05:00
The dispd library allows processes to communicate with the dispd server that
handles window management and graphical output. Currently, there is no such
server and the library calls the kernel interface itself. This library allows
games such as asteroids to detect the current resolution and request whatever
resolution they need to function.
2012-12-21 15:22:09 -05:00
2014-06-28 10:10:20 -04:00
### Utility Collection ###
2012-12-21 15:22:09 -05:00
The utility collection contains common programs such as `ls`, `cp`, `mkdir` and
more. These programs allow the basic operation from the command line.
2014-06-28 10:10:20 -04:00
### Benchmarks ###
2012-12-21 15:22:09 -05:00
The system comes with some small and outdated benchmark programs. They don't
currently give any meaningful values, so you should not use them for anything.
2014-06-28 10:10:20 -04:00
### Games ###
2012-12-21 15:22:09 -05:00
The games directory contains the source code for the above mentioned games.
These depend on libdispd.
2014-06-28 10:10:20 -04:00
### mbrfs ###
2012-12-21 15:22:09 -05:00
The `mbrfs` program creates block devices for every partition in the master boot
record in a block device.
2014-06-28 10:10:20 -04:00
### extfs ###
2012-12-21 15:22:09 -05:00
The `extfs` program translates a block device formatted with the second extended
filesystem and mounts it at an empty directory.
2014-06-28 10:10:20 -04:00
### mkinitrd ###
2012-12-21 15:22:09 -05:00
This program produces a Sortix compatible initrd, the file that contains the
initial filesystem used to bootstrap the real root filesystem.
2014-06-28 10:10:20 -04:00
### regress ###
2014-02-20 09:48:20 -05:00
This is a collection of operating system test cases run using the `regress`
driver program.
2014-06-28 10:10:20 -04:00
### carray ###
2014-04-21 16:37:44 -04:00
This program converts a binary file to an C array.
2014-12-04 11:39:41 -05:00
### sh ###
This is the Sortix shell. Currently the `sh` program is a wrapper that looks for
a better non-interactive shell if running a script, otherwise it invokes the
hacky `sortix-sh` program.
2014-06-28 10:10:20 -04:00
### Sortix Kernel ###
2012-12-21 15:22:09 -05:00
The Sortix kernel is the core of the Sortix operating system. It provides all
the primitives libc needs to implement a Unix-like environment.
Note that you need to reboot the system to use the new kernel and that you need
a permanent root filesystem or your local changes will be lost.