DIRECTORY CONVENTIONS & STRUCTURES
Directory conventionsThe strict formal names of directories are followed by a slash (e.g. /home/) to differentiate them from files. However, this is never done in command invocations. The convention is followed below to assist the reader in making this differentiation, but should not be followed in daily use.
Users should carefully distinguish between the root directory (i.e. / - the origin of the entire directory structure) and the Root User's Home Directory (i.e. /root/). Although somewhat confusing at first, the distinction soon becomes obvious.
The root directoryLinux uses a directory scheme structured like an inverted tree. Its origin is named the root directory and denoted by a fore-slash (/) Within this are subdirectories containing files and lower-level subdirectories. Only a few basic system files are ever placed in the root (i.e. highest level) directory - all other files are stored within the appropriate subdirectories.
|Table 1 A standard root directory tree.|
The Root UserThere is only one Root User per system and this user has the login name root. Other users have restricted access to file and programs in order to ensure privacy and security between users, and to protect the system from accidental or deliberate damage. The Root User has unrestricted access to the entire machine, and this privilege must be used with care. Root access is protected by a password, and can be invoked by any user knowing it.
Home DirectoriesEvery user is assigned a Home Directory. The Root User's Home Directory is on the Root Directory at /root/ All other Users have a directory with their login name in the /home/ directory, e.g.
The user's Home Directory is denoted by the tilde: ~/
The Bash ShellA standard linux login is to a bash shell (the Bourne Again SHell). Bash is configured by two files at the system level and two more in each User's Home Directory:
A filename beginning with a "dot" or period is a "hidden" or system file, but is much the same as ordinary files. Standard directory listings omit the system files ("dot files") for clarity. Before modifying any system files, the originals should be copied to an appropriate directory as explained below.
The System Configuration Directory /root/cfg/Within the /root/ directory a subdirectory named "cfg" should be created, that is, /root/cfg/ Withing this a further subdirectory named "original" should be created, i.e.
and within this again another directory named "root" to give:
By copying all original files in the /root/ directory into it, this becomes the repository for all original files in the /root/ directory. The two original bash configuration files can be stored here as:
The edited files can be stored in a "default" or "customized" directory:
A mirror tree of the root directory (i.e. /) can thus be built within /root/cfg/original/ to contain the originals of all modified configuration files. The standard Mandrake directory structure is given in Table 1. Most system configuration files are in /etc/ or one of its subdirectories, and the /root/ and /etc/ directories are usually included in standard backups.
User Configuration DirectoriesThe same procedure can be followed by each User to preserve their original configuration files. User Home Directories are in the /home/ directory, and User1's Configuration Directory will therefore be:
Files and directories can be copied at the commandline using Bash's cp command:
$> cp FILE_1 FILE_2
Far easier and more convenient is to use a text-mode file manager, the one here recommended being Midnight Commander or mc
Click here for more information about Bash commands and the commandline.
Starting a TerminalFrom the KDE Desktop, click the Main Menu icon, the Terminals item, then the Konsole item:
MainMenu > Terminals > Konsole
The Command PromptAn empty commandline contains only the command prompt, the default being:
The first section within the square brackets gives the user login ID and hostname of the computer, the second part the Current Working Directory. The dollar sign $ indicates a normal login, and changes to a hash sign # for a root login. For convenience we will abbreviate these to:
|Normal login command prompt:||$>|
|Root login command prompt:||#>|
UID and GIDClick the mouse in the Terminal window to ensure that it is active, then issue the id command and press the Enter key:
Only the letters id should be entered - the prompt will already be there. This will result in something like the following:
uid=500(user1) gid=500(user1) groups=500(user1)
Each user on the machine is assigned a User IDentification number (UID). Root always has the UID of zero, and normal UID's start at 500, with smaller numbers reserved for system users. Each user is also assigned to a group, by default a group with the same name and having the user as its sole member. The Group ID (GID) is therefore often the same as the UID, but need not be so. Other group memberships are listed last by the id command.
Basic Navigation CommandsNext enter the pwd command to get something like:
The Print Working Directory command prints the name of the user's Current Working Directory. Following login this is the user's Home Directory located in the /home main directory and defaulting to the user's login name.
The ls command lists the contents of the Current Working Directory:
Desktop/ Documents/ tmp/
The forward-slash / character following the names indicates that they are directories, not files, and these three directories are installed for all normal users in a Mandrake/KDE system.
The cd command allows the working directory to be changed. Issued on its own, it always changes to the user's Home Directory. Issued with the name of a valid directory, it changes to that directory. Try issuing the following command sequence:
$> cd /home
The pwd, ls and cd commands are the basic three needed to navigate a Linux Directory Tree, and should be memorized before proceeding further.