Three-month study concluded, Linux basics

So far, the study has been three months, and three months is mainly to learn the basics of Red Hat Linux system, to sum up my learning.
Linux learning content:
(1) install a Linux system
(2) basic command.
Everything Linux system is a file

The initialization process
Systemctl restart the service name to restart the service (PID value becomes)
systemctl reload service name to restart the service (pid value unchanged)
systemctl Start Service to start the service name
Systemctl stop service names out of service
Systemctl enable the service name is added to the startup items
Systemctl status service name check the service status
Systemd name service configuration tool name systemctl
command postfix form: - letters example: -a -l - word example: - all --list
horizontal bar can be combined -al

Common system operation command
echo command
echo command output terminal for the extraction string or variable value, in the format of "echo [String | $] variable
data command
data command is used to display the date and time or set the system format "data [option] [format specified +]."
reboot command
reboot command is used to restart the system, the format reboot.
poweroff command
poweroff command to shut down the system, the format poweroff.
wget command
wget command in a terminal Download network file, the format is "wget [parameters] Download."
the ps command
ps command is used to view the system status of the process in the format of "ps [parameters]"
pidof command
pidof command queries a specified service process PID in the format of "pidof parameter name] [service]."
the kill command
Kill command to terminate the service for a specified PID of the process, the format of "Kill process parameters [PID]."
killall command
killall command is used to terminate all a server process corresponding to the specified name in the format: "killall [parameters] [service name]."
the system status detection command
Ifconfi G
the ifconfig command for acquiring the network card configuration and status information, the format of "ifconfig [Network Device] [parameter]."
the uname command
Uname command is used to view system kernel and system version information, the format of "uname [-a] . "
uptime command
uptime used to view the system load information in the format of uptime.
free command
free displays the current system memory usage information, the format of "free [-h]".
5. who command
who signed the host to view the current user terminal information, the format of "who [parameter]."
6. last command
last command is used to log in to view records of all systems in the format "last [parameters]."
7. history command
history command history command executed for display, the format is "history [-c]".
8. sosreport command
sosreport command is used to collect system configuration and schema information and diagnostic output document format sosreport.
Working directory command
1.pwd command
pwd command displays the user's current working directory is located, the format of "pwd [Option]",
2.cd command
cd command for switching the working path, the format of "cd directory name [] . "
3.ls command
ls command displays file information in the directory, in the format of "ls [options] [file]."
four. Text file editing commands
1.cat command
cat command is used to view the plain text files (less contents), the format of "cat [option] [file]."
2. more order
more command is used to view the plain text files (more content), the format is "more [options] file."
3. head command
N lines before the head command is used to view the plain text of the document in the format of "head [options] [file]."
4. tail command
tail command for viewing after the N line plain text document or continue to refresh the content in the format of "tail [options] [file]."
5. tr command
tr command is used to replace characters in a text file, the format of "tr [original character] [target character]."
6. wc command
the number of lines of specified wc command text, words, bytes, the format of "wc [parameter] Text."
7. stat command
stat command is used to store specific information and time to review documents and other information, in the format of "stat file name."
8. The cut command
cut command is used by a "column" extract text characters, the format of "cut [parameter] Text."
9. command diff
diff diff command for a plurality of text files, the format of "diff [parameter] file."
Fives. File directory management commands
1. touch command
time touch command to create a blank file or set of files in the format of "touch [options] [file]."
2. mkdir command
mkdir command is used to create a blank directory, in the format "mkdir [options] directory."
3. cp command
cp command to copy a file or directory, the format of "cp [options] source file destination"
mv command
mv command is used to cut the file or rename the file, the format of "mv [options] source [destination path | target filename]. "
6. rm command
rm command is used to delete a file or directory, in the format "rm [options] files."
7. dd command
dd command according to the specified data block size and number of files to copy or convert the file format "dd [parameter]."
8. file command
type of file command is used to view files in the format of "file filename."
six. Compression packing the search command
1. tar command
tar command is used to package a file compression or decompression, the format of "tar [options] [file]."
2. grep command
grep command is used to perform a search keyword in the text, and display the results match the format of "grep [options] [file]."
3. find command
find command to find the conditions for the specified file, the format of "find [Search Path] Looking operating conditions."

(3) the pipe symbol, and environment variables redirect

