Linux day01

Operation and maintenance is essentially the operation and maintenance of each stage of the life cycle of networks, servers, and services to reach a consensus and acceptable state in terms of cost, stability, and efficiency.

First understand the responsibilities of operation and maintenance

  1. Product launch
  2. Fault maintenance
  3. Version update iteration
  4. Quality assurance
  5. Improve efficiency
  6. Reduce costs: different solutions have different costs

Note: For start-up companies, the operation and maintenance department and the system department are generally integrated, and the related work is carried out by the same group of people, and the boundaries may not be very obvious. Large companies have higher requirements for operation and maintenance work and require a finer division of labor. Therefore, the underlying work related to the computer room/network/operating system is separated and the system management department becomes the system management department, while the upper-level work related to application products is divided Responsible for operation and maintenance, became the operation and maintenance department.

Compare the following development (Java, for example) and the operation and maintenance of the difference between
Java development

  • Need strong coding ability
  • Job demand is high
  • Most of the competitors are 985, 211, double first-class graduates, 100 people in 10 positions are casting
  • Fresh graduates need a certain ability to reach 10k, but there is plenty of room for growth

Operation and maintenance

  • Does not require high coding skills (operation and maintenance development needs)
  • Fewer jobs
  • Linux is the gateway to the Internet world
  • Basic salary after graduation 10k

At present, most of the server systems that operation and maintenance personnel are exposed to are Linux and Windows

Operation and maintenance jobs

  • Technical support engineer (Qianxin, NSFOCUS, Sangfor, Venustech)
  • Network Engineer (Network Management, Tencent)
  • System Operation and Maintenance Engineer (Linux System Operation and Maintenance)
  • Business Operation and Maintenance Engineer
  • Database Operation and Maintenance Engineer (DBA)
  • Cloud Computing Engineer (Cloud Computing)
  • Operation and maintenance engineer
  • Penetration test engineer

What is an operating system?
The middle layer software that interacts with the user and the hardware. Software that
manages software and hardware.
In short, an operating system is a computer program that manages computer hardware and software resources.

Introduction to Linux

Unix and Linux code is composed of 90% C language and 10% assembly language.
The mascot of
Linux is Penguin. Linux is a kernel, not an operating system.
Linux system kernel refers to a system that is maintained by linus and provides a hardware abstraction layer and hard disk. As well as the system core program of file system control and multitasking functions, the
Linux distribution kit system is what we often call the Linux system, which is a collection of the Linux kernel and various common software.
Linux core concept: everything is a file

Linux file
file = metadata + real content
The file named with. Is a hidden file. It is
strictly case sensitive
. Any character other than / can be used as the file name. It is recommended to avoid using special characters. The
file name length does not exceed 255 characters

Linux history

Around 1965, Bell Laboratories (Bell), Massachusetts Institute of Technology (MIT) and General Electric (GE) co-founded the Multics project. In
1969, Bell Labs withdrew from the Multics project in order to develop a multi-channel information computing system. In
1970, Ken Thompson released the project. Unix system, this year is called the first year of computer.
Later, AT&T organization disintegrated, Unix moved towards commercialization, and an authorization of 40,000 US dollars.
In order to solve teaching research, Andrew University professor developed Minix himself. This system can only be used for teaching in
1991 Linus Torvalds released Linux version 0.02.
In 1994, Linux version 1.0 was released.

Linux pros and cons

  • Safe, stable, low cost
  • Multitasking, multiuser
  • Consume less resources
  • Small core, support a variety of electronic products
  • Some software does not support Linux
  • The command line is not user-friendly

Common Linux system
RHEL (Red Hat Enterprise System):

The most widely used operating system in the world

CentOS (Community Enterprise System)

By recompiling and releasing the RHEL system to the Linux system for free use by users, it has a wide range of users. Currently Centos has been incorporated by Red Hat.

Fedora Test Field

Users can experience the latest technology or tools for free, and these tools will be added to RHEL when the technology matures.

openSUSE

The famous Linux system from Germany has a good reputation and market share in the world

Gentoo (highly customized)

Highly customizable, suitable for experienced people.

Debian (Excellent hardware architecture support)

High stability, strong security, and excellent hardware support.

Ubuntu (personal desktop system)

It is derived from Debian, has strong compatibility with new hardware, and has an excellent Linux desktop system with fedora, and can also be used in the server field.

Arch Linux (small and beautiful)

Small but beautiful, highly customized

Deepin (domestic operating system)

Domestic desktop system

Free Software Movement and Open Source License Agreement
Free Software Movement

Richard Stallman (Richard Stallman) is the main initiator and spiritual leader of the movement.

"Free Software" refers to software that gives users the freedom to run, copy, distribute, learn, modify, and improve software.

