The Filesystem

 < Day Day Up > 

Every operating system must organize the files on the computer in some fashion. You may recall that early on in this book we discussed filesystems. Every operating system has certain directories that are of paramount importance. In Windows, the actual operating system is stored in the windows directory on your root drive, usually your C drive. In most cases, you will find Windows in c:\windows. Beneath the windows directory you will see a number of subdirectories, such as system and system32. The entire windows directory, with its subdirectories, contains files that are critical to your computer functioning. Unless you have some advanced knowledge of the Windows operating system, you should not tamper with anything in these directories.

Other important directories include Program Files shown in Figure 19.3. This is where most programs will be installed by default. This is also generally on the root drive. You also have probably noticed a default document directory on Windows machines. This is a directory that the operating system creates for you. It is meant to contain items that are considered crucial or fundamental to the system’s normal operation.

click to expand
Figure 19.3: The Program Files directory.


It was mentioned briefly earlier in this book but must be emphasized again that Windows refers to a directory as a folder. They are the same things. In this book we will use the terms interchangeably.

Since we are using the phrase root drive, it might be prudent to define that term. Do not confuse the root drive of any operating system with the root user. The root user, in Unix and Unix-like systems, is the system administrator. In Windows the root user is referred to as the administrator. The root drive or director, for any operating system, is the main directory. For example, if you have three hard drives in your system, or one hard drive divided into three partitions, the one that contains the operating system is the root drive.

As was mentioned previously, in any operating system there are certain key directories. These directories hold certain types of files. This is true in Linux as well as Windows. Let’s examine some of those directories and what they contain. There are several directories in Linux, each with its own particular purpose. The File Manager, shown in Figure 19.4, is showing all the top-level directories. We will examine several of these in the following pages.

click to expand
Figure 19.4: Directories in the File Manager.

/root: The /root directory is the home directory for the root user. It usually is not accessible to other users on the system.

/bin: The /bin directory holds binary files. Compiled programs are binary files. You will find a number of programs/applications in this directory. In fact, many shell commands are stored in this directory.

/sbin: This directory is very much like /bin, but the commands are not intended for the average computer user. For that reason, /sbin is not usually in the default path of normal users but will be in root’s default path. That means that most users who log on cannot access /sbin or any commands stored there.

/etc:The /etc folder contains configuration files. Most applications require some configuration when they start up. All of those configuration files can be found in this directory. This directory has several subdirectories, each containing a different type of configuration file. Let’s look at a few of those subdirectories:

etc/passwd:In this subdirectory you will find the user database, with fields giving the username, real name, home directory, encrypted password, and other information about each user. Note that the password is encrypted. You cannot go to this directory and read other people’s passwords. That means that when the user manager runs, it is actually reading its information from this directory.

/etc/group:This subdirectory is quite similar to /etc/passwd, except that it describes groups instead of users. All the information about a group, including a list of user accounts that are members of that group, are stored in this directory.

/etc/inittab: This is where you change the configuration file for init. If you will recall, we previously discussed the pivotal role that init plays in a Linux system. It is recommended that you do not reconfigure this unless you are very sure of what you are doing. A novice user should not touch this directory.

/etc/motd: You may have noticed that after logon you get a brief message. This is called the message of the day, and it is found in this directory. This message is often used by system administrators to send information to all users.

/dev:This directory contains device files. Remember that Linux treats all the drives as files. All hard drives start with hd, and floppy drives start with fd. The main hard drive might be named /dev/hd0. The floppy drive would be called /dev/fd0.

/mnt: Although you may not be aware of it, any drive must be mounted prior to its use. The process of mounting a drive involves the operating system accessing it and loading it into memory. In Windows, this is all completely transparent. In modern versions of Linux, it is almost transparent. Most temporary storage drives, such as CD-ROMs and floppy drives, are mounted. The operating system does this for you, however. In older Linux/Unix systems, you had to use shell commands to mount the floppy drive before you could access it. This is no longer the case. However, you will find your floppy in a subdirectory of the /mnt directory, where all mounted temporary storage devices are found.

