Java Novice Learning Guide [day43]---Linux

Linux

1. Why you need Linux

The software we develop needs to be deployed on the server so that users can access it through the server. In today's three major systems (windows, linux, macOS), linux is often used as a software server system.

Two, Linux introduction

Linux is an operating system, similar to the Window system, a set of stable multi-user network operating system.

advantage:

  • Open source code;
  • Stability and efficiency: It can be restarted for one or two years, and there will be no downtime;
  • Reliable security, stable performance: basically no need to install anti-virus software;
  • Multi-user and multi-task: Linux system can support multiple users at the same time;
  • Low requirements for hardware configuration: at least 128M memory can run.

Common Linux systems:

Redhat Red Hat, charges, strong technical support, complete data, stable and safe system;

Centos was acquired by Red Hat, it is free, the system is stable and secure, and many companies are using it;

Ubuntu is a debian-based distribution, the most popular free operating system with a powerful interface. More suitable for individual users.

Three, virtual machine installation

1. Why do you need a virtual machine

There are many ways to obtain a computer, but the most cost-saving and cost-effective way is to use a virtual machine. The virtual machine software can simulate a computer.

2. Common virtual machine software

  1. vmware: No.1 in virtual machine software, features: perfect simulation, commercial authorization, charging software (serial number), large memory;

  2. virtualbox: the original sun company, now belongs to Oracle, free and open source, timely update, small size, memory optimization, compatibility is not particularly good;

  3. Virtual PC Microsoft's free product: only supports windows system (Microsoft officially said that it only supports windows, in fact, other systems can also be installed) has stopped updating;

  4. Hyper: Microsoft's latest virtual machine software;

3. Install vmware

The 15.5.0 version used here1605952268086

You can create two folders first, one vmand one CentOS, to store related files.

After clicking install, it is a "dumb" installation

Four, CentOs installation

CentOs (Community Enterprise Operating System, Chinese meaning: Community Enterprise Operating System) is one of the Linux distributions (red hats)

1. Virtual a bare metal (typical)

The recommended version is CentOs 7 64-bit. The memory allocated can be manually modified as needed. Generally, 20GB of memory disk capacity and 1 core CPU are allocated.

2. Configure bare metal virtual machine

1605964859628

3. Centos7 system installation process

Note: Click to enter the Linux system (the mouse disappears), hold down Ctrl+Alt to exit (the mouse appears)

①、Choose Chinese

② Determine the software installation source and software selection, you can choose this mode with a desktop option

③, select partition-automatic

④, open the network configuration, select to open the Ethernet, modify the name

⑤, set root password

⑥, create a user

Note: The password setting is too simple, there will be a warning, you can ignore it, click Finish twice to ignore the warning and continue to execute

⑦. After the installation is completed and restarted, the first time we need the initial settings, click the unaccepted license installation

⑧, click not listed: go to the login page

⑨, enter the root user name and click

Note: It is recommended to use root operation for subsequent operations. Root has the maximum authority. Log in with other users. Some operations will be restricted.

4. Configuration after installation

Backup system: use a virtual machine------->snapshot (if the software installation in linux fails, you can restore to the specified snapshot version and try again, otherwise the deletion is not clean and you need to reinstall lunux, which is very troublesome)

Network settings:

  1. Nat network address translation mode (NAT, Network Address Translation)
  2. Bridged Adapter bridge mode

Five, CentOs software installation

  • Unzip the source code package file installation
    • Some software needs to configure environment variables
  • RPM package installation
    • Unable to solve the dependency problem
  • Yum online installation
    • During the installation process, the rpm package is too dependent

Six, command execution method

1. Local terminal: similar to cmd under windows

  1. Check IP: Linux (ifconfig), windows (ipconfig)

  2. End the current execution command: ctrl + C

  3. Clear screen: clear

  4. View how to use the command: help

Note: If Linux handles hibernation: press Enter and ESC or EXIT to log in again

2. Remote operation

To access Linux remotely, you need to use SSH (Secure Shell in English, which is a secure protocol), which is also used for remote login.

Common SSH client software includes SecureCRT, Xshell, Putty, etc., which are generally used on Windows client computers

The SSH service is installed by default in CentOS, which can be verified by the following command: (executed in the local terminal)

Insert picture description here

Prompt: Seeing the process number 6294 indicates that the ssh service is running

Seven, Linux commands

1. File related commands

Linux has a basic idea: everything is a file. (The file is a computer disk as a carrier, a collection of binary data)

The directory structure of the linux system is a tree structure with / (root directory) as the root node

1605969097521

System catalog introduction

/bin stores binary executable files (commands), all users can use

/sbin stores binary executable files, only root users can use

/boot Core files needed for system startup

/dev device file

/home The home directory of the user, every non-root user will have a folder with the user name at home

/lib system shared dynamic link library

/mnt mount directory, usually mount to this directory