The meaning of free software is to enable users (including individuals and groups) to control the program for their own use. When the user has no control over the program, such software is "Nonfree" or "Proprietary".

Free software activists believe that the spirit of free software should be implemented in all software: they believe that it is unethical to prohibit computer users from exercising this freedom. Richard Stallman believes that it is very unethical to sell binary software without source code, because it prevents software users from learning and helping others. However, there is no consensus on how to achieve the ultimate goal of the free software movement. Some people believe that legal means should be used to force software vendors to provide source code; some believe that commercial software should be boycotted to achieve their goals. Others believe that time will prove that free software is ultimately slightly better than commercial software in quality and will win in the free market.

Supporters of the open source software movement pay more attention to the usability of the software rather than its ethical issues. The biggest difference between open source software supporters and free software supporters is that the former does not blindly oppose and condemn commercial software like the latter. Many programmers among open source software supporters are using open source software while writing commercial software to make a living.

Well-known free software: Linux, PHP, MySQL, Notepad++, Firefox, Thunderbird

Open source license agreement

The spirit of open source sharing.
Users have the freedom to use, modify, redistribute, and create derivatives. This is exactly in line with hackers and geeks' pursuit of freedom, so the foundation of open source communities at home and abroad is very large and popular.

Features of open source software: low risk, high quality, low cost, and more transparency

If open source software is purely pursuing "freedom", it will affect the programmer's passion for creativity. Therefore, there are more than 60 license agreements recognized by open source organizations in the world to ensure the benefits of open source workers.

GNU (GUN is not unix), GPL (General Public License) General Public License Agreement

  • Freedom of copying: allows copying the software to anyone's computer and does not limit the number of copies
  • Freedom of dissemination: allow software to spread in various forms
  • Free charge: The software is allowed to be sold on various media, but buyers must be informed in advance that the software can be obtained for free.
  • Modification freedom: developers are allowed to add or delete software functions, but the modified software still complies with the GPL agreement.

BSD Berkeley Software Release Agreement

  • If the redistributed software contains source code, the source code must comply with BSD
  • If there are only binary programs in the re-released software, you need to declare in the relevant documents or copyright files that the original code complies with BSD
  • It is not allowed to use the name of the original software, the name of the author, or the name of the organization for marketing purposes.

Installation and deployment Linux
installation: virtual machine
View firewall status:

systemctl  status firewalld

View the services allowed by the firewall:

firewall-cmd --list-all

Note: If the ssh service is not released, you need to manually release or close the firewall

Turn off the firewall:

systemctl stop firewalld.service 

Check the sshd service:

systemctl status sshd

Check port 22:

ss -tanl | grep 22

View ip address:

ip a | grep global

SSH remote connection

ssh  username@hostname
ssh -p passwd username@hostname

initialization

  • Turn off the firewall
systemctl stop firewalld.service
  • Turn off SELinux
setenforce 0
getenforce
  • Install vim, bash-completion
yum install -y vim bash-completion
  • Shut down and take snapshot

Linux file system

  • File=Metadata+Real content
    Files named with. Are hidden files.
    Strictly case sensitive
    . Any character other than / can be used as the file name. It is recommended to avoid using special characters. The
    length of the file name should not exceed 255 characters.

  • File path:
    absolute path: starting from the root position
    relative path: relative to the current position

  • Seven file types
    Common file types:-or f
    directory file type: d
    block device file type: b
    character device file type: c
    socket file type: s
    pipe file type: p
    link file type: l

  • Three ways to view file types

    • ls -l or ll: The first character in the result represents the file type

    • The file command can view the file type

    • stat can view other file attributes such as file type

Linux FHS (File System Hierarchical Standard) Directory Structure

  • bin: Store commands frequently used by the system, usually binary programs
  • boot: part of the core components needed to start Linux
  • dev: Linux external device
  • etc: configuration files and subdirectories required for system management
  • home: user's home directory
  • lib: library files (including kernel modules) that the program depends on
  • lib64: dedicated to the location of auxiliary shared library files on x86_64 systems
  • media: automatically recognized equipment
  • mnt: The location where the user temporarily mounts another file system
  • opt: install some additional software
  • proc: virtual directory, access the directory to obtain system information
  • root: user home directory of the super administrator
  • run: Information since the storage system has been running
  • sbin: command used by the super administrator
  • srv: data needed after the service is started
  • sys: sub file system, mapping kernel information
  • tmp: temporary file
  • usr: user's application and related files
  • var: files that are frequently modified

Linux kernel version
3.10.0-693.el7.x86_64
major version. minor version. release version-modified version

  • Minor version: if it is an even number, it is a stable version, if it is an odd number, it is a development version, which is used by kernel developers
  • Release version: To change this version, add some new features
  • Modified version: the number of compilations, the number of each compilation +1