/boot:This directory contains those files that are used by the bootstrap loader. This means that LILO will look here for files it needs, as will GRUB (remember that with Linux 9.0, GRUB is the default boot loader instead of LILO). Kernel images are often kept here instead of in the root directory. This directory is critical to the boot process. It is another area that the novice user should leave alone.

/usr: Some commands are in /bin or in /usr/local/bin. This directory also contains /usr/share/man, /usr/share/info, and /usr/share/doc, where you will find documentation. This is where you will find all of those manual pages accessed by the man command.

It is not important that you memorize all of these directories. However, a basic familiarity with what is in the directories would be useful. This also leads us to the topic of maneuvering around the directories from the shell. There are a few rather simple commands that you can use to maneuver in the shell. You have seen the cd command. You can type in cd followed by the name of the directory and you will change to that directory. If you then type in just cd and press Enter, you will go to your home directory. Both of these commands are shown in Figure 19.5.

click to expand
Figure 19.5: The cd command.

If you want to use the shell to get to any of the directories we have mentioned, you must first be at the root directory. You then type in cd /mnt (or whatever directory you want to change to). In Figure 19.6 you can see a change to the /mnt directory followed by the ls command being used to list files and subdirectories.

click to expand
Figure 19.6: Using cd to peruse directories.

Managing Users and Groups

Windows provides only very limited capability to manage users or groups from the command line. This is due the fact, previously mentioned, that Windows is designed to be used from the graphical interface. Linux, however, can be used just as effectively from the shell as it can from the graphical desktop environments. In fact, some Linux enthusiasts might argue that it is better to use Linux from the shell. Whether you are using a desktop environment such as KDE or GNOME or are working from the shell, you will still need to manage users and groups.


Though it may seem odd, the first shell command we need to examine is the logname command. This command will tell you what user is currently logged on to a terminal. This might sound odd, but it is necessary. Especially in multiuser environments, you may not know what username was used to log on to a system. This means you will not know what privileges he has. The logname command is typed in just as you see in Figure 19.7, and it tells you the username that is currently logged on to that system.

click to expand
Figure 19.7: The logname command.

Useradd and groupadd

Another command you need to be familiar with is useradd. This command is used to add users from the shell. This command also has a number of flags you can use with it. In Figure 19.8 you can see the display for useradd —help. As you can see, there are several flags you can pass to it.

click to expand
Figure 19.8: The useradd flags.

You can specify a group for the user to belong to, expiration date, password, and everything you might specify through KDE’s user and group manager. However, in many cases you will just specify a username and password. Figure 19.9 shows a new user, named someusername, with the password of password, being added with the useradd command.

click to expand
Figure 19.9: Adding a user with useradd.

As you may have guessed, you also can add groups with a very similar command, groupadd. This command has fewer flags. You can essentially specify the group name and group ID and very little else. Figure 19.10a shows a new group named somenewgroup being added.

click to expand
Figure 19.10A: Using the groupadd command.

Once you have executed this command, you have a new user account with a home directory and the capability to log on to and use the system. You can verify this by using File Manager to look in the home directory and see if a subdirectory has been created for this new user. This would be a sure sign that the user was added successfully. As Figure 19.10b shows, the user has been added successfully.

click to expand
Figure 19.10B: The new user’s home directory.

Another interesting command that is closely related to useradd and groupadd is the groups command. This command will tell you what groups the currently logged-on user is a member of. You can see this command used on the root user in Figure 19.11.

click to expand
Figure 19.11: The groups command.

As you can see, managing users and groups from the shell is not really any more difficult than from the graphical desktop environments. It may be a little less visually appealing, but you can still perform the required functions.

 < Day Day Up > 

Moving From Windows to Linux
Moving From Windows To Linux (Charles River Media Networking/Security)
ISBN: 1584502800
EAN: 2147483647
Year: 2004
Pages: 247
Authors: Chuck Easttom © 2008-2017.
If you may any questions please contact us: