Chapter 1 UNIX technical knowledge
The Unix Password File is usually the/etc/passwd file.
The logon items in the password file are generally composed of seven fields separated by colons: Login Name, encrypted buckle, digital user ID (224), digital group ID (20), comment field, start directory (such as/home/rollen) and ShellProgram(/Bin/KSh ).
The starting directory of the UNIX directory is named root, whose name is a character/
The stat and fstat functions return an information structure containing all file attributes.
The characters that cannot appear in the file name include: slash (/) and Null Operator
The path name starting with a slash is an absolute path. Otherwise, it is a relative path.
Each process has a working directory, also called the current working directory. The process calls chdir to change the current working directory.
When logging in, set the working directory to the starting directory, that is, a directory such as (home/rollen), which can be obtained in the/etc/passwd file.
The file descriptor is a small non-negative integer that is used by the kernel to identify the file being accessed by a specific process. When the kernel opens an existing file or creates a new file, it returns a file descriptor, which can be used for reading and writing files.
Every time we run a new program, all the shells will open the standard input, standard output, and standard error to input these three file descriptors, which are connected to the terminal by default.
The open, read, write, lseek, and close functions provide I/O that are not applicable to buffering. These functions work with file descriptors.
A program is an executable file stored on the disk. One of the six exec functions can be used by the kernel to read the program into the memory and execute it.
Each UNIX process has a unique process ID, which is a non-negative integer.
There are three functions mainly used for process control, fork, exec (exec has 6 variations), waitpid.
The data type ending with _ t is called the original data type, which is generally defined in the <sys/types. h> file. They are generally defined using the C typedef description.
When a Unix function fails, a negative value is usually returned, and the integer variable errno is usually set to a value with specific information. But there are also exceptions. For example, some functions do not return negative values, but use other conventions, such as return null.
Errno should know 1) if there is no error, its value will not be cleared by a routine. Therefore, you only need to check its value when the return value of the function fails. 2) No function will set the errno value to 0. All constants defined in the <erron. h> file are not 0.
The User ID in the logon entry of the password file is a numerical value. It is used to identify different users. The system administrator also needs to determine the user ID while determining the login name of a user. You cannot change your user ID. each user has a user ID.
The user with the user ID 0 is the Super User Root. In the password file, the login name of a logon item is usually root.
The Group ID is also a numeric value, which is assigned by the system administrator when determining the user's login name. Generally, in UNIX, a group is used to integrate different users into a department. This mechanism allows different members of a group to share resources, group files (usually/etc/group) map group names to numeric group IDs.
The directory items of each file in the system contain the user ID and group ID of the owner of the file. To store these two values in a directory item, only four bytes are required (assuming they are stored in double-byte shaping). However, if you use an 8-byte login name and an 8-byte group name, it requires more storage space, but it is much easier for users to use a name as a login name than to use a number. Therefore, the password file contains a ing between the login name and user ID. The group file contains the ing between the group name and the group ID.
A signal is a technology that notifies a process of a certain condition. There are three forms of signal processing:
1) Ignore Signal 2) process according to the System Default Mode 3) provide a function called when a signal occurs
Many conditions generate signals. There are two keyboard methods: the interrupt key (usually delete or Ctrl + C) and the Return key (usually Ctrl + \), they are used to interrupt the current process. Another way to generate signals is to use the kill function. When sending signals to a process, we must be the owner of the process.
UNIX always uses two different time values: 1) calendar time 2) process time.