Linux Comprehensive pending modification

Source: Internet
Author: User
Tags aliases

First, the Linux classification

Typical branches of redhat such as: Redhat, CentOS, Fedora,mandrake,mandriva, domestic red X, etc.

Debian branches such as: Debian,ubuntu, etc.

Slackware branches such as SUSE, etc.

Yum can be used to operate RPM packages, such as the management of a software on a fedora system:
Installation: Yum Install <package_name>
Uninstall: Yum Remove <package_name>
Update: Yum update <package_name>

Apt-get can be used to run Deb packages, such as the management of a software on an Ubuntu system:
Installation: Apt-get Install <package_name>
Uninstall: Apt-get Remove <package_name>
Updated: Apt-get update <package_name>

Linux command format:

Any content between [] is optional

... Anything in the back can be duplicated.

{} indicates that one of the items separated by a vertical bar (|) should be selected.

For Example:

Cmd[-x] {on | off} filename .... You can match the following command:

Cmd–x on filename

Cmd-x off filename1 filename2

CMD off filename1

System Administrator Basic tasks:

    1. Add, delete, and manage user accounts
    2. Adding and deleting hardware
    3. Perform a backup
    4. Installing and updating software
    5. Monitoring System
    6. Fault diagnosis
    7. Maintain local documentation
    8. Always be alert to system security
    9. Help users

Typical boot process for Linux systems:

    1. Loading and initializing the kernel

1.1 System ROM Load a small bootloader from the hard drive into memory (BIOS)

1.2 The bootloader is then scheduled to load into the kernel

    1. Detecting and configuring devices

2.1 Kernel detects and initializes each hardware device

    1. Creating Kernel Threads

3.1 The kernel creates several spontaneous processes (spontaneous processes that are not created through the system's Fock mechanism)

3.2 Once the spontaneous process is created, the kernel boot process is finished. However, the process of handling the basic operations and the Linux daemon have not yet been created, and all of this is done by the INIT process.

    1. Operator intervention (manual boot only)
    2. Execute the system, start the script

The startup script generally accomplishes some of the following:

5.1 Setting the computer name

5.2 Setting the time zone

5.3 Check disk with fsck mode (in Auto mode only)

5.4 Installing the system's disks

5.5 Deleting old files from the/tmp directory

5.6 Configuring the Network interface

5.7 Starting daemons and network services

    1. Multi-user mode operation

After the startup script is complete, the system is a complete system, but this time can not be multi-user login, there must be an INIT process to generate a Getty Process monitoring terminal and console, after generating the Getty process, the INIT process completes the boot.

Process:

Ps aux understands the full picture of the running process on the system. Only a snapshot of the past system is provided.

Top Real-time update of a system

Hard Links

The equivalent copy of a file copies, but unlike copy is created by the hard link and the source files are synchronized (or shared), not only the content sharing, permissions and so on are identical, delete any one of them, the other files as usual, in the usual application to provide hard links in order to prevent users from mistakenly deleted.

CMD:LN F1. /F2//Create F2 is a hard link to F1

Soft connection

A soft connection is the equivalent of a shortcut in Windows, deleting a source file,

Cmd:ln-s F1/HOME/F2//A soft connection to create F1 in/HOME/F2

File permissions:

Chmod Changing the user's read write EXE permissions

Chown change the owner of a user

Umask Sets the default permissions for creating files, but it is best to set them in the configuration file, and the user can modify them with Umask settings.

Additional flags for files (only ext* file system is available):

can be set with command lsattr and chattr

You can set the contents of the file:

Never update the access time of a file

Allow only append to write

Deleting and modifying files is not allowed

Access Control List (ACL)

Batch create files and folders

Cmd:touchm{1..50}.txt Create M1.txt,m2.txt,m3.txt ..... M50.txt

cmd:mkdirm{1..50}

Regular expressions

Variable

variable= value

${variable} or $variable

If the variable has spaces in it, assign a value to the variable by using "".

forexample:variable = "Hellow World"

To set a read-only variable:

Colour=blue

Readonly colour

To clear the value of a variable:

Unset colour

Define and clear environment variables:

environ-variable = value environment variable assignment

Export environ-variable declaring environment variables

The same way to clear environment variables and clear general variables

Unset environ-variable

Common environment variables: env command to display all environment variables

PWD oldpwd PATH HOME SHELL useruid

To assign a command to a variable:

cmd=$ (ls-l) commands can be nested

echo $cmd No carriage return between result set

echo "$cmd" result set with carriage return, same as ls–l output

Position parameters

is a special shell script variable

$ A is the name of the script $ $ for the first argument, and the second argument, and so on

${10} is the tenth argument, and the tenth one is enclosed in parentheses.

$* and [email protected] represent all parameters starting from $

$# all parameters passed to the shell script

$$ Script Run script number

$? return value

Shell Loop (conditional judgment)

The return value of the command:

Can I use echo $? View

return value

Meaning

0

Command runs successfully

1-125

Command run failed, script command, System command, command parameter error

126

Unable to execute command found

127

No command found.

128

command is forcibly exited by the system

Digital judgment

-eq

=

-ne

! =

-gt

>

-ge

>=

-lt

<

-le

<=

Judging a string

String

The judgment is not empty

-N String

The judgment is not empty

-Z String

Judged to be empty

String A = string b

String A! = string B

Judge:

If/elif/else structure:

Ifexpression1

Then

Command

Elifif expression2

Then

Command

Else

Command

Fi

Case structure:

Casevariable in

VARIABLE1)

