linux study notes (including text editor)


Introduction Section

1.CPU registers, L1 cache, L2 cache are stored, L1, L2 cache is called the first and second layers
DRAM is a dynamic random access memory, which is the main component of main memory
DDR data transfer speed is double DDR2 , DDR3
the SRAM static random access memory, more transistors used in the design of the number, the higher the price, as a cache in the CPU.
a ROM BIOS read-only memory, for example, is coded into a memory chip, non-volatile memory , no electricity may be stored, but also Firmware

Originally display adapter with CPU, but with the computing power requirements increase, the emergence of GPU
2.SSD with our hard work is not the same, but soon, we can now generally SSD for system disk, because it is really fast, and then HDD put things
3.CPU into RISC and CISC design concepts based on


The first chapter,
nonsense


Chapter II Planning and host disk partition
linux, almost all of the hardware device files in the / dev directory in

The purpose of zoning: consider the effectiveness of the security system of data

MSDOS (MBR) partition table format and limit
disk's partition table placed in the first sector of the disk, because the partition table is only 64bytes, can accommodate up to four pen recording partition, (primary partition) a hard disk but can also be separated more partitions, where additional sectors used to record the partition extends in the front several sectors distributed to each partition according to the partition information, the partition extends at most only one, but it can continue to cut out the logical partition

And a primary partition extending up to four partitions
extending partitions up a
logical Alto to be cut out by a partition extending
only primary and logical partitions can be accessed as data formatted partition

GUID partition table, GPT partition table
so-called logical block address (LBA) to deal
with only the first 512bytes MBR different block recorded, GPT using LBA 34 is recorded, and finally the entire disk 33 LBA also be used to backup
GPT partition without a main, extending the concept of logical partitions ,, each be master, can all be formatted

Host program is loaded hardware driver aspects, mainly BIOS and UEFI
1.BIOS MBR boot with
the entire boot process to action before the operating system should look like this:
BIOS: the boot active execution of this dead stuff written on the board, will recognize the first bootable device
MBR: boot record blocks in the first sector of the first bootable device containing the boot manager
boot manager: a core file can be read to perform the software
core file: start the operating system features

Boot manager can provide a menu for users to select different boot project
2.UEFI, BIOS boot with GPT
UEFI equivalent of a low-level operating system, load the driver to control hardware

Under 2.2.4 linux installation, select the disk partition (extremely important)

Linux directory tree is a tree of files, but the files are actually stored on disk partitions so we used the concept of mount
mount: the use of a directory as a point of entry, the disk partition data is placed in the directory

That is, store the file directory will correspond to the actual disk partitions


Chapter III Installation centOS


Chapter Four for the first time login and online help

[Ctrl] + [Alt] + [F2] ~ [F6]: Sign text interfaces tty2 ~ tty6 terminal;
[the Ctrl] + [the Alt] + [Fl]: graphics interface desktop.

Ctrl C to stop the current action
Ctrl D is equivalent to exit quit

date --help help
man date operating instructions
man -k man to find a system file if it contains the keyword man to
man -f man to find the man documentation system with this directive relating to
4.3.3 info page

4.4 text editor Nano
Nano to turn named text.txt in the
data written to disk synchronization Sync
su- this command allows you to become root identity


Chapter V linux file permissions and directory configuration

Type and file permissions
The first character of the file is a directory, files and links
in the next character in groups of three, Larry [rwx] combination, represent the owner, with the user groups, as well as other user permissions
-rwxr-xr-- similar to that of
the second column indicates how many file names connected to the node
of the third column shows the account owner of the file
in the fourth column represents the file belongs to a group of
fifth column is the file capacity size

5.2.2 How to modify file attributes and permissions
chgrp: change the file belongs to a group
chown: change the file owner
chmod: change file permissions, SUID, SGID, SBIT characteristics and so on

5.2.4 linux file types and extensions

The type of file
we mentioned earlier - the beginning of the file as a regular file regular file, is divided into plain text files ASCII (almost all of us can be used as a file set are of this type), binaries (linux is available execute files have fall into this category), the data format file (some programs in the course of the operation reads certain file formats, such as when you sign up will log data is stored)

Directory (head d)
connecting profiles (the beginning of L) is a shortcut to
the device and the device file block device hard disk file (b) and this keyboard device file character (c)

Extension
extension under Windows is .com, .exe, .bat, can execute under linux, but just look at the ability to perform in front of the presence or absence of x
just to let you know the type of the file name extension so it files
* .sh: script or batch files (scripts), because the batch file is written using the shell, so it compiled the extension .sh Hello;
* the Z-, * .tar, * .tar.gz, * .zip, * .tgz: compressed packed files. This is because the compression software were gunzip, tar, etc., due to
different compression software, whichever is related to the extension of Hello!
* .html, * .php: page documents, representing the HTML page PHP file syntax and grammar of Hello! .html files using web
page browser to directly open, as .php files, you can browse through the server-side client-side browser, in order to obtain operational
web results after it!

