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

580 lines
21 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
---------------
2014-05-05 18:16:17 -04:00
The kernel translates the raw keyboard scancodes into unicode codepoints using
the current keyboard layout table associated with the terminal. Such layout
tables are compiled from a textual description into compressed binary tables
using the `kblayout-compiler` program. The kernel has a default US keyboard
layout integrated into it at compile time.
You can change the current keyboard layout using the `chkblayout` program. It
loads a keyboard layouts with the requested name from the `/share/kblayout`
directory, or a user-supplied file if the path contains a slash. The system
comes with a few existing keyboard layouts and more can be added if desired.
* `dk'
* `us'
You can select a particular keyboard layout by typing something like:
chkblayout da_DK
Mind that while the user-space programs and the kernel all handle text correctly
as unicode, your console may not be able to render such code points. VGA text
mode consoles, for instance, only has the VGA font available, which contains
just codepage 437 characters. The console driver helpfully translates some
unicode characters that look like codepage 437 characters into their lookalikes
for rendering. The graphical kernel console reuses the VGA font internally, but
has no hardware restrictions. In principle, support could be added such that
user-space can upload font data to the kernel graphical console.
2012-12-21 15:22:09 -05:00
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.
* `/bin` - Programs.
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.
* `/libexec` - Non-user programs.
* `/lib` - Shared libraries.
2014-06-28 10:10:20 -04:00
* `/root` - Directory of the root user.
* `/share` - Architecture independent files.
* `/share/doc` - Documentation.
2014-05-05 18:16:17 -04:00
* `/share/kblayout` - Keyboard layouts.
2014-06-28 10:10:20 -04:00
* `/src` - System source code.
* `/tmp` - Temporary files.
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 ('&').
2015-04-02 10:27:36 -04:00
* Standard redirection ('<', '>', '>>').
* Piping stdout from a task to stdin of another ('|').
2012-12-21 15:22:09 -05:00
* 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').
* Changing the current directory ('cd /home').
* Removing an environmental variable ('unset FOO').
* Clearing all enviromental variables ('clearenv').
* Executing shell scripts ('sh script.sh param1 param2').
2012-12-21 15:22:09 -05:00
* 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).
2015-04-02 10:27:36 -04:00
* Quotes (''') ('"').
2012-12-21 15:22:09 -05:00
These features are missing from the shell:
2015-04-02 10:27:36 -04:00
* Proper recursive shell grammar parsing.
* Heredoc sequences.
* Command substitution ('$(ls)', '`ls`').
* Arithmetic expansion ('$((2 + 2))').
* Aliases.
* Conditions and loops ('if', 'case', 'while', 'until', 'for').
* Functions.
* Some special parameters ('$@', '$*', '$#', '$-', '$!).
* Special shell variables ('$ENV', '$IFS', '$LINENO').
* Shell prompt customization ('$PS1', '$PS2', '$PS4').
* Tilde expansion ('~/foo').
* Any but the simplest variant of Parameter Expansion.
2012-12-21 15:22:09 -05:00
* Proper shell wildcard support ('*/*.foo').
2015-04-02 10:27:36 -04:00
* Ability for variables to not be exported.
* Export keyword ('export FOO', 'export BAR=bar').
* Subshells.
* Proper redirection to/from specific file descriptors.
2012-12-21 15:22:09 -05:00
* And much more; the shell remains hacky.
If a better shell is installed, and the shell is non-interactive, then the sh
program will automatically run the superior shell transparently.
2012-12-21 15:22:09 -05:00
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
2014-05-05 18:16:17 -04:00
* `chkblayout` - change keyboard layout
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
2015-06-26 21:12:26 -04:00
* `id` - print real and effective user and group IDs
2012-12-21 15:22:09 -05:00
* `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
2015-05-31 17:11:41 -04:00
* `mktemp` - create temporary file or directory
2012-12-21 15:22:09 -05:00
* `mv` - move a file
* `pager` - display file page by page
2015-07-30 19:21:30 -04:00
* `ps` - report a snapshot of the current processes
2015-07-31 11:44:55 -04:00
* `pstree` - display a tree of processes
2012-12-21 15:22:09 -05:00
* `pwd` - print current directory path
2015-02-16 08:18:38 -05:00
* `realpath` - canonicalize filesystem paths
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
2015-08-01 07:55:44 -04:00
* `stat` - display file status
2012-12-21 15:22:09 -05:00
* `tail` - display end of file
* `time` - measure program running time
2013-03-16 17:40:02 -04:00
* `trianglix` - triangle system
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
2014-05-07 08:15:52 -04:00
* `unmount` - unmount filesystem
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
* dash
2012-12-21 15:22:09 -05:00
* diffutils
* gawk
2012-12-21 15:22:09 -05:00
* gcc
* gettext (GNU)
2012-12-21 15:22:09 -05:00
* git
* grep (GNU)
2012-12-21 15:22:09 -05:00
* groff
* gzip (GNU)
2012-12-21 15:22:09 -05:00
* hello (GNU)
* libassuan
* libatk
* libav
* libcairo
* libdaala
* libdbus
2012-12-21 15:22:09 -05:00
* libexpat
* libffi
* libfontconfig
* libfreetype
2012-12-21 15:22:09 -05:00
* libgcrypt
* libgdk-pixbuf
* libglib
* libGL (Mesa)
* libgmp
* libgnutls
* libgpg-error
* libgtk
* libharfbuzz
* libiconv
* libjpeg
* libksba
* libmpc
* libmpfr
* libnettle
2012-12-21 15:22:09 -05:00
* libogg
* libpango
* libpixman
2012-12-21 15:22:09 -05:00
* libpng
* libSDL
* libssl (LibreSSL)
* libstdc++
2012-12-21 15:22:09 -05:00
* libtheora
* libvorbis
* libwayland
* libxkbcommon
* libz (Sortix)
* m4 (GNU)
* make (GNU)
2012-12-21 15:22:09 -05:00
* patch (GNU)
* python
* quake
* sed (GNU)
* tar (GNU)
* xz
* (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:
2014-08-23 15:26:38 -04:00
* `Ctrl-C` - Copy
* `Ctrl-I` - Go to line
* `Ctrl-K` - Cut
2012-12-21 15:22:09 -05:00
* `Ctrl-O` - Open a file
2014-08-23 15:26:38 -04:00
* `Ctrl-Q` - Exit
2012-12-21 15:22:09 -05:00
* `Ctrl-S` - Save a file
2014-08-23 15:26:38 -04:00
* `Ctrl-V` - Paste
* `Ctrl-X` - Cut
* `ESC language <c or c++>` - enable syntax highlighting
2014-08-01 06:12:54 -04:00
* `ESC line-numbering <on or off>` - enable line numbering
2012-12-21 15:22:09 -05:00
* `ESC margin <column>` - add right margin at column
* `ESC popen <command>` - open command output
2014-08-23 15:26:38 -04:00
* `ESC tabsize <desired-tab-size>` - change tab size
2012-12-21 15:22:09 -05:00
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. If the device `/dev/ata0p1`
contains an ext2 filesystem, then it can be mounted using:
mkdir /mnt
extfs /dev/ata0 /mnt
You can then access the filesystem at `/fs`. You can unmount it safely when you
are done using it:
2012-12-21 15:22:09 -05:00
unmount /mnt
2012-12-21 15:22:09 -05:00
This will safely shut down the filesystem process and sync to disk. Beware how
init doesn't know about your personal mount points and powering off the system
will cause all processes to be destroyed, and such mount points will not be
shut down gracefully at the moment.
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.
2013-03-16 17:40:02 -04:00
Sortix comes with the orthogonal graphical multi-user revolutionary triangle
system Trianglix, an attempt at making the most foreign yet somehow usable user
interface. You just need to run `trianglix` to start it.
2012-12-21 15:22:09 -05:00
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 make modifications to it. It is not yet
2012-12-21 15:22:09 -05:00
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 can only update to 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.
The `/src` directory contains a makefile that eases rebuilding the entire system
automatically. To rebuild the entire system simply run:
2012-12-21 15:22:09 -05:00
2014-06-28 10:10:20 -04:00
cd /src
make
chroot /src/sysroot init # to test the new user-land
make sysmerge # to update to the new user-land
2014-06-28 10:10:20 -04:00
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 chroot into it if desired.
The sysmerge target merges the image in `/src/sysroot` onto the current root
filesystem without changing local files, as opposed to a make install that
indiscriminately overwrites everything.
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 existing processes will continue to run the old programs. 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.
### Building System Components ###
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
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.
### 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.