Syntax redirector file] [
Clear:> Command> File command 2> file: outputs error information
output redirection operator: <
Append: command >> >> >> File command file & ~~~: all information output
access redirector: <

|: The door to any previous command is supposed to be output to the standard screen as normal data is a command of standard input

&& If the front is successful, the execution behind
|| If the front fails, do the behind
! Negate

Wildcard: The asterisk (*) indicates matches zero or more characters, the question marks represent a single character match, digitally [0-9] represents a single digit match between the characters 0 to 9, the brackets, and (?) the letters in the brackets [abc] match is representative of a, b, c of any three characters in a character.

Escape character:
backslash (\): a variable behind a backslash character string becomes simple.

Single quotation marks ( ''): wherein all variables escaped as a simple string.

Double quotes ( ""): wherein the variable attributes retained without escaping.

Backtick ( ``): the return result executes the commands.

(4) .vim editor and shell script command
mode:
Command mode: control cursor movement, text can copy, paste, delete, and find other work.

Input modes: normal text entry.

Line mode: To save and exit the document, as well as set the editing environment.Three-month study concluded, Linux basics

vim Common Commands
Command Function
dd removed (cut) the entire line cursor
5dd removed (cut) 5 starting from the cursor line
yy copy the entire line cursor
5yy replication 5 lines starting from point
n to display the search command is positioned next string
N to display the search command is positioned in a string
u undo the last operation
p deletes (dd) or copy (yy) had adhered to the back of the data before the cursor

1.if condition test statement
if statement allows conditional test scripts to automate the appropriate command according to the actual situation. From a technical point of view, into a single IF statement is a branch structure, a double branched structure, a multi-branched structure; complexity is raised together with the stepwise flexibility.

single-branch structure if conditional statement by the if, then, fi keywords composition, but only execute preset commands only after conditions are met, the equivalent of spoken "If ...... so ......."
Three-month study concluded, Linux basics
Three-month study concluded, Linux basics
Three-month study concluded, Linux basics
Loops 2.for conditions
for loop statement allows the script once and read a plurality of information, and one by the information processing operation, when the range of data to be processed are used for loop easy to do.
Three-month study concluded, Linux basics
3.while condition loop
Three-month study concluded, Linux basics
4.case condition test statement
Three-month study concluded, Linux basics

(5).用户身份与文件权限
管理员UID为0:系统的管理员用户。

系统用户UID为1~999: Linux系统为了避免因某个服务程序出现漏洞而被***提权至整台服务器,默认服务程序会有独立的系统用户负责运行,进而有效控制被破坏范围。

普通用户UID从1000开始:是由管理员创建的用于日常工作的用户。
UID是不能冲突的,而且管理员创建的普通用户的UID默认是从1000开始的(即使前面有闲置的号码)
命令:
1.useradd命令
useradd命令用于创建新的用户,格式为“useradd [选项] 用户名”。

  1. groupadd命令
    groupadd命令用于创建用户组,格式为“groupadd [选项] 群组名”。
  2. usermod命令
    usermod命令用于修改用户的属性,格式为“usermod [选项] 用户名”。
  3. passwd命令
    passwd命令用于修改用户密码、过期时间、认证信息等,格式为“passwd [选项] [用户名]”。
  4. userdel命令
    userdel命令用于删除用户,格式为“userdel [选项] 用户名”。

文件权限与归属:
文件类型:
-:普通文件。

d:目录文件。

l:链接文件。

b:块设备文件。

c:字符设备文件。

p:管道文件。

文件权限的字符与数字表示

Three-month study concluded, Linux basics

文件的特殊权限

  1. SUID

SUID是一种对二进制程序进行设置的特殊权限,可以让二进制程序的执行者临时拥有属主的权限(仅对拥有执行权限的二进制程序有效)。

  1. SGID

SGID主要实现如下两种功能:

让执行者临时拥有属组的权限(对拥有执行权限的二进制程序进行设置);

在某个目录中创建的文件自动继承该目录的用户组(只可以对目录进行设置)。

  1. SBIT
    SBIT特殊权限位可确保用户只能删除自己的文件,而不能删除其他用户的文件。

    文件的隐藏属性

    1. chattr命令

chattr命令用于设置文件的隐藏权限,格式为“chattr [参数] 文件”。

  1. lsattr命令

lsattr命令用于显示文件的隐藏权限,格式为“lsattr [参数] 文件”。

文件访问控制列表

  1. setfacl命令

setfacl命令用于管理文件的ACL规则,格式为“setfacl [参数] 文件名称”。

  1. getfacl命令

getfacl命令用于显示文件上设置的ACL信息,格式为“getfacl 文件名称”。

(6).存储结构以及磁盘划分
Linux系统中的一切文件都是从“根(/)”目录开始的,并按照文件系统层次化标准(FHS)采用树形结构来存放文件,以及定义了常见目录的用途。
Three-month study concluded, Linux basics

常见的硬件设备及其文件名称

硬件设备 文件名称
IDE设备 /dev/hd[a-d]
SCSI/SATA/U盘 /dev/sd[a-p]
软驱 /dev/fd[0-1]
打印机 /dev/lp[0-15]
光驱 /dev/cdrom
鼠标 /dev/mouse
磁带机 /dev/st0或/dev/ht0

主分区或扩展分区的编号从1开始,到4结束;

逻辑分区从编号5开始。
Three-month study concluded, Linux basics
所谓扩展分区,严格地讲它不是一个实际意义的分区,它仅仅是一个指向下一个分区的指针,这种指针结构将形成一个单向链表。
Three-month study concluded, Linux basics

File systems and data
Ext3: is a journaling file system, the file system can avoid data loss when the system is abnormal downtime, and can automatically fix inconsistencies and erroneous data. However, when a large hard drive capacity, required repair time will be very long, and can not guarantee 100% data is not lost. It will every detail of the entire disk write operation is pre-recorded, in order to be able to trace back to the interrupted portion of downtime after an exception occurs, and then try to repair it.

Ext4: improved version of Ext3, as the default RHEL 6 system document management system, which supports a storage capacity of up to 1EB (1EB = 1,073,741,824GB), and can have an unlimited number of subdirectories. Further, Ext4 file system can allocate block block quantities, thereby greatly enhancing the efficiency of reading and writing.

XFS: is a high performance journaling file system, and is the default RHEL 7 document management system, its advantages particularly evident after the occurrence of unplanned downtime, which can quickly recover files may be corrupted, and the powerful logging computing and storage functions with only a very low cost performance. And it can support a maximum storage capacity is 18EB, which meets almost all needs.

The first to write blog, unskilled. . .
According to Liu Trent teacher of "Linux in respect of such a study" sorted out;

Guess you like

Origin blog.51cto.com/14634821/2456902