| |
A free Basic UNIX-training with muLinux
The Directory Structure
The huge mass of files in a Unix-system requires organization.
That's why files are bundled in directories.
A directory is like a map, which contains the files.
Directories can contain directories again, called subdirectories,
and these also can contain directories and files, and so on.
All directories make a structured hierarchy, which starts from the
main directory as root. This principle is used by most other operating systems, where directories may be called maps or folders.
The main directory is symbolized by the "normal" slash
/.
This directory is always meant when a path starts with the forward slash /.
All other slashes in the path are just separations for the subdirectories.
For example:
/home/hans
Here home is a subdirectory of the main directory. home
contains the subdirectory hans.
Below are the same directories as shown in a file manager in X-Window:
Navigation in the filesystem
Navigation inside the file system is accomplished with a few commands.
Because of their basic functionality most of these commands don't need
any complicated parameters.
A directory is always the parent directory.
It's the directory where
"you are".
To see which is the parent directory we need the command pwd.
/# pwd
/
The forward slash / shows that we are in the main directory.
To change to another directory we must first know which
subdirectories exist.
Let us list the contents of that directory:
/# ls
a/ cdrom/ home/ mnt/ root/ setup/ tmp/
bin/ dev/ lib/ nfs/ samba/ startup/ usr/
c/ etc/ linuxrc* proc/ sbin/ swap/ var/
The names of subdirectories and files are shown.
Subdirectories in muLinux are listed with a / after the name [when the option -F is appended].
Below it is shown as listed under X-Window:
To change the parent directory, we need the command cd
(change directory).
After this command you need to specify the name of the subdirectoy:
/# cd etc
/etc#
We see that the prompt has changed.
It shows us our place, the current directory.
The command pwd isn't needed here,
but the command ls is very informative.
How we will see, there are a lot of directories and files here.
But more about that later.
First: How do we go to a higher directory?
The parent directory is symbolized by two dots ..
Please don't forget the space after the command cd.
/etc# cd ..
/#
Command Line Completion
Sometimes directory and filenames are very long.
To save time spent typing directory names there is
command line completion.
For example, if we want to change to /etc, we just need to type
cd /e and then press the tab-key.
/# cd /e Tab-key
/# cd /etc
/etc#
The rest of the name is completed.
This of course only works when there is no second directory which starts
with an e at the beginning.
In that case you need to add more letters.
For example, there exist more subdirectories, which start with an
s:
/# cd /s Tab-key You will hear
a Peep.
/# cd /sb Tab-key
/# cd /sbin
/sbin#
Absolute and Relative Addressing
When do we type the slash / before the directory name?
The slash marks the main directory.
That means, all directories with a slash at the beginning are defined out
of the main directory (absolute addressing).
No matter which directory we are in when we enter the command we will start from the main directory. If we leave the slash off, we define the working directory (relative addressing), starting from the directory we are in.
Now we are able to browse through the directories.
Of course now we want to know what's contained in the directories.
We use the commands cd and ls.
We can also use the cursor keys and the Backspace key to
change these commands.
The Standard Unix Directories
In Unix the directory structure is straight forward. The files are separated by type. Userdata, programs, and configuration files aren't thrown together as in other operating systems and there is differentiation between constant and changing files. Files can be assigned to different hard disks and partitions, physical separation is also possible. This improves system security and simpifies the organization of data.
/
This is the main, or root directory. The highest directory in the whole
directory tree. If possible there shouldn't be any files here, only
directories.
/bin
Important commands which are not specific for the superuser.
For example the commands date, reboot, halt, shutdown, pwd and ls. Program-files are also called binaries.
/dev
All peripherical devices, such as printers and modems, are contained in
the device directory.
They serve as gateway to the device drivers and so they have no content.
For example if you are printing a file, this file is just copied to
/dev/lp2 (printdevice). A special device is /dev/null.
This is the trash bin of Unix. When a file is copied there it is gone.
The file /dev/fd0 is the floppy drive
(floppy drive).
There are different files which start with /dev/fd0.
They define different floppy formats.
To list them all we can use the command ls
/dev/fd0* .
The asterisk is used as joker (or wildcard) and replaces all numbers and letters.
IDE-hard disks (hard disk) start with /dev/hd*.
SCSI-disks: /dev/sd*.
(virtual) consoles ( Alt + F1 ... Alt +
F6): /dev/tty*.
Serial ports: /dev/ttyS*.
/etc
Here you find the central configuration files. An example is the file
passwd.
This file contains a list of all users on the system.
The configuration files are pure textfiles (ASCII-files) and can be edited
with a simple text editor. Unix files can be configured without special software.
/home
Here we find the home directories of the "normal" users.
Every user in Unix gets a username, a password and his own directory.
This directory is situated as a subdirectory in /home .
A user with the name "Jacqueline" would get the
directory /home/Jacqueline .
There and only there, can she edit and save files and directories.
/lib
In Unix, as far as possible, shared libraries are used.
Shared libraries save lots of system resources, because many parts of
are shared and used at the same time.
/mnt
Many Unix versions mount the drives like CDROM and Floppy here.
The contents of the drives appear under the subdirectories, hda*,cdrom, etc.
/opt
muLinux doesn't use this directory.
Other distributions store optional programs, such as Netscape
Communicator here.
/proc
A virtual filesystem, which contains information about the hardware.
Every running process (process) is shown,
for every running process there is a subdirectory in
/proc showing the name and process
number (PID).
This subdirectory has no write permissions.
/root
This is the homedirectory of the superuser.
It's not situated in /home, because /home often is
mounted on another partition or harddisk and so /root would not
be available for rescue operations.
/sbin
The /sbin directory contains the executable binaries for the system start and for system administration by the superuser.
/tmp
Many programs need temporary hard disk space,
since all users use programs, all users need write permissions in
this directory.
On systems with many users this directory should be placed in a special
partition or hard disk.
Then, writing to this directory doesn't cause any system crashes
due to insufficient free disk space. When there is enough RAM (memory) available, it's also possible to write
the /tmp into RAM as is done in muLinux.
/usr
Commands and applications relevant for the user.
These are located in further subdirectories.
/usr/bin contains programs used less frequently.
It's not important if a program is put in
/bin or in /usr/bin since large, fast, and inexpensive hard disks have become common. In older equipment /bin was placed on a fast disk, and /usr/bin, on a slower disk.
/usr/doc and /usr/man contain Manual files.
/usr/games contains games which can be fired up by
typing their names.
Like for example blue the card game.
/var
In Unix there is a big difference between parts of the directory tree
which are writeable or readable only by the user, and those requiring root authority. The files which are readable by all users are placed under /usr. Those where the user needs write access also, are placed as
variable files in the subdirectories of /var .
Examples are the storage of printing-jobs and emails in the directory /var/spool like the logging of system happenings in
/var/log.
Additional muLinux Directories
There are a some variations in the directory tree among the
Unix versions and muLinux is no exception. Some of these muLinux directories will be found in other Linux distributions.
/a
Mountpoint for the floppy-drive.
When the floppy is mounted we can list the contents of the floppy in that
directory.
Other Linux distributions use the directories
/floppy or /mnt/floppy .
/c
Mountpoint for a hard disk.
/cdrom
Mount point for the CDROM-drive.
Other distributions use usually /mnt/cdrom .
/nfs
Mount point for the NFS partition used by other machines on the network.
/samba
Mount point for samba, directories for use by Windows machines on the
network.
/setup
This directory contains the files used by the muLinux
setup program.
/startup
Mount point for the muLinux start disk while booting.
/swap
Unused memory is taken from RAM and stored in this directory.
Normally this space is allocated in a special partition or on another hard disk and is not shown in the directory tree.
That is all for now. You would do well to refer to this chapter occasionally.
Robert.Warnke@giso.de (copyleft) Robert Warnke, Berlin (Germany) - You can write me in English. | http://rowa.giso.de | translated by mek, corrected by Bob Goodwin
|
| |
|
|