Ii. Linux basic commands, VI Editor, Linux software installation, vilinux
Basic Linux commands
1. File Operations
A) Windows is a multi-root file system with one or more hard disks physically divided into C, D, and E ...... Disk. Each disk is a tree. Linux is a single file system, regardless of the CDE disk. Multiple hard disks, U disks, and CDs are also equivalent to Multiple folders. The folders corresponding to different hard drives, U disks, and CDs are called "mount Points". The process of placing external storage devices in the file system tree is also called "mount )"
B) in Linux, both files and commands are case sensitive.
2. Tom says "folder", while professionals say "Directory)
3. Functions of common Linux root directories:
1) boot stores various files used for system boot.
2) bin stores binary executable files (ls, cat, mkdir, etc)
3) sbin stores binary executable files, which can be accessed only by the root user (user set by himself ).
4) usr is used to store system applications. An important directory is/usr/local administrator software installation directory.
5) the location where the optional application package of opt is additionally installed
6) dev is used to store device files.
7) etc stores system configuration files
8) home Stores the root directory of all User Files
9) lib stores the shared libraries and kernel modules required for running programs in the file system.
10) tmp is used to store various temporary files
11) var is used to store files that need to change data during running.
12) install the temporary file system on mnt
4. Common file operation commands:
The working directory is the current directory"
Display the current working directory pwd (print work directory)
Displays files, directories ls, or dir in the current directory
Change Directory: cd. /test switch the working directory to the test directory under the current directory (do not forget the space after cd); cd .. to the upper-level directory; cd/is obviously the root directory returned
Create Directory mkdir (Make Directory): mkdir test has no permission to create a file folder in some system directories. User Files are generally stored in the home user name.
Delete Directory: rmdir (Remove Directory) delete an empty Directory; rm (Remove) delete a file; rm-r testA delete a Directory and all its files (-r is short for recursive. * Command of the pitfalls: rm-rf /).
Mv mobile File
Cp copy file
View text file content: cat (full display at once, suitable for small files); more (paging display, q Exit)
Find file: find-name 'a * 'find the file name starting with a in the current directory. Don't lose''
5. view the processes currently running by the current user in ps; view all running processes in ps-ef
6. reboot restart
7. shutdown now shut down immediately
8. exit the terminal: exit
9. clear the current display or shortcut: ctrl + L
10. The up/down key can quickly restore History commands. You can use the tab key to automatically fill in files or subdirectories in the current directory. If multiple first parts are the same, the same first part is automatically completed. Ctrl + c cancel the current command and start again.
11. Run the tar command to package the folder into a file, at the same time, you can compress the command format to package the tar-c-f archive file. You Need To uncompress the file tar-x-C and uncompress it to the specified directory-f archive file.
12. man command, the Manual of each command, such as man dir; exit by q.
13. Linux pipeline command: A software or command usually needs to input raw data to complete one task. After processing, output the processing result to a place (saved to a file or displayed on the screen). The Linux pipeline is such a thing, it can use the processing result of the previous command as the input data of the next command. Example: 1) ps-ef | grep bash 2) netstat-a | more 3) So cat 1.txt | more can also achieve more 1.txt 14. sudo: based on security considerations, generally, it is not recommended to use the Super User permission to log on to linux. Instead, we usually use low-Permission user access, and use sudo for High-Permission operations followed by instructions. For example, you cannot create a folder under/, but sudo mkdir a can. Of course, you need to enter a password. Su is short for "super user", and sudo is "execute commands with super user Permissions"
VI Editor
1. VI Introduction if you use a linux desktop, there are also some graphical text editors (similar to notepad), but the linux God-level editor is vi, if no vi is used, do not use linux. In many environments, there is no graphical interface. You can only use vi. VI is a full-keyboard operation and cannot be performed with the mouse. Of course, daily development is still based on visual interfaces such as VS. vi is generally used for simple modification or configuration file modification. I feel very painful when I first came into contact with vi. I am familiar with it. I have a lot of vi commands. I just want to learn basic operations. Vim is an enhanced version of vi.
2. vi Running Mode
In command mode, commands such as row deletion can be input (equivalent to a shortcut key); In insert mode, text can be input; in last line mode, commands such as Save and exit can be executed.
Easy to mix: In the insert mode, if you directly enter: Enter:, so you need to exit the insert mode first, and then: the command in the last line mode:
1): wq is saved and then exit w → write, q → quit. If it is executed in "vi file name" mode, it is directly written to the specified file name; otherwise, ": wq file name ".
2): q! Do not save and exit
3): w save and do not exit. In the last row mode, enter "!". Shell commands can be executed without leaving vi
Commands in command mode
1) Move the input cursor. You cannot press the up or down key in insert mode. To run esc, return to the command mode;
2) shift + ^ move to the beginning of the row; shift + $ move to the end of the row. Think of the regular expression to remember it;
3) ctrl + B: roll up a screen; ctrl + f roll down a screen; B → backward; f → forward
4) dd: Delete the current row. x: Delete the current character.
5) undo: the last operation u; undo short
6) o: Add a new line under the current line (because if you move to the end of the line and press enter, you still need to return to the car before the last character) automatically enters the insertion mode.
7) I: insert in front of the current cursor, a: insert behind the current cursor. A → append (additional) is also automatically inserted into the insert mode. There is also a silly character Interface Editor nano. ^ X in the prompt message below means ctrl + X. Instead of installing nano on Linux, you may need to install nano on your own.
Software Installation
In linux, many software download source code and compile it by themselves, which is a bit painful. Therefore, many releases have their own installation package formats. For example, RedHat uses *. rpm files and Ubuntu uses *. deb files. Searching, downloading, and installing on your own is still very troublesome. Therefore, many releases provide something similar to the application market and NuGet. We recommend that you use apt to download and install Ubuntu. Will be downloaded from the ubuntu official website (China Region image). If the download speed is slow, you can set to download from other images. When you search for "Ubuntu apt-get image" to execute some programs, if the program is not installed, you will be prompted, such as executing vim and tree. Sudo is required to install the software. As follows:
1) install "sudo apt-get install program name", such as "sudo apt-get install vim"
2) Uninstall "sudo apt-get remove program name"
Network Configuration
1. Use the ifconfig command to view network configuration information, ip address and nic physical address (MAC address)
2. a lan is set up between the VM and the host, and the VM accesses the Internet through the host. You can set different connection methods in the "network" of virtual machines. The host can connect to the Virtual Machine network through the ip address seen in ifconfig.
3. There are many network connection methods for virtual machines, including HostOnly, NAT, and Bridge ). HostOnly configuration is troublesome and requires a lot of understanding about network engineering. NAT is a virtual machine that uses the host Nic to access the network and is hidden behind the host. Other devices in the network cannot access this virtual machine or even host, however, a virtual machine can connect to the network of the host and can connect to the Internet. A Bridge is used to expose the VM as a device in the network, the host and virtual Master are equal in the network and can access each other, but there is no device access restriction in the network (such as Mac Address binding or the number of terminals ), if you have any restrictions, modify the configurations of the vro. Because we need mutual access between the host and the virtual machine, unless the network is limited, it is best to configure Bridge, configure Bridge to select the network card through which to access the Internet, you cannot select an error. Otherwise, you cannot access the Internet. We will configure Bridge later ).
4. the ip address of the VM may change.
SSH service
This article describes how O & M personnel remotely connect to servers in the data center and seldom uses graphical interfaces (CARDS, cannot be automated) to remotely log on to the dedicated communication protocol telnet. telnet is used to perform command line operations on the server over the network. The client can control the server through telnet only when the server has started the remote Logon Service. However, the telnet protocol uses plaintext to transmit data, which causes serious security issues. Therefore, it is almost not recommended to use it now, but the alternative protocol is SSH. Data is encrypted during SSH communication.
Use OpenSSH for Linux Installation
By default, only the client openssh-client is installed in Ubuntu.
Install server: sudo apt-get install openssh-server
Check whether the server is on: netstat-tlp
Start sudo/etc/init. d/ssh start
Restart sudo/etc/init. d/ssh restart
Ssh service default port 22, you can modify the port/etc/ssh/sshd_config by modifying the configuration file
How to connect to linux through ssh in windows: download and run putty without installation.
If garbled characters appear in the editor !!
If Chinese characters are garbled, right-click the putty title bar and choose change settings]
The new display will not contain garbled characters, and the old display will also contain garbled characters. Subsequent ssh connection operations are also common operations when you connect to the server: launch in windows and then deploy and run in linux.
Use mysql
1. Install the mysql server
1) sudo apt-get install mysql-server
2) set the password of the root user as prompted, and set it to root during testing.
3) sudo apt-get install mysql-client install management client
4) mysql-uroot-proot connects to mysql through the management client. If no error is reported, OK. Mysql-u user name-p password. Mysql-uyzk-p123
5) run the show databases command in the mysql client (do not directly execute the command in shell). (do not lose the ending Semicolon.) check which databases are available. Execute select now (); run the command correctly. Run "quit;" to exit the mysql client. 6) based on security considerations, mysql can only be connected to the local machine by default. If you want to connect to another computer (for example, host access to mysql in the virtual machine), you need to configure. It is recommended that you do not configure it to connect to any computer, because it is dangerous. Configure to allow access by only some ip addresses.
2. Configure MySQL Remote Access (the network must be configured as a bridge network ):
1) EDIT mysql configuration file mysqld. cnf: because mysql is a system service, you need to run vi with su to have the permission to execute sudo vi/etc/mysql. conf. d/mysqld. cnf. Because the configuration files of different mysql versions may have different locations, it is best to find the path in the cd and dir levels. (In linux, different versions are very different. I used to modify/etc/mysql/conf for the materials I checked earlier. d/mysql. cnf, but use the status command to query the mysql version and then search for "mysql 5.7 remote access" to find the correct method. )
2) Comment out bind-address = 127.0.0.1.
3) Run sudo/etc/init. d/mysql restart to restart the mysql service.
4) Run ipconfig on the host (ifconfig in Linux and ipconfig in Windows) to check the ip address of the host (not to mention the ip address of the VM ), for example, 192.168.0.11.
5) execute mysql-uroot-proot (-u is followed by the user name,-p is followed by the password, and modify according to your configuration. Do not enter a space in-u or-p.) after entering the mysql server, run grant all privileges on *. * to root @ "192.168.0.11" identified by "change to password" with grant option. Note: Do not drop the semicolon at the end. Do not enter it directly in the command line, log on to mysql and run the command again. Run flush privileges again. Note: Do not drop the semicolon at the end. Do not enter it directly in the command line. Enter mysql and execute it again.
2. mysql In the VM must be connected to the ip address of the VM on the host.
3. If the Host ip address changes, you need to reconfigure it.
Install vsftp Server
1. What is ftp. Upload and download files through ftp
2. sudo apt-get install vsftpd
3. At this time, you can log on with a linux user to access the/home/user name folder. However, there is no upload permission. Run "sudo vi/etc/vsftpd. conf" to cancel # Before "write_enable = YES", and then run "sudo/etc/init. d/vsftpd restart" to restart
4. You can use FileZilla FTP Client and other FTP clients to upload and download files in Windows.
5. garbled characters are displayed in Chinese. You do not need to process them. Many files uploaded and downloaded are compressed. Unzip "unzip a.zip" is used for linux decompression ". Do not upload rar or other formats