Linux Basics: Introduction to installation, common commands and installation of JDK, Mysql, Tomcat

Source: Internet
Author: User
Tags chmod parent directory ssh iptables

I. Introduction to Linux 1. Overview of Linux

Linux is a UNIX-based open source free operating system, because the stability and security of the system almost become the best system environment for program code to run. Linux was originally developed by Linus Torvalds (Linus Torvalds), which has now spawned hundreds of different Linux systems due to the openness of the source code.

The application of Linux system is very extensive, not only can run our program code for a long time, but also can be installed in various computer hardware devices, such as mobile phone, tablet computer, router, etc. In particular, as mentioned here, we are familiar with the bottom of the Android program is running on the Linux system.

2. Linux categories (1) Linux is divided into two directions depending on the market demand:

1) graphical interface version: Focus on user experience, similar to Windows operating system, but the current lack of maturity

2) Server version: There is no good-looking interface, is to enter the command in the console window operating system, similar to DOS, is we assume the best choice of server

(2) Linux is based on its native level and is divided into two types:

1) Kernel version: Kernel team under the leadership of Linus development of maintenance system kernel version number

2) Release: Some organizations or companies have two development and re-released versions based on the kernel edition

(3) Linux distributions are different and can be divided into N multiple:

Better have Ubuntu, CentOS (developed on the basis of Redhat) and Redhat (charge)

Today we use CentOS.

Want to learn Linux recommended a few books: (main service, but also the front-end and operation is very popular drop!!) )

Second, the installation of Linux 1. Installation of virtual machines

Because Linux is also a system, in essence, the window of our computer is no different, so we have to learn Linux first to the Windows system of our computer into a Linux system, or to install a dual system on our computer, it sounds terrible. In fact, we can install a software on our computer, this software can simulate one or more virtual computer machine, this is the virtual machine

There are two common types of virtual converters:

VMware's virtual machine software, powerful, premium products

Vitrualbox Virtual machine software Oracle company virtual machine software, free merchandise

Because VMware usage is high on the market, we install VMware VMware installation Manual

2. Installation of CentOS

CentOS is a Linux distribution, the main version of the current enterprise Application Server system, the installation of CentOS, in fact, the system is installed in the VMware virtual machine software, the VMware virtual machine software to simulate a Linux system computer. CentOS6.5 installation See "CentOS Installation Manual"

Iii. Basic Linux commands

Server version of the Linux installation is complete, but there is no graphical interface, we can only go through the console to the operating system, we will use a DOS command-like Linux command to go to the operating system, then we will be the Linux command to learn. Linux commands hundreds, courses can not be involved, there is no need one by one involved, according to our programmers in the daily work of the needs, summed up the following several for learning.

1. Directory Switching commands

A graphical interface and mouse can be used in window to arbitrarily switch directories that need to be entered, but Linux must switch directories via the CD command. But before we learn the CD command, we need to distinguish the directory structure of Linux (Linux directory structure detailed description)

CD usr switch to this directory in USR directory

Cd.. /switch to the previous level directory

CD/switch to the system root directory

CD ~ Switch to user home directory

CD-Switch to the previous directory

2. Operation commands for Directories (1) Add directory operations (Increase)

Command: mkdir directory name

Example: in the root directory/under MkDir test, a test directory will be generated in the root directory

(2) View catalogue (check)

command: LS [-al] Parent Directory

Example: Using LS under the root directory, you can see all the directories and files in that directory

Example: Using ls-a under the root directory, you can see all the files and directories under that directory, including hidden


Example: Using ls-l under the root directory, you can see the details of all directories and files under that directory


Note: Ls-l can be abbreviated as LL

(3) Search catalogue (check)

Command: Find directory parameter

Example: Find the test-related directory (file) under/root find/root-name ' test* '

(4) Modify the name of the directory (change)

Command: MV directory name new directory name

Example: The test directory has a oldtest directory with the MV Oldtest newtest command to modify

Note: The syntax of the MV can be renamed not only to directories but also to various files, compressed packages, etc.

(5) Location of mobile directory---cut (change)

Command: The new location of the MV Directory name directory

Example: Cut the Newtest directory below/usr under test, using MV NEWTEST/USR

NOTE: The MV syntax can not only cut the directory, but also perform cutting operations on files and compressed packets.

(6) Copy directory (change)

Command: Cp-r directory name directory copy target location-----R for recursive copy

Example: Copy the newtest under/usr to test in the root directory, using Cp-r/usr/newtest/test

Note: The CP command can not only copy directories but also copy files, compress packages and so on, copy files and compress packages without writing-R recursion

(7) Deleting a directory (delete)

Command: RM [-RF] Directory

