I. Boot and Shutdown
1: After successful login, the system starts shell. The normal user prompt is $, and the super user root prompt is #
2: shutdown: only the root user can shut down the shutdown command.
Shutdown [-T seconds] [Option] time [Warning Information]
-K does not actually shut down, only issuing a warning
-H shut down the system service immediately after it is stopped.
-C. Cancel the running shutdown command.
3: Online Help
Man
Info
Ii. Linux Files And Directories
1: Significance of file attributes
Ls [-ails] displays the file name and attributes
[-A] listing all objects
[-I] print inode Value
[-L] details, including size and attribute data
[-S] sort by file size
Ls-AL: list file attributes
Drwxr-XR-x 3 Root 4096 Feb 16 09:59 ..
File Attribute connection count file owner file group file size last modified by file name
There are 10 attributes in this column. The first attribute indicates whether the file is a directory, file, or link file.
[D] Directory
[-] File
[L] link file
[B] interface devices available for storage in Device Files
[C] serial port device in the device file
The following three attributes are a combination of rwx.
[R] readable
[W] writable
[X] executable
The first group is the permissions of the owner, and the owner
The second group is the group permission.
The third group is other permissions not in this group, others
If you want to open a directory, you should also open the X attribute of this directory.
2: The last column is the file name. If there is a "." in front of the file name, this file is a hidden file.
3: Change File Permissions
3.1 Change Group
Chgrp [-R] group name file or directory
3.2 change owner
Chown [-R] account name file or directory
[-R] indicates changing the subdirectories or files in the directory at the same time.
When we copy a file to another user, we must change the group and owner of the file. Otherwise, other users may still be unable to use the file.
3.3 change permission chmod
3.3.1 change the File Permission of the numeric type
R: 4
W: 2
X: 1
For example, [-rwxrwx ---] adds the same group of numbers
Owner = rwx = 4 + 2 + 1 = 7
Group = rwx = 4 + 2 + 1 = 7
Others = --- = 0 + 0 + 0 = 0
Chmod [-R] combines numeric files or directories
3.3.2 use symbols to change file attributes
Use U, G, and O to represent three groups of users, groups, and others.
A Indicates all
Syntax:
Chmod U + (ADD) r file or directory
G-(except) W
O = (SET) x
A
4: File Types
Regular file: a common type of file. The first attribute of the file is [-].
Plain text file
Binary files
Directory: The first attribute of the file is [D].
Link file: The first attribute of the file is [l].
Device Files: related to system peripherals
Block Device File: an interface device that stores data to provide system access. For example, the first attribute of a hard disk. file is [B].
Character (chacter) Device File: interface device of the serial port, keyboard and mouse, etc. The first attribute of the file is [c]
5: The file system in Linux is different from that in DOS.
Each device or hard disk partition forms a file system with its own top-level directory and directory hierarchy. Among various file systems, the top-level directory of a file system is mounted) to the subdirectory of another file system, and finally all the file systems are integrated into a large tree directory structure.
6: main directory
When a user logs in, a special directory is associated with the login name. This is the user's home directory, which is the user's original working directory, files and directories created by users in the system are generally stored in this directory.
7. File System Hierarchy
/_______ | ______ BASIC Program of the bin System
| ______ Special files of the dev Device Driver
| ______ Configuration files used by the ETC system for management
| ______ Home _____ | _______ user1
| _______ User2
| ______ Lib dynamic link to the shared library
| ______ MNT can temporarily Mount other file systems in this directory
| ______ Proc
| ______ Temporary information generated during execution of the TMP program stored in this directory
| ______ USR is a very important directory. It contains subdirectories used to store system configuration files and the most important and useful large software package programs.
| ______ Var login, records of various services in case of problems, and regular service records are recorded in this directory
8. file and directory operations
Create directory mkdir [directory name]
Delete the directory rmdir [directory name]
Only one layer can be created at the time of creation. If you want to delete all the items in the directory, use Rm-RF [Directory].
CP [-drsu] [source file] [target file]
[-U] If the file source file is newer or there is no target file, the copy operation is performed for backup.
Rm [-fir] [file name]
[-F] force Delete
[-I] provide user confirmation (default)
[-R] loop deletion until nothing exists
MV [-u] [source file] [target file]
[-U] When the source file is newer than the target file, there is an action
9. View File Content
Cat [-N] displays the abbreviation of the file concatenate from the first line
[-N] line numbers are output to the screen together
Tac reverse display, opposite to cat
More [file name] Can List objects on one page
Less [file name] allows you to read the file forward and backward.
Head [-N number] [file name]
Tail [-N number] [file name]
10: commands related to file security
Chattr [+-=] [-asacdistu] [file or directory name]
Lsattr [-ar]
Iii. Organization of files on disk
1: Hard Disk Structure
The hard disk contains multiple hard disk disks. Each disk has a read/write head. The set of identical tracks of all disks in the hard disk is the magnetic column. Each track is divided into many areas, each region is called a sector. A sector is the minimum physical storage capacity of a hard disk. The storage capacity of a sector is about 512 bytes.
A block is the smallest unit that can be recorded by a disk and is composed of several sectors. A block is the region where the file content and data are recorded. inode records the attributes of the file and the information placed in the block. Each file occupies one inode.
Generally, there are two data line interfaces on the motherboard. to distinguish the reading sequence of the hard disk, these interfaces are called (primary) and (secondary) respectively)
Each data line can be connected to two ide devices. Therefore, a single motherboard can be connected to four ide interfaces by default.
The Code of each hard disk is as follows:
IDE master hard drive
Ide1 (primary)/dev/hda/dev/HDB
Ide2 (secondary)/dev/HDC/dev/HDD
The hard disk is divided into two areas:
1: Master Boot recorder (MBR)
There are two important things in it: Start the hypervisor and partition table on the hard disk)
2: actual data storage area
The hard disk partition table defines the N disk areas from the X column to the Y column.
Due to limited MBR capacity, there can be only four split records
Superblock: When partitioning a hard disk, each partition is a file system, and the block at the beginning of each file system is a superblock, which is used to store file system size, empty block, and full block, and the total number and other information.
2: storage and organization of files on disks
There is an array on the disk. each of its elements becomes an index node (inode), which stores the management information of each file. At the same time, the system assigns a number to each file stored on the disk to become the index node number, which is used to index the corresponding file records stored in the preceding array. the index node number and file name of a file are stored in the directory at the same time to form a table with the contact file name and file index node number. each pair of file names and index node numbers in the directory is called a link.
An index node number can be linked to multiple file names.
The LS-I command can be used to view the index node number of a file.
Ln [-S] [source file] [target file] creates a new link for an existing file
[-S] provide symbolic links