/etc Directory for storing system configuration files

​ /etc/passswd user information file

​ /etc/group user group information file

/var is used to store files that change regularly and files that change frequently. Such as cache, login files, mysql database files, etc.

/tmp Temporary directory, used to store temporary files

The /proc virtual directory is a memory mapping and can access the system information in the memory

/sys is similar to proc, storing information and data related to the kernel

/root root user's home directory

/usr stores applications and files (similar to the system32 and program files directory of windows)

​ /usr/local/src All application packages are placed here

​ /usr/local/ All applications are installed in this directory.

​ /usr/bin, /usr/sbin: This is a supplement to /bin and /sbin

2. Commonly used commands

  1. View the current directory (use: copy the directory to some configuration files): pwd

  2. Switch directory (need to execute commands in a specific directory): cd directory name

  3. File name and directory name completion: Tab

  4. View catalog file information:

    (1) lsList file information

    (2) ls -lList file information in detailed information

    (3) ls –aList all files and folders, including hidden files

    (4) ls -alList all file information in detailed information, including hidden files

    (5) ls 目录名View the file information of the directory

    (6) llEqual to ls -l

  5. View current users:

    (1) whoamiView current operating users

    (2) who am iView the information of the currently logged-in user (there may be more than one)

  6. Find command:

    (1) Find the file in the file data: locate【Slow】

    locate hosts (Query the database /var/lib/mlocate/mlocate.db)

    Update once a day, you can't query the one you just created, you can query after manually updating updatedb

    (2) The most powerful search command: a command findto find various files according to conditions [fast]

    find Display all files and directories under the directory

    find /bin Only show the current road King

    find /bin/ Display all files and directories under the directory

    find -name "*.txt" Show all files with the suffix txt

    find -path "*test*" Show all directories and files that match test

    (3) Search the directory and alias information of the command:which

    (4) The directory where the search command is located and the help file and source code path:whereis

​ 7. Switch users:

​ (1) suUsername: switch user

​ (2) su root: For ordinary users to switch to the root user, they need to enter a password;

​ (3) su itsource: User who switched to itsource

​ (4) exitLog off the current user and return to the previous user

3. Directory related instructions

  1. Relative path and absolute path:

    (1) Absolute path: the path starting with / (root directory) (for example: /home, /etc/passwd)

    (2) Relative path: the path beginning with ./, in many cases ./ can be omitted (refers to relative to the current path):

    ​ ① ./ means the current directory (can be omitted)./usr/loccal/=usr/local

    ​ ② …/ indicates the upper level directory

    Note: The last slash of the path can be omitted

  2. Create a directory:

    (1) mkdir directory name//create a directory

    (2) mkdir -p directory1/directory2/directory3 //create directory recursively

  3. Delete directory: rm -rf path//can delete files and directories -r (recursive) -f (violent)

  4. Move directory/modify file name: mv dir1 dir2 If dir2 does not exist, change dir1 directory name to dir2 (rename), otherwise move dir1 directory to dir2;

  5. Copy directory:

    (1) cp -rf dir1 dir2 //Copy dir1 to the dir2 directory (copy the contents of the directory together)

    (2) cp -rf dir1/* dir2 //copy content directly (very important)

  6. Pack and unzip:

    (1) tar -czvf tom.tar.gz tom-packaging

    (2) tar -xzvf tom.tar.gz -C /usr/local – 解包

    (3) Parameters:

    ​ -c Create a new tar file -t See compressed file content

    ​ -v Display running process information -j call bzip2 compression command to perform compression

    ​ -f specifies the file name -C specifies the directory to be decompressed

    ​ -z Call the gzip compression command to perform compression

    ​ -x Unzip the tar file

4. File-related instructions

  1. Create file: touch file path//create a blank file

  2. View the content of the file: cat //Display the content of the file directly

  3. Open file, save, close file (used in vi command mode)

    ​ vi filename //Open the filename file

    Note: Press i (insert) to enter editing, press Ctrl + C to exit editing, and exit editing. Enter: wq to exit the editor

    ​ :w //Save the file

    ​ :w vpser.net //Save to vpser.net file

    ​ :q //Exit the editor, if the file has been modified, please use the following command, q (quit)

    ​ :q! //Exit the editor without saving

    ​ :wq //Exit the editor and save the file

8. File upload

File, save, close file (used in vi command mode)

​ vi filename //Open the filename file

Note: Press i (insert) to enter editing, press Ctrl + C to exit editing, and exit editing. Enter: wq to exit the editor

​ :w //Save the file

​ :w vpser.net //Save to vpser.net file

​ :q //Exit the editor, if the file has been modified, please use the following command, q (quit)

​ :q! //Exit the editor without saving

​ :wq //Exit the editor and save the file

8. File upload

Insert picture description here

Guess you like

Origin blog.csdn.net/WLK0423/article/details/111571054