2.2 USING LINUX
This section is a brief overview of the Linux operating system. The intention is to overview the basic components in the operating system. An administrator can manage the operating system using the graphical user interface (GUI), or using typed commands. New users often prefer to use the system using the GUI. Advanced users often prefer to use commands to administer the system, they are often faster and more reliable.
Commands can be typed in a command window. Typed commands are case sensitive, and most commands are lower case. Spaces are used to delimit (separate) commands and arguments, so they should also be used when typing. Linux allows users to perform some very sophisticated operations with a single command. But, while learning this should not pose a problem, unless logged in as root. While learning the user is encouraged to use a normal user account so that accidental damage to the system can be minimized.
2.2.1 Some Terminology
The terms below are some of the keywords that are unique to Linux. These will appear during the installation, or during common usage of the system.
2.2.2 File and directories
The directory and file structure of Linux is hierarchical, much like other popular operating systems. The main directory for the system is call root and is indicated with a single slash `/'. There are a number of subdirectories listed below that are used for storing system files, user files, temporary files and configuration files. A sample of the standard directories are shown below, and can be viewed with a file manager, or with keyboard commands. If other disks are used, such as a CDROM, or floppy disk, they are mounted under the root directory. (i.e., there are no `C', `A' or other drives, they are all under `/'.) (Note: the UNIX slash is `/', not the `\' used on DOS.)
A list of some of the more important directories follows with a brief description of each. Most users have their home directories under the '/home' directory. Most of the other directories are of interest to the system administrator.
Every file and directory has a unique name which can be used to refer to it. Sometimes it is useful to be able to refer to groups of files without typing the name of each one. Wildcard allow file and directory names to be matched to patterns. The list below shows some of the wildcards commonly used.
Some examples of filenames with wildcards, and files they would match are shown below.
Filenames can contain numbers, letters and a few other symbols, but care should be used to avoid symbols that also have meaning to Linux, such as the asterisk '*'. File names that begin with a period '.' are system files that are normally hidden. For example, most users will have a file in their home directories called '.profile' or '.login'. These are used when a user logs.
Some of the standard Linux commands for files and directories are listed below. Most of the file and directory names can be used with wildcards.
2.2.3 User accounts and root
Linux follows very strict conventions for file and directory permissions. These require that each file and directory be given specific permissions for public reading, writing and execution. Each user is given their own account with a password, so that access to the system is controlled. Only the root user can access all files and directories on the system. Other users are limited to files they own, or files that have been marked public. Typically the root user is only used for administration, and normal users use non-root accounts. This generally keeps the system safe from careless damage, and security breaches. Each user has their own home directory, normally in the `/home' directory. The permissions for files and directories are set so that the user has complete control over that directory.
The permissions for files can be seen by doing a directory listing with 'ls -la'. This will show flags something like '-rwxrwxrwx jackh user' for a file that everybody can read 'r', write 'w' or execute 'x'. The leftmost 'rxw' is for the user 'jackh', the second 'rwx' is for the group 'user' and the rightmost 'rwx' is for everybody on the system. So if the permissions were '-rwxr--r--' everybody on the system can read the file, but only the owner can write and execute it.
For security reasons, write permissions for files are normally only allowed for the owner, but read permissions are normally given to all. Execute permissions are normally set for all users when the file can be executed, such as a program. Sometimes more than one user wants to have access to a file, but there are reasons to not permit permission to everybody. In this case a group can be created and given permission to use a file.
Commands that are oriented to users and permissions follow.
Most of the user information is stored in the '/etc' directory. For example, user account information is stored in the 'passwd' file. User passwords are stored in the 'shadow' file. Group information is stored in the 'groups' file. It is possible to add users to the system by editing these files, but there are commands that make it easier to update and maintain these files.
The 'passwd' command is used to change user passwords. In general passwords are the main line of defense against unwanted intruders. Most systems will do simple password checks when passwords are entered. In general, if a password can't be found in a dictionary or index of a book it will generally be safer.
2.2.4 Processes
At any one time there are multiple programs (processes) running on a Linux computer. When you run a program it becomes another process also running on the computer. Each process is given it's own unique process ID number (PID). Each process is given it's own private memory space, and allowed to run for a fraction of a second every second.
The list of commands below allow the processes in the computer to be seen. They also allow the general state of the machine to be determined.
Simple commands can be combined together with pipes to make more complicated functions. An example is 'ls | more'. By itself 'ls' will list all the files in a directory. 'more' is normally used to print out text files. But in this case the output of 'ls' is passed (piped) through 'more' so that it only prints one screen at a time. Multiple commands can be combined on a single command line by separating them with a colon ':'. For example the command 'ls ; ls ..' would list the contents of the current directory, then the parent directory.
Output from functions can be redirected to files instead of the screen. For example 'ls > temp' will take the normal output from the 'ls' function, and write it into a textfile called 'temp'. Input to functions can be directed into a program. For example 'sort < temp' will make the file 'temp' the input to the sort command.
Simple batch files can be created by putting a list of commands in a normal text file. The file can then be made executable using the command 'chmod 755 filename'. The program can then be run using './filename'.