Linux Basics

Linux introduction:
  Linux is a set of Unix-like operating systems that are free to use and spread freely. It is a multi-user, multi-tasking, multi-threading and multi-CPU operating system based on POSIX and UNIX. It can run major UNIX tools, applications and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the network-centric design idea of ​​Unix, and is a multi-user network operating system with stable performance.
  Linux can run on a variety of hardware platforms, such as platforms with processors such as x86, 680x0, SPARC, Alpha, etc. In addition, Linux is an embedded operating system that can run on handheld computers, set-top boxes or game consoles. At the same time, Linux also supports multi-processor technology. Multiple processors work at the same time, which greatly improves the system performance.
  Linux also supports a graphical user interface, but generally speaking, according to the author's experience, as the actual production environment of the project, Linux generally uses a pure character interface. The purpose is very simple, reducing unnecessary resource overhead and improving operating efficiency. In addition, everything is a file in Linux, I believe that people who have used Linux have a profound experience!

Directory structure:
/ #Root directory
bin sbin usr sys home etc lib dev cgroup root selinux srv, etc. #First-level directory under the
root directory Bin and sbin under the root directory, bin and sbin under the usr four directories are used for To save system commands, the commands under bin can be executed by ordinary users, and the commands under sbin can only be executed by the root superuser. The boot in the
root directory is the user's startup data directory
. The dev in the
root . System configuration file directory The lib in the
root directory is the function library directory
. The sys and proc in the root directory are the memory overload point directories, and this directory cannot be operated.
The tmp in the root directory is the temporary directory The
root in the root directory is the home directory of the super user The home
in the root directory stores the home directory of ordinary users and other

files in different colors of Linux (there may be differences between different versions):
blue files ----------Directory
White files----------General files, such as text files, configuration files, source files, etc.
Light blue files------- link File, mainly the soft link file established by using the ln command
Green file----------executable file, executable program
Red file----------compressed file or package file ( Or there is a wrong file)

command prompt:
#--------superuser (root) prompt
$--------- normal user's prompt
~-------- The current directory (the directory under the home directory)

Command format:
command [options] [parameters] #Most commands are in this format, options and directories can be added or not, such as ls -l /etc/ and ls - l and ls three different formats of commands

Command effective order:
First order: Execute the command executed with the absolute path or relative path.
Second order: perform aliasing.
Third order: Execute Bash's internal commands.
Fourth order: Execute the first command found according to the search directory order defined by the $PATH environment variable.

Tab key completion:
Use the Tab key to automatically complete the file name or complete the command. If there is the same initial letter, pressing twice will list the command or file name that starts with the input letter.

Create a file link (soft link is recommended):
hard link: Except the name and the original file can be different, everything else is the same, modification affects, deleting one does not affect the other, cannot cross partitions, cannot be used for directories
Soft link: similar to Windows shortcut keys, i-nodes are different, modification affects, delete the original file soft link It will be invalid. When viewing permissions (or other information), you should check the original file. When creating a soft link, the source file must be written as an absolute path.

User and user group:
User: those who use the operating system
User group: those with the same system permissions A group of users
A user can belong to multiple user groups, one is the main user group, and the other is the subsidiary group
/etc/group Stores all user group information in the current system, divided into four groups separated by colons: group name/group password Placeholder/group number (0-499 is reserved for the user group number for the system)/list of user names in the
group of user names in the group is empty, there may not be any users, there may be only one user name that is the same as the group name
/ etc/gshadow stores the user group password information in the current system, which are: group name/group password/group manager/list of user names in the group. When the
group password is !, it means that the group password is empty, that is, no password is
stored in /etc/passwd All user information in the current system, respectively: username/password placeholder/user number/user group number/user comment information/user home (home) directory/shell type
/etc/shadow Store the user password in the current system Information, respectively: username/password (one-way encryption password)/etc.

System operation level:
0 shutdown
1 single user
2 Not fully multi-user, not including NFS service
3 Fully multi-user, usually used level
4 Not assigned
5 Graphical interface, if the graphical interface is not installed, use the init 5 command and an error will be reported
6 Restart
Use the init command to run the corresponding system level
Use runlevel queries the current level of the system, 3 5 means it was 3 before, now it is 5, and N means no level.
Personally it is recommended not to click the fork button to close the window, but to use the logout command (or use the ctrl key + d on the command line) to exit and then close , otherwise it will occupy the number of Linux users. The number of Linux users generally allows about 256

shells. Introduction:
Shell is a command line interpreter in Linux, which parses commands into binary languages ​​that the computer can understand, and parses the results into specific languages ​​that users can understand. , Send a request to the Linux kernel to interact with the user through the shell, etc. After the
user logs in to the Linux system, the system will start a user shell. In this shell, you can use shell commands or declare variables, and you can create and run shell scripts.
When running a shell script, the system creates a subshell. At this point, there will be two shells in the system, one is the shell that the system starts when logging in, and the other is the shell that the system creates for running script programs.
When a script finishes running, its script shell terminates, and you can return to the shell it was in before executing the script.
In this sense, a user can have many shells, each of which is forked from some shell (called the parent shell).
There are two main types of syntax in shell: Bourne and C, the two syntaxes are incompatible with each other; Bourne mainly includes: sh, ksh, Bash, psh, zsh; C mainly includes: csh, tcsh; the commonly used standard shell is Bash

shell script is simple Introduction:
# in the shell means a comment, $ means a call, and bash is a standard Linux shell
#!/bin/bash #The fixed start of shell scripts can be omitted if other scripting languages ​​are not embedded, and it can be executed normally (it is recommended that all shell scripts must be write)
echo "hello shell!" #echo is the print (output) statement of the shell script, which means to output hello shell!
echo -e "\e[1;34m bash! \e[0m" #-e means adding special Option, \e[1; means start of color selection, \e[0m means end color selection, 34m means red, linux supports eight colors from 30m to 37m.
If you need to learn about shell scripting, please refer to professional books and materials. Do an introduction.

Description of this article:
This article mainly introduces the basic knowledge of Linux, and helps newcomers to Linux quickly understand and get started with the Linux system. For more professional learning or Linux system professionals, please refer to Linux-related professional books and materials. To learn and review common Linux commands, please refer to: Linux Common Command Reference and Guidehttp: //jsonliangyoujun.iteye.com/blog/2344117Original     permanent address: http://jsonliangyoujun.iteye.com/blog/2343963

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326454027&siteId=291194637