Unix systems are characterized by a large number of commands (from the Latin commendare for "command") with whichthe operating system canbe operated via a shell . The syntax of these commands differs between the various systems. There are the two main currents BSD and System V . Many commands are available in several variants, and the GNU tools are also widely usedas free software . Most commands have one- or more-letter option buttons that change or expand the functionality. Many basic commands are standardized by standards such as POSIX and can therefore be found on almost all Unix variants.
The modular philosophy
The basic philosophy of the Unix commands is the modular principle: Instead of large, “everything” programs for entire task areas, small, specialized commands are provided for elementary tasks that can be linked to each other in order to carry out more complex actions.
In the following it is stated in brackets in which Unix variant the command appears for the first time or from which its distribution is based and whether it is standardized in POSIX:
- ( V7 )
- The command was first included in AT&T UNIX Time-Sharing System Version 7 from 1979.
- ( System V )
- The command was first included in AT&T UNIX System V from 1983.
- ( BSD )
- The command was first included in the Berkeley Software Distribution, which was created from 1977.
- ( GNU )
- The command belongs to the GNU Core Utilities and was first included in the GNU operating system.
- ( SH )
- This is (originally) an internal command of the Bourne shell .
- ( CSH )
- This is (originally) an internal command of the C shell.
- The command was created independently of the development of a shell or an operating system.
- ( POSIX )
- The command is standardized in POSIX.
Unix systems are traditionally operated via the command line in a terminal or its emulation . There are also desktop environments for Unix and Unix-like systems, but the command line is still preferred by many users. One of the reasons for this is that the shells (command line interpreter) under Unix are much more powerful than, for example, the DOS command line interpreter . In addition, a shell is superior to a graphical user interface for some tasks, since the shell syntax, for example, allows flow control and program feedback to be included, which is usually not possible with graphical applications.
In addition to the interactive use, the shells also have the task of executing so-called shell scripts . These are roughly comparable to DOS batch processing files, but are much more powerful due to the much better equipment of the Unix shells with control structures. In particular, the shells allow the command “modules” to be linked with simple syntax, which is only possible with DOS from MS-DOS 2 (newer DOSes (e.g. FreeDOS , DCP ) usually from the beginning).
In contrast to DOS commands, which are often just English words (e.g. TYPE, FORMAT), UNIX commands often have strongly abbreviated names ( ed , w ) or even fantasy names that have nothing to do with their effect (e.g.. B. awk , less ) and often require difficult training.
The shells contain some built-in commands, here are some examples:
- set ( SH , POSIX )
- Setting shell options and setting shell arguments
- read ( SH , POSIX )
- Reading a line from the input and storing it in a variable
POSIX does not standardize any paths for this, POSIX only standardizes that a POSIX-compatible program called sh must exist and that it must be found after entering PATH = `getconf PATH` .
The main shells
- sh , Bourne Shell ( V7 )
- wasn't the first, but is considered the Unix shell
- csh , C-Shell ( BSD )
- with a syntax similar to the C programming language
- ksh , KornShell ( System V )
- Version ksh93 was the starting point for the shell standardized in POSIX
- bash , Bash (Bourne-again shell) ( GNU )
- Further development of the Bourne shell and currently the most widely used Unix shell; Shell preset for most GNU / Linux distributions , macOS 10.3+, Solaris 11+, Windows Subsystem for Linux and Cygwin ;
- tcsh , TENEX-C-Shell (u)
- Further development of the C-Shell
- zsh , Z-Shell (u)
- popular, ksh-like shell with a lot of features
(For more shells see under Unix Shells )
UNIX is richly equipped with a wide variety of filter programs for processing data streams. This is particularly because the concept of the pipeline introduced in UNIX is ideal for building entire processing chains from such filters. sed , awk , sort , pg and many others belong to this group of programs.
Standard input / output
Unix programs have three standard communication channels:
- Standard input ( stdin ), default setting: keyboard ( terminal )
- Standard output ( stdout ), default setting: screen (terminal)
- Standard error output ( stderr ), default setting: screen (terminal)
By convention, diagnostic and error messages or warnings are output on the standard error output.
Input / output redirection (English I / O redirection )
You can "bend" the standard communication channels. Usually you do this to read from a file or to write to a file.
- Input redirection with
wc -l < test.dat
<reads from the test.dat file and writes the result to the console. With
wc -l( Word Counter with the argument Lines ) the lines are counted and output in the console.
- Output redirection with
ls > dir.dat
- Ls is output in the dir.dat file. If this already exists, it will be overwritten.
- Output redirection with
ls >> dir.dat
- The output of ls is appended to the end of the dir.dat file.
- Redirection of standard terror with
wc -l < test.dat 2> err.log
- Error messages are written to the err.log file (not in the C shell csh ).
The principle of input / output redirection can also be found in the MS-DOS operating system.
A powerful tool is the use of a pipe for input and output redirection
<Kommando1> | <Kommando2>
You can link several filters with one another (hang one behind the other). Usually a filter expects input from the standard input (keyboard). The output takes place on the standard output (screen). With piping, the output of a command is redirected to the standard input of the following command via a pipe implemented in the operating system core.
grep Fidibus testdatei | tr '[:lower:]' '[:upper:]' | sort
In the file testfile are using grep all lines sought and issued, containing the word "spill", then tr converts all lowercase to uppercase, and finally everything is sorted and displayed on the screen. This type of pipe is called anonymous pipe .
This form of input and output redirection is so common that there are a large number of commands that only make sense with this technology - for example the above-mentioned wc (word count), which without input redirection (away from the keyboard, to a file) would hardly have an area of application.
Regarding the technology behind it, it should be noted that the individual filters are started as separate processes and thus perform their work more or less simultaneously, while the pipes ensure that the filters wait for each other if necessary so that no large amounts of intermediate results occur, the corresponding Would take up amounts of disk space.
For more complex applications, named pipes ( FIFOs ) can also be defined, which can then be accessed like a file:
- mkfifo: create named pipe
- In a shell:
mkfifo Rohr ls > Rohr
- First a named pipe called Rohr is created and then the current directory list is redirected to it. Warning: Opening the named pipe for writing may cause the program to block because it is waiting for another program to open the pipe for reading and receive the data waiting in it. The same thing happens if a pipe is opened for reading before another program writes to it.
- Then in another shell (e.g. in another window):
- Here the "content" of Rohr is read out and output on the standard output. So the output of ls from the first shell appears in the standard output of the second shell.
- Then the pipe can be deleted like a normal file:
One area of application is, for example, when a filter wants to mix data from different sources - for example paste , which takes two files and outputs them side by side.
see also: GNU Core Utilities (collection of basic command line programs under free license)
The Unix help system is essentially based on the so-called man pages (for manual page ). Ideally, there is a separate man page for every command, every call of the programming interface (system functions, C library) and every important configuration file .
The manual pages are also divided into numbered areas that cover different interfaces (user commands, administration commands, C functions, etc.).
The commands of the online manual
one ( V7 , POSIX ) : Manual pages ( MANual page )
calls the help page for a particular program, a specific function etc.
- whatis : gives a one-line short description of the commands, usually the summary line of the associated help page.
apropos or man -k searches for a character string in the short descriptions and returns the appropriate entries including short description. For example, displays
apropos compilerall entries that contain the word “compiler”.
An alternative helper system called texinfo comes from GNU and is based on hypertext . This is integrated in the Emacs editor, but there is also a pure info browser:
The tendency is apparently that the GNU programmers treat the manual pages somewhat neglected and deliver the more complete and mostly correct manual in Texinfo format.
The following is an incomplete compilation of important Unix commands.
Handling files is an essential part of working on a computer. Accordingly, there are also Unix commands for handling files:
- cp ( V7 , POSIX ) : Copy file ( CoPy )
- ls ( V7 , POSIX ) : Show files in a directory ( LiSt )
- mv ( V7 , POSIX ) : move or rename a file ( MoVe )
- ln ( V7 , POSIX ) : Creation of file links ( LiNk )
- rm ( V7 , POSIX ) : Deleting a file ( ReMove )
- tar ( V7 ) : Archiving program ( Tape ARchive )
On Unix (as on all modern operating systems) files are organized in directories. Under Unix, however, unlike under MS-DOS or Windows, there is only a single directory tree into which the contents of other data carriers can be "attached" at a certain point in the tree if necessary.
The following commands are available for directory management:
- mkdir ( V7 , POSIX ) : creates a new directory ( MaKe DIRectory )
- rmdir ( V7 , POSIX ) : deletes an (empty) directory ( ReMove DIRectory )
- cd ( SH , POSIX ) : changes to another directory ( Change Directory )
- pwd ( V7 , POSIX ) : Display of the current directory path ( Print Working Directory )
- mkfs ( V7 ) : Create file system ( MaKe FileSystem )
- newfs ( BSD , System V ) : Create a file system more conveniently
- fsck ( V7 ) : Check the file system ( FileSystem Check )
- mount ( V7 ) and umount ( V7 ) : Mount the file system in or unmount from the directory tree
- dd : copying, trimming and rerouting of data streams ( disk dump , English for "disk" or "disk" and "unload" or "throw away")
- df ( V7 , POSIX ) : Display of the free storage space in file systems ( Disk Free )
- du ( V7 , POSIX ) : Display of the required storage space of files and directories ( Disk Usage )
User and rights management
Unix was a multi-user operating system from the start (for example, MS Windows has only been able to do this since the NT generation). This means that different users can work on the computer and are isolated from each other: You can allow or forbid other users to access certain files. In addition, users can also be assigned to groups to which specific access rights can be granted collectively. The user root (system administrator), who is the only user with full access to the system, plays a special role.
Each user typically has his own home directory, in which only he (and root) can create and delete files.
- su ( V7 ) : Change user, default is changed to root ( substitute user )
- useradd or adduser ( System V ) : Create a new user.
- w (BSD) : Who is registered? And what are you doing?
- chsh (BSD) : Change of user information in / etc / passwd , / etc / group etc.
- who ( V7 , POSIX ) : Who is logged on?
- chmod ( V7 , POSIX ) : Change access rights to files ( CHange MODe )
- chown ( V7 , POSIX ) : Change owner and / or group ( CHange OWNer )
- chgrp ( V7 , POSIX ) : Change group membership of a file ( CHange GRouP )
- passwd ( V7 ) : Change user password (see also chsh )
- id ( BSD , POSIX ) : Outputs information about its own identity: user name, user ID ( UID), name of the primary user group, number of the primary user group (GID)
- finger (BSD) : Provides information about the (logged on) user. (Disabled on many systems due to security concerns)
One of the strengths of Unix is its many accessory programs, especially (but not only) for editing text files. The strength is based, among other things, on the fact that the accessory programs can easily be "interconnected" via pipes in order to perform more complex tasks.
- cat ( V7 , POSIX ) : Output and / or linking of text files in the command line ( conCATenate , English for "link")
- cut ( System V , POSIX ) : Select specific columns for output.
- echo ( V7 , POSIX ) : output
- grep ( V7 , POSIX ) : Display of all lines of a text file thatmatcha regular expression .
- head (POSIX) : Output of the first n characters / lines of the input (this is usually a file ).
- tail ( BSD , POSIX ) : Output of the last lines of the input (this is usually a file ).
- less ( GNU ) and more ( POSIX ) : page-by-page output of a text file
- paste ( System V , POSIX ) : Reads the content of several files line by line and combines them with one another using the delimiter
- sort ( V7 , POSIX ) : sort according to certain criteria.
- strings ( BSD , POSIX ) : filters printable character strings from a binary file.
- sed ( V7 , POSIX ) : powerful tool for text manipulation ( Stream EDitor )
- awk ( V7 , POSIX ) : programmable tool for data processing ( Aho Weinberger Kernighan , the first letters of the names of the inventors)
- ed ( V7 , POSIX ) : the "original" Unix text editor
- ex ( BSD , POSIX ) : the forerunner of vi
- vi ( BSD , POSIX ) : VIsual editor
- vim (u) : free further development of vi
- ftp (BSD) : command line client for File Transfer Protocol (FTP)
mail ( V7 ) : Send an email . POSIX standardized
- ping (BSD) : sends a ping to another computer.
- telnet (BSD) : Client for the Telnet protocol
- ssh (u) : Shell for encrypted connections and (as scp) transfers, more secure than Telnet or FTP ( Secure SHell )
- rsh (BSD) : ( Remote SHell )
- netstat (BSD) : Display of network connections
- ifconfig (BSD) : network interface configuration
- talk (POSIX) : talk to another user.
- write ( V7 , POSIX ) : Send a message to a user
- wall : Send a message to all users of a system ( Write ALL )
- at ( V7 , POSIX ) : start the process later (at ( at ) a certain time)
cron ( V7 ) : start the process regularly (POSIX standardizes the configuration tool
- kill ( V7 , POSIX ) : Kill a process or send other signals to it
- nice ( V7 , POSIX ) and renice ( BSD , POSIX ) : change the priority of a process
- nohup : ( V7 , POSIX ) do not quit on logout
- ps ( V7 , POSIX ) : Display of the running processes
- top (u) : interactive display of ongoing processes ( Table Of Processes )
- uname (POSIX) : Output of information about the operating system and computer
C development system
cc ( V7 ) : C compiler (POSIX specified
c99as C-99 compatible compiler)
- gcc ( GNU ) : The GNU variant of the C compiler
- make ( V7 , POSIX ) : Program group management
- lint ( V7 ) : C code review
- as ( V7 ) : assembler
- ld ( V7 ) : Link Loader
- adb ( V7 ) : Debugger
- gdb ( GNU ) : The GNU debugger
- nm ( V7 ) : Symbol Table
- objdump (u) : Disassembler specializing in ELF files
- size ( V7 ) : program segment sizes
- prof ( V7 ) : Profiler
- lex ( V7 , POSIX ) : Lexical Analyzer Generator
- yacc ( V7 , POSIX ) : Parser Generator
Unix was developed together with the powerful typesetting system troff , which enables, among other things, table and formula setting.
The manual pages can also be set with this system. nroff allows output on text terminals and line printers. The operating system- independent TeX has largely replaced * roff. The GNU help system texinfo also works with TeX for printing.
- troff ( V7 ) : Macro-oriented typesetting system for photosetting from the company Wang , whose control codes areverysimilar to the imagesetters from H. Berthold AG .
- nroff ( V7 ) : Macro-oriented system for terminal and line printer
- groff ( GNU ) : GNU version of troff and nroff with extensions for the control of graphics-capable printers
- eqn ( V7 ) : Mathematical formula set for troff (preprocessor)
- neqn ( V7 ) : Mathematical formula set for nroff (preprocessor)
- tbl ( V7 ) : Tables for troff and nroff (preprocessor)
- pic (u) : Integration of images in troff record data. The program originally comes from the UNIX Documenters Workbench and was available separately.
- spell ( V7 ) : spell checker
- Brian W. Kernighan, Rob Pike: The UNIX Toolbox. Programming with UNIX. Hanser, Munich 1986, ISBN 3-446-14273-8 (German translation)
- Michael Kofler: Linux command reference. Shell commands from A to Z. Rheinwerk Verlag, Bonn 2016, ISBN 978-3-8362-3778-9 . 3rd, updated and expanded edition 2016 (2nd edition from Rheinwerk Verlag).
- Collection of free Unix tools for Windows
- UNIX reference card , briefly summarizes many important commands.
- List of Unix acronyms , explains the origin of the names of many Unix commands
- Unix commands for beginners, including image editing at command line level