Example: Delete the newtest under/usr and enter/usr with rm-r newtest

Example: Delete newtest under/test without asking for forced deletion, using RM-RF newtest under/test

Note: RM can not only delete directories, but also delete other files or compressed packages, in order to enhance the memory of everyone, regardless of the deletion of any directory or files, directly using the RM-RF directory/File/compression Package

3. Operation commands for files (add and revise)

(1) Creation of files (increase)

Command: Touch file name-----empty file

Example: Create an empty file under the test directory touch aaa.txt

(2) File view (check)

Command: Cat/more/less/tail file

Example: Using cat to view a/etc/sudo.conf file, only the last screen of content can be displayed

Example: Use more to view the/etc/sudo.conf file, you can display a percentage, the carriage return can be one line down, the space can be a page down, Q can exit view


Example: Using less to view the/etc/sudo.conf file, you can use the PgUp and PgDn on the keyboard to page up and down, Q end view

Example: Using TAIL-10 to view the following 10 lines of the/etc/sudo.conf file, CTRL + C ends


Note: The command tail-f file can dynamically monitor a file, such as Tomcat's log file, which will change as the program runs, and can use tail-f catalina-2016-11-11.log to monitor file changes

(3) Modify the contents of the file (change)

Command: Vim file

Example: Edit the Aaa.txt file under/test, using Vim aaa.txt

But it is not editable at this time, because in command mode, click the keyboard i/a/o into the editing mode, you can edit the file


When the edit is complete, press ESC to return to command mode

At this point, although the file has been edited, but not saved, you need to enter a colon: Enter the bottom row mode, enter WQ in the bottom line mode to write the content and exit, that is, save; input q! to force exit does not save.

Summarize:

Vim Editor is a powerful component of Linux, is a strong version of the VI editor, VIM Editor commands and shortcuts have a lot of, but here do not elaborate, we do not have to study very thorough, using VIM to edit the way the file is basically used. Attached: "VI Introduction to the use of methods" and "Vim Command Collection"

About VIM Use process:

In practical development, the main function of using the VIM editor is to modify the configuration file

Vim file------> enter file-----> Command mode------> Press I to enter edit mode-----> Edit File-------> Press ESC to enter bottom line mode-----> Input: wq/q!

(4) Deletion of files (deleted)

Same directory Delete: memorize RM-RF files can

4. Action commands for compressing files (1) packaging and compressing files

Packaged files in Linux generally end in. tar, and compressed commands typically end in. gz.

In general, packaging and compression are carried out together, packaged and compressed files with the suffix name. tar.gz.

Command: TAR-ZCVF Package compressed file name to package compressed files

Where: Z: Call the gzip compression command to compress

C: Packaging files

V: Show the running process

F: Specify file name

Example: Package and compress all files under/test compressed package with the specified name xxx.tar.gz

TAR-ZCVF xxx.tar.gz aaa.txt bbb.txt ccc.txt