bash related features

  • What is a shell?
    The shell program finds the executable program or code corresponding to the input command, and provides it to the kernel after analysis to allocate resources to run it, in the form of one or more processes
  • Bash is a kind of shell, and it is also the shell used by CentOS7 by default
  • Commands that can be executed in the shell:
    built-in commands: shell comes with
    external commands: there is a corresponding executable program file under a certain file system path
  • type: You can view the command type, which is built-in or other types
  • whereis: find the location of the relevant file of the command
  • which: view the location of the command

Insert picture description here

Linux commands

The linux command is a command to manage the Linux system. For the Linux system, whether it is a central processing unit, memory, disk drive, keyboard, mouse, or user, it is a file. The commands for Linux system management are the core of its normal operation, similar to DOS commands. There are two types of linux commands in the system: built-in Shell commands and Linux commands.

  • Command format
    <command> <parameter>

  • parameter:

    • Long parameters:--, such as--help,
      if you want to use multiple parameters at the same time, you can display multiple long parameters side by side in the form of spaces
    • Short parameters-such as ls -a. You can combine multiple short parameters at the same time, such as ls -la
  • Command execution result

    • Success: Exit status code is 0
    • Failure: Exit status is non-zero
  • Cancel command execution: Ctrl+C

pwd command

Show current location

cd command

cd -: Enter the location of the previous directory
cd: Enter the user's home directory

Alias

  • View alias: alias
  • Define alias: alias [name] = [value]
  • Unalias: unalias
  • The command line is only valid for the current process. If you want to take effect permanently, you need to modify the configuration file. It
    is valid for the current user: modify the ~/.bashrc configuration file, and it can take effect permanently. It is valid
    for global users: modify the /etc/bashrc configuration file.
  • Note: If you want to take effect immediately, you can log out and log in again, or use source ./bashrc or source /etc/bashrc command to make it take effect

Help source
–help: long parameters of the command line, find the explanation of the built-in parameters.
Use the man manual to view very specific manual documents.
Information leaf, the
help document of the info program itself, written by the developer of the Readme
program official document
release official Documents
Baidu experience, Baidu Encyclopedia, Jianshu, CSDN, blog garden, rookie tutorial, programming lion, w3cschool

Command history

  • View history commands: history
  • Command history file: ~/.bash_history
    will read the command history file when logging in to the shell, and subsequent operation commands will be appended to the command history file
  • History related parameters
    -a: immediately append the command history of this session to ~/.bash_history
    -d: delete the specified command in the
    history -c: clear the history command
  • hot key
  • !#: Call the #th command in history
  • !string: Invoke the most recent command starting with string in the history
  • !!: Call the previous command in the history

Directory management commands

  • mkdir: create a directory
    -p: create recursively
    -v: display the creation process
    -m: specify permissions
  • rmdir: delete a directory
    -p: delete recursively
    -v: display the deletion process

File view command

  • cat: View all contents of the file at one time, the disadvantage is that it will take up more IO when viewing larger files
  • tac: similar to cat, but view from the end of the file
  • more: Load only part of the content at a time, and load the remaining content when the page is turned to avoid wasting IO resources
  • less: similar to more, except that you can turn back pages
  • head: view from the front of the file, default the first 10 lines
    -c: get the first number of bytes
    -n: get the first number of lines
  • tail: In contrast to head, the content is viewed from the end of the file, the default last 10 lines
    -c: how many bytes
    after acquisition -n: how many lines after acquisition
    -f: dynamically display the newly appended content of the file, the function is the same as the tailf command

File timestamp
Timestamp: the number of seconds since the first year of the computer (1970) to the present

  • atime: the last time the file was accessed
  • mtime: the last time the file content was modified
  • ctime: the last time the file attribute was modified

You can use the touch command to modify the time of the file
-a: only change atime
-m: only change mtime
-t: specify the change time

cp command

  • When SRC is a single file,
    DEST does not exist, a DEST file is created, and
    DEST with the same name as SRC exists, overwriting the old file
  • When SRC is multiple files,
    DEST must be a directory
  • SRC is a directory: -r
    DEST must be a directory, if it does not exist, a new directory will be created; if it exists, it will be overwritten
  • Common parameters
    -i: interactive
    -r/R: recursively copy directories and files
    -a: archive
    -p: together with attributes

mv command
Common options
-i: interactive
-f: mandatory

rm command
-i: interactive
-r: delete recursively
-f: force delete

Note: It is recommended to use absolute path to delete files when deleting files, use relative path is easy to delete

Guess you like

Origin blog.csdn.net/qq_44924544/article/details/108585480