Command

......

Command;;

Variable2)

Command

........

Command;;

*)

Command

........

Command;;

Esac

For structure

For variable in {list}

Do

Command

Command

Done

For ((EXPR1;EXPR2;EXPR3))

Do

Command

Command

Done

While expression

Do

Command

Done

Until expression

Do

Command

Done

String processing:

Length of string:

${#string}

Expr length $string (it is best to enclose $string in double quotation marks, because there is a syntax error if the string contains a space)

Expr Index

Expr index $string $substring specific return value, please refer to the example

Expr match

Expr match $string $substring

The substring can be either a character or a regular expression

Extracting substrings

Extract from left:

${string:position}

${string:positon:length}

Extract from Right:

${string:-position}: And-There is a space between

${string:(postion)}

Or you can use the command.

Expr substr $string $positon $length

To delete a string:

${string#substring} Delete the shortest substring matching the beginning of the string and the substring

${string# #substring} Delete the oldest string at the beginning and substring

${string%substring} deletes the shortest substring matching the end of the string and substring

${string%%substring} Delete the oldest string at the end of the string and the substring match

Replace substring:

${string/substring/replacement} replaces only substrings that match the first time with substr

${string/substring/replacement} Replaces all substrings that match substr

${string/#substring/replacement} to replace the substring at the beginning that matches the substr

${string/%substring/replacement} replaces the substring with the beginning of the substr match

File identifiers:

The file identifier is 0-9 of the data, indicating the source of the specific data flow associated with the process. When Linux starts a process, it automatically opens 3 files for the process: standard input, standard output, and standard error output, represented by the file representation, 0,1,2, if the process is to open additional input and output files, starting from 3.

Set-o Noclobber does not allow overwriting of any file set +o Noclobber

>> Append > Overwrite > Force overwrite (when noclobber)

Note: The error output of the command is not the output of the command

The output of the command is redirected to the NewFile file, but the error output is still displayed on the shell, indicating that the error output of the command is not the output of the command.

Wc–l NewFile and Wc-l < newfile the second bar displays only the numbers, not the file names

<<delimiter Shell takes the decomposition character delimiter until the next delimiter as input

Child shell and process processing

In Linux, only the fork function can create child processes, and parent processes use the fork function to create child processes

The shell commands are divided into built-in commands and external commands, which are commands executed by the shell itself, while external commands are commands that are executed by a child process created by the fork function, which means that the built-in command does not create a child shell, while an external command creates a child shell

Built-in commands are commands that are included in the Shell Toolkit

: Indicates true forever, equivalent to keyword

A command line in the shell (), run in a child shell, a variable defined in a parent shell can be used in a child shell, but a variable defined in a child shell cannot be used in a parent variable

restriction mode for shell scripts, which disables some scripts or commands

For example, you can disable the use of CD commands and so on

The Trap command can specify that a command is executed when a signal is received

Trap Command SIG1

Alias and Unalias setting aliases and de-setting aliases

Alias cddavid= ' Cd/home/david '

There are two types of devices in Linux:

Character devices (unbuffered and can only be stored sequentially), block devices (buffered and randomly accessible)

Two Special equipment:/dev/zero/dev/null

/proc File System

is a pseudo file system that only exists in memory and does not occupy external memory space. It provides an interface for accessing system kernel parameters in a way that the file system accesses. Because the system information (such as processes) is dynamically changed, when all users or applications read the/proc file, the/proc file system dynamically reads the required information from the system kernel and submits it. So there are times when we call files in/proc as virtual files. There are times when we query a file to return a lot of information, but the size of the file will be 0

There are three important files in the/proc directory:

Net SCSI and SYS

SYS directory is writable and can be queried or modified by the kernel parameters

While net and SCSI depend on the configuration of the kernel parameters

Use/proc/sys to optimize system parameters (do not change easily, otherwise it may cause system crashes)

For example, you can modify the maximum number of/prco/sys/fs/file-max settings files

After the user modifies the memory parameters, it is added to the file rc.local and can be modified automatically when the system is started.
NET is to view the network

/proc/net/sockstat/proc/net/tcp

Linux Comprehensive pending modification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.