Or: TAR-ZCVF xxx.tar.gz/test/*

(2) Unzip the package (Focus)

Command: Tar [-XVF] Compressed file

Where: x: Representative Decompression

Example: Extract the xxx.tar.gz under/test to the current directory

TAR-XVF xxx.tar.gz

Example: Extract the xxx.tar.gz under/test to the root directory/usr

TAR-XVF xxx.tar.gz-c/usr------C represents the location of the specified decompression

5. Other commands (1) Show current location

Pwd


(2) Search command

Command: grep to search for a string of files to search for

Example: Searching for a line in a/usr/sudu.conf file that contains a string to

Example: Search the/usr/sudu.conf file that contains the string to the line to highlight

(3) Piping command

Command: | Enter the output of the previous command as the current directory

Example: View a process that includes the system string in all processes in the current system

(4) View process

Command: PS-EF

Example: Viewing a process running in the current system

(5) Kill process

Command: PID of the kill-9 process

(6) network communication command

View network card information for the current system: ifconfig


To view a connection to a machine: ping


To view the port usage of the current system: Netstat-an


6. Permissions command for Linux

Permissions are important concepts in Linux, each file/directory has permissions, and we can view the permissions of a file or directory under a directory through the ls-l command

Example: Ls-l in a random directory


The information for the first column is explained as follows:

Type of File:

D: Representative Directory

-: Representative file

L: Represents a link (can be considered a shortcut in window)

The following 9 bits are divided into 3 groups, each with 3 positions, each representing the owner's rights, the permissions of the user in the same group as the current user, and the permissions of the other users.

R: The delegate permission is readable, R can also be represented by the number 4

W: Delegate permission is writable, W can also be represented by the number 2

X: The delegate permission is executable, X can also be represented by the number 1

Owner ( User )

Genus Group ( Group )

Other users

R

W

X

R

W

X

R

W

X

4

2

1

4

2

1

4

2

1

command to modify permissions for a file/directory: chmod

Example: Modify the permissions of the Aaa.txt under/test to have all permissions for the owner, the group that belongs to the host has read and write permissions,

Other users have read-only permissions

chmod u=rwx,g=rw,o=r Aaa.txt


The above example can also be represented using a number:

chmod 764 Aaa.txt

Iv. use of remote connection tools

In the actual development, the Linux server is in other places, we want to connect the Linux through the remote way to operate it, the Linux remote Operation tool has many, the enterprise commonly used has puttty, SECURECRT, SSH secure and so on. We use the SSH secure tool for remote connection, which is a free graphical interface and a remote tool set in the command-line window. The installation package is as follows:

After installation, two icons will appear:


Click the graphical interface icon:


Enter the interface:

About the remote tool garbled solution:

When using remote Tools to connect, if Linux has a Chinese file or directory, the display will appear garbled, because the Linux encoding is UTF-8, and the remote tool by default is the current system local encoding is GBK. So the solution is to unify the two code is OK, but the SSH secure tool can not set the encoding, so by modifying the Linux system encoding method for uniform encoding.

In the Linux/etc/sysconfig directory there is a i18n file that represents the Linux system encoding


Modify it from UTF-8 to GBK to reproduce the connection to Linux:


Five, Linux software Installation 1. JDK Installation

Note: RPM and software-related commands are equivalent to software Assistant management software under Windows

Steps:

1) See if the current Linux system has Java installed

Input Rpm-qa | grep java

2) Uninstall two X OpenJDK

Enter RPM-E--nodeps software to uninstall

3) upload JDK to Linux

4) Install the required plugin for JDK operation Yum Install glibc.i686 (optional)

5) Unzip the JDK to/usr/local under TAR–XVF jdk-7u71-linux-i586.tar.gz–c/usr/local

6) Configure the JDK environment variable, open the/etc/profile configuration file, and copy the configuration below

#set Java Environment

Java_home=/usr/local/jdk1.7.0_71

Classpath=.: $JAVA _home/lib.tools.jar

Path= $JAVA _home/bin: $PATH

Export Java_home CLASSPATH PATH

7) Reload the/etc/profile configuration file Source/etc/profile

2. MySQL Installation

Steps:

1) View the MySQL that comes with CentOS

Input Rpm-qa | grep MySQL


2) Uninstall your own MySQL

3) upload MySQL to Linux

4) Install MySQL dependency (optional)

Yum-y Install libaio.so.1 libgcc_s.so.1 libstdc++.so.6

Yum Update libstdc++-4.4.7-4.el6.x86_64

5) Unzip MySQL to/usr/local/under MySQL directory (MySQL directory needs to be created manually) within

Cd/usr/local

mkdir MySQL

TAR-XVF mysql-5.6.22-1.el6.i686.rpm-bundle.tar-c/usr/local/mysql

6) Install MySQL under/usr/local/mysql

Install server side: RPM-IVH mysql-server-5.6.22-1.el6.i686.rpm

Install client: RPM-IVH mysql-client-5.6.22-1.el6.i686.rpm

7) Start MySQL

Service MySQL Start

8) Add MySQL to the system service and set the boot up

Join the system service: Chkconfig--add MySQL

Auto start: Chkconfig MySQL on

9) Log in to MySQL

MySQL will generate a temporary random password when it is installed, and the storage location is/root/.mysql_secret.

Msyql–u root-p

10) Modify the MySQL password

Set password = password (' root ');

11) Open remote login for MySQL

MySQL is not supported by default in MySQL for security purposes, so you need to set the right to log on to MySQL remotely.

After logging in to MySQL, enter the following command:

Grant all privileges on * * to ' root ' @ '% ' identified by ' root ';

Flush privileges;

12) Open Linux port 3306 for external access

/sbin/iptables-i input-p TCP--dport 3306-j ACCEPT

/etc/rc.d/init.d/iptables Save---Persist changes to the firewall

3. Tomcat installation

Steps:

1) upload Tomcat to Linux

2) Unzip Tomcat to/usr/local

3) Open Linux port 8080 for external access

/sbin/iptables-i input-p TCP--dport 8080-j ACCEPT

/etc/rc.d/init.d/iptables Save

4) Start off Tomcat

Enter Tomcat under the bin to start:./startup.sh

Enter Tomcat under the bin to close:./shutdown.sh

Vi. Network configuration 1. VIM command Configuration

2. Setup settings

Linux Basics: Introduction to installation, common commands and installation of JDK, Mysql, Tomcat

Related Article

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.