3.1. File System Hierarchy.
In this section we discuss where you could save your files,
where you find saved files, how files are arranged, how
to interact with file related dialogs, what are the main types of files
and what are main files permission modes.
Section quote:
- "Unix has this thing called 'directories', which make it possible
for you to have multiple files with the same name on your disk."
-- Rik van Riel, explaining why directory is more mature concept than folder.
- "It's a mistake to think that a directory has to be a directory."
-- Linus Torvalds on LKML.
Section contents:
3.1.1. Start from your home!!
At your desktop (KDE or GNOME) you will see a house or hut icon
named "Home" or "Ahmad's Home" launch it (with double or single click)
and it will open the file manager (Nautilus in GNOME or Konqueror in KDE),
it can browse (list) the file system, do drag and drop operations,
cut or copy and past file operations, it can remove,move and copy files,
and even it can show image files, play audio files, and browse networks too,
this how two free software compete, by adding features.
Tip
The importence of this topic is that the know Linux policy that says
"every thing (as seen from kernel) is a file", some are real regular files,
orther are folders, othters are virtual (fake) files(eg. 'proc' file system tree),
some are links to other files, some do complicated inter-process communications
like FIFO pipes, and other files represent devices(mouse,sound output,...etc),
for example any raw data sent to the file '/dev/dsp'
will come out from the speaker, this will hide the complications
of hardware design (of sound cards in our example) so that application programmers
focus on their programs, this is called 'encapsulation".
Tip
To use GUI applications use your instinct, just look and feel,
you could drag and drop any thing, right click on every thing,
and also you may use hotkeys like 'CTRL+C', 'CTRL+V', 'CTRL+INS' or 'SHIFT+INS'.
Tip
You could change how GNOME 1.x Nautilus looks
from it's 'view' or 'edit' menu then
select 'preferences' then pick an icon theme, in new GNOME you could select
Nautilus icon theme from GNOME control center then 'theme' then 'details' then
'icons', you could set it to look like photo-realistic icons or
get more from 'http://art.gnome.org'.
Your home is just like "My Documents" in MS Windows terminology,
each user has his own home folder, Ahmad can't see what's in Ali's home,
this folder is given for each user to be able to put his own
files, remove them, create or remove subfolders, but user has no permission
to do such things outside his home. Some distributions has somewhere on it's
menus a launcher for super mode file manager (with root privileges),
after you provide the root user password, you will be able
to do every thing (including case damage), using it is a bad practice,
but it could be useful at your first Linux steps, you have to get use
of being regular non-privileged user as long as you can.
On your home you see a folder labeled 'Desktop' it's tthe desktop you see
over the background.
Tip
if you look at the home folder of 'morph' in the previous figure,
you will see little small marks on the folder icons
(paper on 'MyDocs', a black tune mark on 'My Music')
those called 'emblems', you could mark files or folders with
with some emblems to tell it's an important, unfinished, ...etc.
witth GNOME right click then select properties then choose one from emblems tab.
|
|
Both KDE and GNOME have icons for CDROM and floppy
on the desktop, in KDE there is a green light on the icon if the device
if it's activated (mounted) but if this light is off then it's not mounted
right click the icon and select mount, then launch the icon and when you are finished
right click and select unmount (or umount), the light will go off and you may
safely remove the media, in GNOME floppy and CDROM icons are only visible when
they are mounted if they are not mounted right click the desktop and select
disks then check that device you want to mount, then the icon appear
when you finish right click again on the desktop and uncheck it then remove the
media, the new GNOME 2.6 on most distributon you have 'computer' icon on the
desktop when launched you can see you CDROM,floppy and USB disks.
With RedHat Linux just put the CDROM media and it will be automatically mounted
and opened with your file manager, with Mandrake there is no need to mount and
umount thi is done automatically using supermount, just put a media (disk) then
click (or double click) on it's icon (they are directly on desktop or use
'removable media' icon on the desktop).
3.1.2. Where on Earth are files located ?
Zillions of installed applications files does not appear at your home!!
nor on Windows partitions, where are they ?
Open you home then press click on UP icon, you will see home folders
of other users (except root) another UP and you see many folders
(with GNOME 2.6 select browse the file system instead of your home to see Nautilus with all of it's beauty),
this folder is called root folder, all other folders are it's subfolder,
this is named '/' (look at the address or location bar),
now click on a folder called 'home' (the address becomes '/home')
then select your folder, for example the address now could be '/home/ahmad',
we say 'home' is the parent folder of 'ahmad' we also say that going from
'ahmad' to 'home' hoing up, up button means go to parent.
Tip
the folder '/root' is the home folder for the root user NOT
'/home/root', but in some old UNIXs it was just
'/', but recall NEVER LOGIN AS ROOT from the GUI.
Definitions:
- directory or folder:
-
a special file type that do not save any type of data, but instead
it's a place to put other files, it make using files more easy
imagine if all files are on the same place.
We say 'folder' in GUI applications context but 'directory'
is used by more advanced users.
- pathname and filename:
-
in MS Windows terminology it's the sequence of directories (separated with '/' in UNIX and with '\' in Windows)
you have to pass to access a file then the file it self, for example
'/home/ahmad/readme.txt' which mean starting from the root '/'
then go inside 'home' then 'ahmad' where you find 'readme.txt',
'readme' is called file name and 'txt' is called extention.
In GNU/Linux and UNIX in general we have different terminology,
we call file location (pathname in Window terminology) simply filename,
we have two types of filenames, absolute and relative (to the current directory).
- basename, period and extention:
-
basename is the filename without directories, for example '/home/ahmad/book.tar.gz'
basename would be 'book.tar.gz', each part of basename separated
by dot '.' is called a period, the period is called extention and
the last some periods are called suffix.
Tip
To access any folder it's enough to type it's name in address or location
bar at your file manager, you also could use file system tree in the side bar.
Home folder is represented with '~', for example
if you have a folder called 'Documents' inside your home it's enough
to type '~/Documents' at address bar to go there,
Ahmad's home is represented by '~ahmad/'.
The current folder is './' (not useful in GUI),
it's parent folder is '../', for example
'~ali/Documents/../foo.txt' is '/home/ali/foo.txt'.
Warning
You could say almost every thing in Linux is case sensitive,
filenames are not exception for example
'Documents' is not 'documents'.
3.1.3. Open file dialog.
Most GUI applications has similar open (and save) dialog box to select file
or files, they are similar because they use the same tool kit library.
There are two styles of those dialogs, motif-like used in most
UNIX applications (aparently GTK+ and GNOME applications)
they look like this:

- 1. some actions to create or delete a folder and rename a file,
they are useful if you don't find a place to save the file you create a folder,
or if you found a file with the name you want to save then you rename it.
- 2. parent directories click to see list of up levels direcroties.
- 3. subdirectories of the current, double click to enter (notice the '..')
- 4. files of the current directory (that match the pattern) click on one
and it will be shown on '7'.
- 5. application specific options like choosing file type
(list PNG or JPEG files)
- 6. where am I ?
- 7. the place where you type filename. Did I say type ? need not
be true you could click on basename from list number 4.
A good news that you could use TAB for automatic completion,
for example if you want foobar type fo then press TAB, you could use
wildcard patterns but press TAB not ENTER.
- 8. Okay (press ENTER), cancel (press ESC).
Warning
Do NOT press ENTER when you type folder name or wildcard patterns, instead
press TAB, but when you see the filename you want then you could touch ENTER.
there could be (in new GNOME versions) a sidebar for going to your home,desktop
,documents and root file system.
The other style of dialogs is the KDE style (just like MS Windows),
up there you see a drop down menu listting up level directories,
beside it we have buttons having arrows (up, left and right),
bellow we have a sidebar of common folders and a wide area of files and folders icons.
you are not yet familiar witth those, some application allow you to drag a file
from the file manager and drop it (eg. like changing GNOME background),
and you may right click a file in the file manager then select 'Open with'
and tthen select an application.
|

|
File managers could access to remote files on the network
at address type 'lan:/' or 'smb://'
to browse SMB protocol (used in Samba and Microsoft networks),
also NFS shares (only Konqueror) or using FISH protocol.
Also they can do many more useful things like browsing UNIX manual pages,
just type correct URI at the address.
|

|
3.1.4. File modes.
Each file on Linux have an owner user and group
(and each user is a member of at least one group),
the group of a file need not be the same as the group of the user,
each file has specific permissions for owner user,group and others,
has the user the permission to read ? write (edit or remove) ? execute ?
has members of group the right to do that and what rights has others.
Let's create a file with any text editor and save it as 'test.txt',
then right click it then select 'properties' then 'permissions',
see whose the owner (it should be you), then see permissions
(you may see other permissions like sticky which is meaningless
for regular files but useful for folders and that its contents
could not be removed even by those who have writing permission
except by its owner or root, eg. sticky is used for '/tmp')
we will discuss those permissions and more modes later deeply.
Tip
Execution for folders mean to be able to seach in, if you don't have
execution right on a folder then it seem empty when you browse it,
and you only access to files you know there names.
Here an example of how groups could be useful, a computer that is
used by students and teachers, we create two new groups 'student'
and 'teacher', then a teacher could create a file that he is the only
one who could read it, an let other files accessible by other teachers but
not students, and he could create files and let both members could read it.
Another example if we want to control accessing to floppy device
we create a group called 'floppy' then give the file '/dev/fd0'
permissions accordingly, and add users we want to be able to access the device to this group.
Warning
Do not give people the permission to right on your files, they could remove them !!
Open your home then show hidden files (from 'view' menu),
by default any file starting with '.' is called hidden,
not because they are secrit (to make a file secrit change permission)
but because they are annoying, you should not bother yourself with them,
they are configuration files almost every program you run create such hidden file
(or folder) at your home to keep your preferences
(on the other hand system wide configuratitons are saved on '/etc' or it's subfolders).
Let's disable viewing hidden files, open your text editor and save a file called
'.test.txt', close the file and then select 'open' from your
text editor menu and try to find that file, type '.' in filename entry
(you could use auto completion for example by pressing TAB in GNOME and GTK+)
and after you type the full basename '.test.txt' press ENTER.
Tip
Examples of hidden folders at your home are '~/.themes'
where you could put GTK+ themes (compressed or uncompressed)
and tthe folder '~/.xmms' which contain
'~/.xmms/skins' where you can put
skins (eg. Winamp skins) for this application.
A file could exist on many places without occupying more space,
we call this linking, a file could be just a link to another file,
another way to access the same data. There are two types of links,
the first is soft or symbolic link, by creating a special file
that saves the filename (relative or absolute) of the original file
that it points to, for example if you put a document file at your home
folder and put a link to it on the desktop they both act the same
(you could open the link with the word processor it will open the document)
except that if you remove the original file the link becomes invalid and we
say it's a broken link, but if you remove the link the original file still work,
it's easy to know if a file is symbolic link or not.
The other type of links are hard links, when thay are created
there are no difference between the hard link and the file, they are two files
pointing to the same block (having the same i-node number),
in other words if you remove the file or the link the other still work,
it's very hard to know if there are files hard linked together,
another difference between soft and hard links is that soft links
could work across file systems in different devices
(eg. a link could be in a partition meanwhile the original file could be in another partition)
and soft links could refere to a file that do not exists (it could be
available later) unlike hard links, lesser important difference
is that the symbolic link occupy space (very small space)
just to save the name of the file it referes to, unlike hard links
which needs no extra space.
Goto the folder '/mnt' is just like 'My computer'
in Windows, there are folders for Windows and other partitions,floppy,flash memory
and CDROM (in Debian you see removable media at '/media'),
if those devices are mounted (mapped or loaded there) then you see that device
file system content (as files), but in fact they are empty (if not previous
files will be hidden until the device is unmounted) but they kernel make
them appear as if they are holding the device file system, the command used
to do this is called mount, this is just an illusion, the files are not
copied from the device to your Linux partition not take any disk space from
Linux root file system. A good example of illusion done by kernel
is 'proc' virtual file system found at '/proc'
which contain information as seen by kernel, for example (you could view them with any text editor or viewer except 'kcore'):
- cpuinfo: information about your computer CPU.
- uptime: how long (in seconds) has the system is up or idle since last boot.
- loadavg: the average of CPU load.
- mounts: mounted file systems (see 'mtab' manual).
- filesystems: file system types that the kernel can deal with now.
- kcore: the same as your computer RAM contents (do NOT view this file).
other important trees on Linux root file system is '/usr/share'
it contain all programs runtime data (images,fonts,online help...etc) and it contian
documents for example see those folders
'/usr/share/lilo', '/usr/share/themes',
'/usr/share/icons', '/usr/share/pixmaps'
and '/usr/share/wallpapers'. This is the tree of usual UNIX
file system tree:
| /bin |
binaries(executable files), contian most basic console programs (command line tools).
|
| /sbin |
system binaries, administration console utilities that should be used by root used only.
|
| /etc |
system wide configurations for all users.
|
| /lib |
basic critical libraries, the system does not work if any is missing.
|
| /tmp |
it contains temporary files that are deleted each time you reboot the system.
|
| /var |
programs write about their status here.
| /var/log |
log files, reports about rquests,actions,logins,logouts,errors,..etc.
it could be useful to track criminals trying to crash your system.
|
|
| /usr |
a super folder with large tree related to extra applications specially interactive programs.
| /usr/bin |
binaries
|
| /usr/sbin |
system binaries.
|
| /usr/lib |
extra libraries used by applications, some times there could
be subfolders with programing modules and few documents.
|
| /usr/X11R6 |
the super tree of the core of X11 graphical server, just like '/usr'
| /usr/X11R6/bin |
X11 binaries.
|
| /usr/X11R6/lib |
X11 related libraries.
|
| /usr/X11R6/etc |
X11 related configrations.
|
|
| /usr/doc |
extra package specific documentations.
|
| /usr/share |
each application specific data like sounds,high scores, pixmap, images
and online help, for example '/usr/share/gtk-doc'
has documentations related with programming with GTK+,
'/usr/share' has some subtrees like
'/usr/share/locale' which has local languages translations,
'/usr/share/man', '/usr/share/info'
and '/usr/share/doc' are many documents.
|
| /usr/local |
super tree just like '/usr' but out of package manager control,
usually insatalled by source code packages.
|
| /usr/include |
headers for C/C++ programing.
|
| /usr/man |
UNIX manual pages.
|
| /usr/info |
GNU info pages.
|
|
3.1.5. File types.
Most Linux application (specially file managers) could distriguish
between file types from it's internal structure, we don't have to give
them special extentions, as we see before an executable file is any file
that you have the permission to execute, we are not forced to give it
specific suffix (eg. '.exe' or '.bin'), and they need not
be compiled biniary(machine langauge) files they could be a normal text
script written on an interpreting languages, they could be a virtual machine
code like Java, or a binary for other systems (eg. using WINE for running windows programs),
when you ask the kernel to execute a file (no matter what extention it has)
it look in a data base called binary format "magic",
it's a table that identified file type from extention or magic number at
certain fixed position as a signiture, then this is used to decide
how to execute it, if it's a script (starting with '#!') then it call
the specified interpreter.
A good example of how smart both Linux file manager are
save a JPEG image then open any file manager and rename it to change extention
from 'jpeg' to 'unknown' then press refresh or close it and reopen it
you still able to see the image!! it knows the type and preview the image
(file managers could be configured to depend on extention onl for speed).
Extentions are used to make it easy to the user not to the system,
the following list shows a small number of common file types:
| .sh |
Shell script, an executable text file.
| | .gz |
a file compressed with 'gzip'.
| | .bz2 |
a file compressed with better (a bit slower) 'bzip2' compressor.
| | .Z |
old UNIX compressed file, 'gzip' could handle them.
| | .txt.gz |
GZIP'ed (compressed) text file.
| | .bmp.bz2 |
GZIP'ed BMP bitmap image file.
| | .tar |
tape archive, a collection of files with no compression,
it preserve date,permissions...etc.
|
.tar.gz
.tar.bz2
.zip
|
compressed archives.
|
3.1.6. Archiving and backup.
There are many console programs to handle famous archives like
ZIP, RAR and ARJ files, and there are many GUI front ends for them for example:
- 'arc' for KDE, that can hadnle most types of archives.
- 'file-roller' for GNOME.
- 'guitar' very light front end GUI for 'tar'.
You could do all types of backup from command line using tools like
'tar' and 'dd', and there are many GUIs for example
- 'Mondo Rescue'
an tool that can take raw image of disks and put them on bootable CDROM to do restore
later.
- PartImage
It takes compressed raw image of disks and support many file systems.
there are many distribution specific backup solutions like 'drakbackup'
from Mandrake, and there are networked backup solutions using 'rsync' protocol.
|
Best viewed with free web browsers
You may get more high quality software
from here for free

Generously Hosted by www.JadMadi.net
|