Linux and linux commands
I. Overview 1. What is an operating system?
The operating system is the intermediary between people and computer hardware. The user cannot directly interact with the computer hardware and can not directly direct the computer to work. Therefore, an intermediary is required. The intermediary is the operating system. The user sends commands to the operating system and the operating system calls the hardware directly.
2. What is Linux?
Like Windows, Linux is also an operating system. Currently, most Web servers use Linux, Which is why java programmers are familiar with Linux.
Two virtual machines 1. What is a virtual machine?
A computer created using software simulation on a physical computer with real computer logic factors is called a virtual machine because the computer does not have an independent physical structure.
2. Virtual Machine Value
You can create multiple logical computers on one physical computer, that is, virtual machines. Each virtual machine is independent of each other, so that you can use one physical computer to create multiple computers and build an environment for multi-host testing.
Three Common Operations 1. Auxiliary general operations
- Ctrl + alt: use the mouse arrow to exit the Linux operating system and enter the Window operating system.
- Ifconfig: view the ip address.
- Clear: clear the screen.
- Cd ~ : Return to the working directory.
- Cd directory: Enter the specified directory.
- Cd...: returns the parent directory.
- Pwd: view the current location.
2. File Creation and Deletion
- Touch filename: create a file in the current directory.
- Mkdir dir: Create a folder in the current directory.
- Rm-rf filename: delete the file or folder with the specified name in the current directory.
- Rmdir dir: delete empty folders.
3. file query
- Ls: view all visible files and folders in the current path.
- Ls-l: view the details of all visible files and folders in the current directory.
- Ls-a: view all files and folders in the current directory, including hidden folders and files.
- Ls-al: view the details of all files and folders in the current directory, including hidden folders and files.
4. Copy, cut, and rename
- Cp oldfile dir: copy the file to the specified folder.
- Mv oldfile dir: Cut the file to a specified folder.
- Mv oldname newname: Rename the file.
5. Modify file permissions
In Linux, file visitors are divided into three types: file creators, members in the same group as file creators, and members in different groups than file creators. Different visitors have different permissions.
Permission representation:
- R: read.
- W: write, write.
- X: execute, run.
To facilitate permission modification, Linux assigns an integer to each permission. The integer r corresponds to 4, w corresponds to 2, and x corresponds to 1, instead of letters, you can use the sum of three permission values, such as rwx. The corresponding number is 4 + 2 + 1 = 7, that is, 7.
Use ls-l or ls-al to obtain the file details, as shown below:
drwxr-xr-x 2 root root 4096 06-20 18:42 abc-rw-r--r-- 1 root root 0 06-20 18:41 content.txt-rw-r--r-- 1 root root 124 06-20 18:39 hello.java
A folder starting with "d" and a file starting.
Each visitor's permission consists of three parts: read, write, and execute. If no permission exists, the permission is assumed by the owner.
"Rw-r --" indicates permissions, which are the creator permissions, member permissions, and non-member permissions.
Modify permissions:
Chmode 755 file: Set permissions for creators, members, and non-members based on the permission values.
6. File editing
Use the vim editor to edit files. The vim editor has two statuses: command status and editing status. After opening the file in the vim editor, the file is in the Command state. Click I to enter the editing State. In the editing state, click esc to exit the editing state and enter the command state. You can enter content to the file.
- Tar-xvf file: Decompress the file.
- Vi file: Use the vi editor to open the file.
- D + B: In the command status, tap d, then tap B, and delete the last line.
- Esc: exit the editing status.
- : Wq: Save and exit.
- : Q! : Do not save the modification content. Force exit.
- More file: view the file content and cannot be edited.
4. File Transfer
Transfers files from the local Windows operating system to a remote Linux operating system. You can use the WinSCP tool. The local operating system is displayed on the left and Linux is displayed on the right. to transfer files, you only need to drag the files from one side to the other.
Generally, install the software in the/usr/local/src file of the Linux operating system, and install the software in the/usr/local directory.
5. Remote Operations
Use putty to manipulate remote Linux servers on a local Windows operating system.
6. Install JDK
JDK is installed in Linux by default. If the JDK version is earlier, you need to use the following command to download it:
yum -y remove java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
After the uninstallation is complete, use java-version to check whether the uninstallation is complete.
Enter the jdk Installation File directory and enter "./JDK Installation File" to complete the installation. After installation, you must configure the environment variables in the/etc/profile file. Use the vi editor to add the following content at the end of the profile file:
###############################JAVA_ENV################################JAVA_HOME=/usr/local/jdk6PATH=$PATH:$JAVA_HOME/binexport JAVA_HOME PATH
$ PATH references the system environment variable. When you configure environment variables in Linux, the two adjacent paths are separated by ":", and "$" is added to reference the environment variables. Save the configuration, enter the source profile name, and rewrite the imported profile file. The environment is changed to zero.
Install Tomcat
Decompress the tomcat installation file, configure the environment variables, and add the following at the end of the profile file:
###############################JAVA_ENV################################JAVA_HOME=/usr/local/jdk6PATH=$PATH:$JAVA_HOME/binexport JAVA_HOME PATH
After saving, execute source profile to re-import the profile file and complete environment variable configuration.
- Startup. sh: Enable the tomcat server.
- Shutdown. sh: Shut down the tomcat server.
8. Install MySQL
Unzip the MySQL Installation File and run the MySQL-client-5.6.16-1.rhel5.i386.rpm/MySQL-devel-5.6.16-1.rhel5.i386.rpm/MySQL-server-5.6.16-1.rhel5.i386.rpm three executable files in rpm-ivh file name format, respectively.
Service mysql start/stop/restart: open, close/stop/restart the MySQL server.
Create a user:
Service mysql stopmysqld_safe -- skip-grant-tables & mysql-uroot-puse mysqlupdate user set password = PASSWORD ("123") where user = "root"; flush privileges; quit; service mysql restartmysql-uroot-p new password set PASSWORD = password ("123 ");
First, use the security mechanism, and then store the user name and password in the user table.