5.3 linux directory configuration
requires the root directory (/) where the partition should be small as possible, and because a common software programs are installed and preferably not in the same root directory of the partition grass, holding the root directory as small as possible, so good effect, but the root of the file system where the problem is not easy

FHS predetermined
first portion: FHS sub-directory must exist Go
/ bin placed under single-mode instruction can also be operated
/ boot files placed apart opportunity to use
any device with an interface device on / dev linux systems are in file exists in the form where
/ etc system configuration files
/ lib system libraries
/ opt third-party software such as 360 family bucket Cooperation

/ usr refers to the Unix software resource Unix operating system software resources, not user data, all the default software are placed here, occupying large capacity
/ var refers primarily for file normality changes, including the cache, log on file, program file and many more


Chapter VI linux file and directory management

Relative path / cluster / raid / output / taiwan2006 / smoke this directory, another directory in / cluster / raid / output / taiwan2006 / cctm,
then I from the first to the second directory to go, how to write more convenient ? Of course, "cd ... / cctm" more convenient Hello! Right!
Absolute path accuracy better

6.1.2 directory related operations
. This layer represents the directory
... on behalf of parent directory

  • Representatives before a working directory
    ~ on behalf of the current user's home directory where identity
    - account on behalf of the user account's home directory
    (the directory will be all there is. ... and these two directories)

Common treatment directory command
cd: Transform directory (Behind cd plus relative or absolute directory directory can also add ... etc or)
pwd: Displays the current directory pwd [-P] -P is a definite path, rather than using links link path
mkdir: create a new directory
rmdir: delete an empty directory
6.2.2 copy, delete and move cp, RM, mv
cp ~ / .bashrc / tmp / bashrc
cp -i ~ / .bashrc / tmp / bashrc (- i will check the operation means when the cover when the file already exists for the target)
to the current directory
[the root Study @ ~] # CD / tmp
[@ Study the root tmp] # CP / var / log / the wtmp. <== I want to copy to the current directory, the last. Do not forget

