1.Openstack
监控工具:zabbix
Docker
Python
RHCSA, RHCE, RHCA (Certified)
Linux distributions:
Slackware:
Suse, Opensuse
Debian:
Ubuntu, Mint
Redhat:
Rhel, Fedora, CentOS
ArchLinux
Gentoo
Lfs:linux from scratch
3. Package Manager:
Rpm:
RHEL, Fedora, Suse, Cnetos
Dpt:
Debian, Ubuntu
Distinguish internal and external commands:
#:type command
/usr: (Universal shared read-only data)
4.SET-C suppress content overwrite output to existing file
tr 转换或删除字符
5.Linux Text Processing Three musketeers:
grep: Text Filtering tool (GREP,EGREP,FGREP)
sed:stream editor,文本编辑工具 awk:linux上实现gawk,文本报告生成器 grep:global search regular expression and print out the line 作用:文本搜索工具,根据用户指定的“模式”对目标文本逐行进行匹配检查:打印匹配到的行 模式:由正则表达式字符及文本字符所编写的过滤条件
6. Read-Only variables:
ReadOnly name, declare–r name
7. Custom Exit Code:
Exit [n]
8.Vim editing
(line number)
Set Nu
Set Nonu
(Brackets match)
Set SM
Set NOSM
(Auto indent)
Set AI
Set Noai
(Highlight Search)
Set Hlsearch set Nohlsearch
(Syntax highlighting)
Syntax on syntax off
(ignores character's case)
Set IC Set Noic
9.bash condition Test
[Expression] [[Expression]]
Combination condition test:
The first way;
Command1 && Command2
Command1 | | Command2
! Command
[-E file] && [-R File]
The second way:
Expression1–a Expression2
Expression1–o Expression2
! Expression
You must use a test command:
eg: [-f/bin/cat–a–x/bin/cat] && Cat/etc/fatab
10. File lookup:
Locate,find
Locate: Fast lookup, Fuzzy Lookup, non-real-time lookup
Locate keyword
Find: Find slow, exact find, real-time Find
Find [option ] ... [Find Path] [Search Criteria] [Handling Action]
Combination Condition:
with:-A
or:-O
Non:-not,!
! A–a! B =! (A–o B)
! A–o! B=! (A–a B)
Eg:find/tmp (-not–user root–a–not–name ' fstab ') – LS
Find/tmp-not (-user root-o-name ' fstab ') – LS
based on File size lookup:
-size [+|-] #UNIT
Common units: K,m,g
based on timestamp:
in days:
-atime,-mtime,-ctime
in minutes:
-amin,-mmin ,-cmin
Lookup based on permissions:
-perm [+|-]mode
Processing action:
-print: Default processing action, display to screen
-ls: Similar to executing the "ls-l" command
-delete for a found file: Delete the found file
-ok command {}\; executes command-specific commands for each file found: interacts with each file before execution;
-exec command {}\; Executes commands specified by command on each file found;
Note: Some commands do not accept too many arguments, and the command executes with an error, and the following methods circumvent this problem:
Find |xargs coomand
Eg:find/etc-size +1m-type-f
Find/-nouser–a-nogroup-a-atime-7
Find/etc-not-perm +222
11.Linux Disk Management:
Disk Management, File system management
Basic principles of RAID, LVM2
Network management: TCP/IP protocol, Linux network property configuration
Package management: RPM, yum
Process Management: Htop, glance, tsar
Sed and awk
I/O ports:i/o device address;
all documents;
12. HDD Interface type:
Parallel:
ide:133mb/s
scsi:640mb/s
Serial:
sata:6gbps
sas:6gbps
usb:480mb/s
/dev/dev_file device file name for the disk device:
Ide:/dev/hd ...
SCSI,SATA,SAS,USB:/DEV/SD ...
- To see if the kernel has identified a new partition:
Cat/proc/partitions
Notifies the kernel to re-read the hard disk partition table:
Partx-a/dev/device
-N m:n
Kpartx-a/dev/device
-F Force
CentOS 5: Using Partprobe
Partprobe [/dev/device]
14. Create File system:
MKFS Command:
(1) mkfs.fs_type/dev/device
(Ext4,xfs,btrfs,vfat)
(2) mkfs-t Fs_type/dev/device
-L ' label ': Volume label
Mke2fs:ext Series File system dedicated administrative tool
-t {EXT2|EXT3|EXT4}
-b{1024|2048|4096}
-l ' label '
-j: equivalent – T ext3
Mkfs.ext3 = mkfs-t ext3 = mke2fs-j = mke2fs-t ext3
-I #: Create an inode for each number of bytes in the data space, this size should not be less than the size of the block
-N #: null for data How many Inode
-M #: The percentage of space reserved for administrative personnel
Mkswap: Create swap partition
Mkswap [options] Device
-l ' LABEL '
Premise: adjust its partition ID to 82
Other common tools:
Blkid: Block device properties Information view
Blkid [OPTION] ... [DEVICE]
-U UUID: finds the corresponding device according to the specified Uuidl
-l Label: finds the corresponding device according to the specified label
E2label: Manage label for ext series file system
#e2label DEVICE [ LABEL]
TUNE2FS: Reset the value of the EXT series file system adjustable parameter
-L: View the Super block information for the specified file system: Super Block
-l ' LABEL ': Modify volume label
-M #: Modify the percentage of space reserved for administrators
-j: Upgrade ext2 to Ext3
-o: File System properties Enable or disable
-o: Adjust default mount options for the file system
-u UUID: Modify UUID number
Dumpe2fs:
-H: View Super Block info
- File System Detection:
Fsck:file system Check
Fsck. Fs_type
Fsck–t Fs_type
-A: Auto fix error
-r: Interactive fix error
Note:fs_type must be the same as the file type already on the partition
E2fsck:ext series file-specific detection and repair tool
-Y: Auto Answer Yes
-F: Forced repair
16. File System mount:
Mount DEVICE Mount_point
Mount: Displays all devices that are currently mounted on the system
Mount [-FNRSVW] [-t vfstype] [-O options] Device dir
Device: Indicates which devices to mount:
(1) device files: e.g./DEV/SDA4
(2) Label:-LLABEL
(3) Uuid,-uUUID
(4) pseudo file system name
Dir: Mount point
Pre-existing, it is recommended to use an empty directory
Common options:
-T Vsftype: Specifies the type of file system on the device you want to mount:
-R ReadOnly
-W Read and write
-N Do not update/etc/mtab
-A automatically mounts all devices that support automatic mounts (defined in the/etc/fstab file)
-LLABELSpecifying mounted devices with a volume label
-UUUIDSpecify the device to mount with the UUID
Note: View all devices that the kernel traced to itself: cat/proc/mounts
-O options (option to mount file system)
Async: Async Mode
Sync: Synchronous mode
Atime/noatime: Include Directories and files
Diratime/nodiratime: Access timestamp for directory
Auto/noauto: Whether auto mount is supported
Exec/noexec: Whether to support running applications on the file system as a process
Dev/nodev: Whether to support the use of device files on this file system
Remount; re-mount
Uninstall command:
Umount
To view the process that is accessing the specified file system:
Fuser-v Mount_point
Terminates all processes that access the specified file system:
fuser-km Mount_point
Mount Swap partition:
Enabled: Swapon [OPTION] ... [DEVICE]
-A: Activate all swap partitions
-P Priority: Specify precedence
Disabled: Swapoff [OPTION] ... [DEVICE]
Memory Space usage Status:
free [OPTION]
-M | -G
17.bash Scripting User interaction:
Read [option] ... [Name ...]
-PPROMPT
-TTIMEOUT
Bash-n/path/to/some_script
Detecting syntax errors in a script
Bash-x/path/to/some_script
Debug execution
18.RAID:
Redundant Arrays of Inexpensive Disks
Improved IO capability:
Parallel disk Read and write
Increased Durability:
Disk redundancy
Level: Multiple disk organizations work together in different ways
How the raid is implemented:
External disk array: Adapter capability with expansion cards
On-chip RAID: Motherboard integrated RAID controller
Software RAID:
Levels: Level
RAID-0:
RAID-1:
RAID-2:
...
RAID-5:
RAID-6:
RAID-10:
RAID-01:
RAID-0:
Read and write performance improvements:
Free space: Nmin (s1,s2 ...)
No fault-tolerant capability
Minimum number of disks: 2,2+
RAID-1:
Read performance improvement write performance decreased slightly:
Free space: 1Min (S1,s2 ...)
Have redundancy capability
Minimum number of disks: 2,2+
RAID-5:
Read and write performance improvements:
Free space: (N-1)Min (S1,s2 ...)
Fault tolerance: a piece of disk
Minimum number of disks: 3,3+
RAID-6:
Read and write performance improvements:
Free space: (N-2)Min (S1,s2 ...)
Fault Tolerance: 2 disks
Minimum number of disks: 4,4+
Mixed type:
RAID-10:
Read and write performance improvements:
Free space: N*min (S1,s2 ...)/2
Fault tolerance: Each group of mirrors can only have a bad piece
Minimum number of disks: 4,4+
RAID-01:
RAID-50:
JBOD:
Combine the space of multiple disks into one large contiguous space for use
Implementation method:
Hardware implementation method, software implementation method
Implementation of software RAID on Centos 6:
Combined with MD (multi devices) in the kernel
Mdadm: Modelling Tools
Format: mdadm [mode] <raiddevice> <component-device>
Supported RAID levels:
LINEAR, RAID0,RAID1,RAID4,RAID5,RAID6,RAID10, etc.
Mode:
Create:-C
Assembly:-A
Monitoring:-F
Management:-f,-r,-a
<raiddevice>:/dev/md#
<component-devices>: any block device
-C: Create pattern
-N #: Use n block devices to create this raid
-L #: Indicates the RAID level to be created
-A {Yes|no}: Automatically create device files for target RAID devices
-C Chunk_size: indicates block size
-X #: Indicates the number of space disks
-D: Show raid details
mdadm–d/dev/md#
Management mode:
-F: flag specifies that the disk is corrupt
-A: Adding disks
-R: Remove disk
Observe the status of MD:
Cat/proc/mdstat
To stop the MD device:
Mdadm-s/dev/md#
Watch command:
-N #: Refresh interval in seconds:
watch-n# ' COMMAND '
19.lvm2
Lvm:logical Volume Manager Version 2
Dm:device Mapper: A module that organizes one or more underlying block devices into a single logical device
PV Management tools:
PVS: Brief PV information display
Pvdisplay; show details of PV
Pvcreate/dev/device: Creating PV
VG Management tools:
VGs
Vgdisplay
Vgcreate
Vgextend
Vgremove
LV Management tools:
Lvs
Lvdisplay
Lvcreate-l #[mmggtt]-n NAME volumegroup
Lvremove/dev/vg_name/lv_name
To extend a logical volume:
lvextend-l [+]#[MMGGTT]/dev/vg_name/lv_name
Resize2fs/dev/vg_name/lv_name
To shrink a logical volume:
Umount/dev/vg_name/lv_name
E2fsck–f/dev/vg_name/lv_name
Resize2fs/dev/vg_name/lv_name #[mmggtt]
lvreduce-l [-]#[MMGGTT]/dev/vg_name/lv_name
Mount
Snapshot: Snapshot
Lvcreate–l #[mmggtt]–p r-s–n snapshot_lv_name original_lv_name
- DD command: Convert and copy a file
DD if =/PAATH/FROM/SRC of=/path/to/dest
BS-#:block size, copying unit sizes
count-#: How many BS do you copy?
Disk Copy:
DD IF=/DEV/SDA OF=/DEV/SDB
Backup MBR:
DD IF=/DEV/SDA Of=/tmp/mbr.bak bs=512 count=1
Destroying the bootloader in the MBR
DD If=/dev/zero OF=/DEV/SDA bs=512 count=1
Two special devices:
/dev/null: Data black hole
/dev/zero: Spit 0 Machine
21.btrfs File System:
File System creation:
Mkfs.btrfs
-L ' LABEL '
-D <type>: RAID 0, etc.
-M <profile>: RAID 0 RAID 1, etc.
-o<feature>
-O List-all: Lists all supported feature
Properties View:
Btrfs filesystem Show
Mount File System:
Mount-t Btrfs/dev/sdb Mount_point
列表生成方式: (1) 直接给出列表 (2) 整数列表 (a){start…end} (b)$(seq [start [step] end]) (3)返回列表命令: $(COMMAND)
22.Linux Package Management:
Api:application Programming Interface
Posix:portable OS
Program source code? Preprocessing? compilation? Links
Static compilation
Shared compilation
Abi:application Binary Interface
Windows is incompatible with Linux
Library-level virtualization:
Linux:wine
Windows:cywin
System-Level development: c,c++
Application-level development: Java,python,php,perl,ruby
Components of a binary application:
binary files, library files, configuration files, Help files
Package Manager:
Debian:deb,dpt
redhat:rpm
23. View the library files that the binaries depend on:
Idd/path/to/binary_file
Manage and view the library files that are loaded natively:
Idconfig
/sbin/idconfig-p: Displays all available library file names and file path mappings that have been cached by this computer
The configuration file is:/etc/id.so.conf,/etc/id.so.conf.d/*.conf
Cache files:/etc/id.so.cache
Package Management:
Functionality: Package The compiled application's constituent files into one or several package files, so as to quickly and easily implement
Administrative operations such as installation, uninstallation, querying, upgrading, and validation of packages
How to manage Packages:
Using Package Manager: RPM
Using the front-end tools: Yum, DNF
Mans rpm
Package source verification and legitimacy verification:
Integrity Verification:
Public Key cryptography:
Symmetric encryption: Encrypt, decrypt using the same key
Asymmetric encryption: Key pairs (public key, private key)
To import the required public key:
RPM--import/path/from/gpg_pubkey_file
24. Database rebuild:
RPM {--INITDB|--REBUILDDB}
INITDB: Initialization
New if no database exists beforehand; otherwise, no action is taken
REBUILDDB: Rebuilding
Recreate the database directly, whether it is present or not
25. Compile C source code:
First Step: Configure script
--help
Option Categories:
Installation path settings:
--prefix=/path/to/somewhere: Specify the default installation location
--sysconfdir=/path/to/somewhere: Configuration File Installation Location
Step Two: Make
Step Three: Make install
Post-installation configuration:
(1) Export the binary program directory to the PATH environment variable:
Edit File/etc/profile.d/name.sh
Export Path=/path/to/bin
(2) Export Library file path
Edit/etc/ld.so.conf.d/name.conf
Add a new library file in the same directory as this file
To have the system regenerate the cache:
Idconfig [-v]
(3) Export header file:
Implemented in a link-based manner:
In-sv
(4) Export Help manual
(5) Edit/etc/man.conf file
(6) Add a Manpath
Linux Daily Notes-01