rm delete
[root @ Study ~] # cd / tmp
[root @ Study tmp] # rm -i bashrc
rm:? the Remove Regular File `bashrc 'the y-
If we add -i option will take the initiative to ask Oh, you deleted to avoid wrong filename!

mv move
[root @ study ~] # cd / tmp directory enter
[root @ study tmp] # cp ~ / .bashrc bashrc copy a file
[root @ study tmp] # mkdir mvtest create the directory
[root @ study tmp] # mv bashrc mvtest move into this directory
will move a file to a directory to go, it is to do so!

6.3 file content query
cat by the first line displays the file contents
tac last line is just beginning to show cat written backwards your mother's
head just look at the first few lines
tail butt look at a few lines.

Example: [root @ study ~] # cat / etc / issue directly review
\ S
Kernel \ R & lt ON AN \ m
/ Issue plus line number [root @ study ~] # cat -n / etc
print length like this:
1 \ S
2 Kernel \ R & lt ON AN \ m
. 3

tac hand, just rows to even think about writing a letter to be written backwards you press a daft!

head
[the root Study @ ~] # head /etc/man_db.conf By default, the display in front of ten rows! To display the first 20 lines, you have to be like this:
[root @ Study ~] # head -n 20 /etc/man_db.conf this way you can specify how many rows to display it before the
tail with a gross head is the same ~!

6.4 file with default permissions and directory permissions hidden
6.4.1 default file permissions: umask
will display four numbers such as 0022
The first group with special privileges, let's take care of him after the words are u, g, o's permissions
to note: umask scores show that the default values need to lose privileges, because r, w, x are 4,2,1 points, then it means 0 rwx, if it is 2 what it represents, it is for rx slightly

6.4.2 File hidden attribute
the chattr (hidden attribute profile)
[the root Study @ ~] # the chattr [+ - =] [ASacdistu] file or directory name

[+]: Increase in a certain specific parameter, other parameters not originally present move.
[-]: remove one particular parameter, other parameters exist originally not move.
[=]: Setting constant, and only later by the parameters
i: i This can very much! He can make a file "can not be deleted, renamed, set up the link can not write or add data! "
There are a great help for the security of the system! Only root can set this property

For example:
[root @ study ~] # CD / tmp
[root @ study tmp] Touch attrtest # <== Create an empty file
[root @ study tmp] # chattr + i attrtest <== i is given attribute
[root @ study tmp] # rm attrtest <== try to delete look

Once i set permissions, even root can not delete the
[root @ study tmp] # chattr -i attrtest cancel permission i
6.4.4 Observation file types: file
using
[root @ study ~] # file ~ / .bashrc
to

Search 6.5 instructions and file
search 6.5.1 script file name
with which [root @ study ~] # which [-a] command
For example:
[root @ Study ~] # Which ifconfig
/ sbin / ifconfig

[root @ study ~] # which which
can
search for file names 6.5.2 file
whereis
[root @ Study ~] # whereis ifconfig
ifconfig: / sbin / ifconfig /usr/share/man/man8/ifconfig.8.gz


Chapter VII linux disk and file system management

GPT partitions recommended
7.1.2 file system characteristics
of each set of file attributes OS / different permissions, the data required to store these files need to be partitioned Lv format
linux file system Ext2 orthodox

The operation of the file system
superblock: overall record this information, including file system inode, and so the total block
inode: attribute record files, each file occupies one inode
block: Record contents of the file will take up more than if the file is too large a block
the performance of ext2 file system 7.1.3 linux
block data
in principle, the size and number of the block formatting can be not completely changed again (unless reformatting);
at most can be placed in a data file in each block;
Deck, if the block size is larger than the file, the file will occupy a plurality of block number;
deck, if the file is smaller than the block, the remaining capacity of the block is not able to be used again (wasting disk space).
That can only store data for each block of a file only, if a large block would be a waste Oh
data stored in the inode table
access mode of the file owner and group capacity, setup time, changing time etc
each file inode it occupies only a right, under linux, each file occupies an inode, and to allocate more being given to the document used in accordance with the size of the file contents

7.1.4 Relations with the directory tree
inode itself does not record the file name, record the file name is mentioned it before in the block directory permissions so-called new w / delete the file name and directory of related
words, you change the file name It is to write to the directory

Simple 7.2 file system
df show disk usage

7.2.2 entity links and symbolic links
on links, are two
hard link: First, we know only the file name and directory, whereas the content and inode related to it, so we have multiple file names correspond to the same inode number, then, it is hard links, and that is it, you put any one of the deleted file name, inode and block are also still exist, the data also
note: hard link across file systems can not, can not link a directory
symbolic link (symlink): equivalent to establish a direct shortcut

7.3 disk partition, formatting, and loading test
lsblk: List all disks on the system information
7.3.2 Partition: gdisk for GPT, fdisk for the MBR
[the root Study @ ~] # GDisk / dev / VDA < == closer look, do not add a digital Oh!
p is to look at the output of the current status of the disk
gdisk only root privileges to perform the
first lsblk can be used to view disk information, and then use gdisk of one disk partition listed
as gdisk / dev / sda2
remember to su to get root privileges ( cancel root privileges with Ctrl + D)

7.3.5 file system mount and unmount
a single file system mounted should not be repeated in different mount points in
a single directory should not be repeated mount multiple file systems
to mount point as a directory, in theory, should be empty city directory go

7.4 Setting the boot mount

7.5 build replacement memory space of the
special observation 7.6 operating system file
, although can be partitioned with gdisk / fdisk ,,, but it is which must query the partition table


Chapter VIII of the file and the file system compression, packaging, and backup
8.1 linux system common compression instruction

gzip
[dmtsai@study ~]$ gzip [-cdtv#] 檔名
[dmtsai@study ~]$ zcat 檔名.gz

[dmtsai Study @ ~] $ CD / tmp
[dmtsai Study @ tmp] $ CP / etc / Services.
[dmtsai Study @ tmp] -v $ the gzip Services
(-v: may exhibit the original document / file compression ratio case and other information)
-d: decompressing parameters;
[dmtsai @ Study tmp] $ gzip -d services.gz pay attention to your decompression object is a compressed file, which is .gz

[Dmtsai @ study tmp] $ zcat services.gz can read the contents of the source file decompressed

xz usage is similar to
[dmtsai @ study ~] $ xz [-dtlkc #] filename
[dmtsai @ study ~] $ xcat file name .xz

8.3 Packing Instruction: tar
compression pressure is to a large document file into a small
package refers to a lot of data packets into a file, a directory instead of the compressed files are
packaged similar to the Windows WinRAR

tar [-z | -j | -J] [cv] [-f to be the establishment of a new file name] filename ... <== packing and compression
-t: look at the contents of the package file which contains a file name, look at the focus "files name "wants;
-j: bzip2 compressed by supporting / decompression: at this point the best name for the file .tar.bz2 *
-v: in the compression / decompression process, the file name being displayed come out!

time tar -zpcv -f /root/etc.tar.gz / etc
view the data contents of the tar file
[root @ study ~] # tar -jtv -f /root/etc.tar.bz2
decompress
tar -jxv -f / root / etc.tar.bz2

8.4 XFS file system backup and restore
application background: usually for use tar to back up the system directory tree, if you want to back up and restore the entire file system for it. . . Look down

Cumulative backups
after that is the first time you use xfsdump full backup, such as when a file system over a period of time after a second xfsdump natural operation, the cumulative backup, that new backup data at this time will only record the first complete there are differences in the backup files only
xfsdump not mount the file system backup is not supported! So only back up the mounted!
xfsdump must use root privileges to operate (relationship involving file system)
xfsdump only backup XFS file system ah!
xfsdump backed up data (file or storage media) can only make parsing xfsrestore
xfsdump UUID is through the file system to distinguish the respective backup file, it can not back up two file systems with the same UUID

xfsdump [-L S_label] [-M M_label ] [-l #] [-f file backup] data to be backed up
, for example: xfsdump -I
-l: a lower case L is the specified level 0 ~ ~ 9 levels of 10 Oh! (Default is 0, that is, a full backup)
-f: is somewhat similar to tar it! Followed by the resulting file, may then e.g. / dev / st0 device file name or the like other general file filename
-I: lists the current state information from the backup / var / lib / xfsdump / inventory

XFS file system restore xfsrestore
xfsrestore -I
xfsrestore [-f file backup] [-L S_label] [-s] be restored directory <== single file system-wide recovery
-f: back contact is to back up files! The business community is likely to take / dev / st0 tape drive, etc.! We then file name here!
-I: xfsdump with the same output! Can check the backup data, including the name of the Label and the backup time
simple task is to / boot entire restoration to the most original state - how do you deal with? In fact, very simple, I
have wanted to know that as long as the file is restored, and the session label name of the file,
the specific reduction
xfsrestore -f /srv/boot.dump -L boot_all / boot

Summary This chapter
 Compression: tar -Jcv -f filename.tar.xz to be compressed file or directory name
 query: tar -Jtv -f filename.tar.xz
 decompressing: tar -Jxv -f filename.tar.xz -C for unzipped
 xfsdump instructions may backup file system or a single directory
 xfsdump for backup when the file system, level differences can be 0-9 backup! Where level 0 is a full backup;
 xfsrestore instructions can be build to restore the backup file xfsdump;
when  To create a disc to burn data, can be built using the mkisofs command;
 can be written to a CD or DVD burner through wodim
 dd can back up a complete partition or disk, because dd can read the data on the disk surface sector
 cpio backup command is very good, but must have to match similar find instructions to read data into the file name to be backed up before backup action
for.


Chapter IX program editor vim
linux most of the configuration files are plain ASCII text form of existence, so use simple text editing software to edit settings

Vi 9.2 using
general instruction mode vi a file open instruction enters the general mode of copy and paste can be deleted but can not edit
edit mode Press i, o, a, r, I, O, A, R Esc to exit the edit mode mode
command line input mode command [: /?] can enter the command-line command mode
after the mode is not switched to each other two

Operation:
using {vi filename] Usually enter command mode
/ bin / vi welcome.txt to open if the file exists on the new old file if there
Press [I] which is to enter edit ai
Press [ESC] to exit edit
then
press [: wq] to save
with [ls -l] can be viewed

linux under the multi-profile as a text file, it can be set using the editing vim
vim program editor can be considered
vi general instruction mode has three modes, edit mode, the instruction sequence pattern

Enter the edit mode is almost just remember: [i, o, R] o is new in particular three buttons and a substituent of R


Chapter X BASH understand and learn
to use the terminal command issued under linux is handled through the bash environment Oh

What is the shell: We need to let the user's operating system, that is, the user can command center through the application, so that the core task of reaching the hardware we need, then the application in the outermost layer, so called shell slightly shell program
that is as long as the operation of the application program interfaces will be called a case (narrow aspect the shell program is software instruction sequence, including bash)

10.1.4 bash shell functions
/ bin / bash
command editing capabilities (history): Memory used instructions recorded .bash_history (sign before recording a previous lock instruction execution)
command file completion feature: (tab key) :
 [the Tab] connected to the back of the first word of a string of instructions, for the command completion;
 [the Tab] then after the second word in the string of instructions, for the "file filled"!
Function setting command aliases: (alias): For example: alias lm = 'ls -al'

10.1.5 determines whether bash shell builtin:
type [-TPA] name
e.g.
type ls type cd

Published 44 original articles · won praise 9 · views 3356

Guess you like

Origin blog.csdn.net/puying1/article/details/98885770