Linux Learning Notes 4:linux task scheduling, process management, MySQL installation and use, use of SSH tools, Linux network programming

Source: Internet
Author: User
Tags readline

1, set task scheduling command crontab task scheduling refers to a particular command or program that the system executes at a certain time. Task scheduling is divided into: 1) system work: Some important work must be performed periodically, such as virus scanning. 2) Individual users work: Individual users may want to execute certain programs. (1) Set task Schedule file:/etc/crontab 1) first set up personal task scheduling.  Executes the CRONTAB-E command.  2) then enter the task into the dispatch file. such as: 5**** ls-l/etc/>/tmp/to.txt said five minutes per hour to execute the ls-l/etc/>/tmp/to.txt command. The first digit in "5****" indicates the number of minutes, the second indicates the first few hours, the third indicates the day of the week, the fourth digit represents the first few months, and the fifth person represents the day ordinal of the weekly. (2) Scheduling multiple Tasks Method 1: Write multiple tasks directly in CRONTAB-E. That is, the line-wrapping task. (deprecated) Method 2: All tasks can be written to an executable file (Shell programming). Steps are as follows: 1) VI mytask.sh Enter the following command Date>>/home/mydate3 Cp/home/mydate3/root 2) Grant mytask.sh Execute permission chmod 744 MYTASK.S    H 3) Crontab-e 4) Re-enter the command: * * * * * */root/mytask.sh. (3) How to terminate a task crontab-r means to terminate a task schedule.  After the command is executed, the tasks in the crontab-e are removed. CRONTAB-L indicates which task schedules are currently in the list.

2, the Linux process concept and management, process: the so-called process is the implementation of the program. Threads: (1) threads are lightweight processes, (2) processes have separate address spaces, and threads do not. (3) A thread cannot exist independently, it is created by a process. Use fork in Linux. (4) The thread consumes less CPU and memory than the process. (1) in Linux, each executed program is called a process. Each process is assigned an ID number. (2) Each process will correspond to a parent process. This parent process can replicate multiple child processes. (3) Each process can exist in two ways: foreground and background. The so-called foreground process is what the user can do on the current screen. The background process is actually in action, but the process cannot be seen on the screen (4) The services of the general system exist as a background process and will reside in the system until the shutdown is over.

(5) Check the current system's process (static) with the PS command. such as: 1) ps-a indicates that all process information for the current terminal is displayed 2) ps-u indicates that the process information is displayed in the user's format 3) ps-x indicates that the parameters that show the background process run typically use Ps-aux to display all the information.

(6) Terminating a process consider stopping a process if it wants to stop at half the time it needs to, or when it consumes significant system resources.  Use the KILL command to complete.  1) Kill process Number: indicates terminating a process. 2) kill-9 Process number: Indicates that some processes will capture some signals. If the process cannot be terminated directly, the information can be passed with "-9".

(7) The process's dynamic monitoring process top top is similar to the PS command, and they are used to show the process being executed. The biggest difference between top and PS.  At top, you can update a running process for a period of time. 1) Monitor specific users: Top: Enter this command, carriage return, to view the process being executed.  U: then enter "U", then enter the user name, you can. 2) terminate the specified process: top: Enter this command, return, and view the process being executed.  K: Then enter the "K" carriage return and enter the process ID number to end. 3) Specify the System Status update time: top-d 10: Specify the system update process time is 10 seconds

(8) Set system time 1) Date command: Displays the time of the system, which can be used to view the system's time by entering the "date" command directly (2): Date mmddhhmmccyy. SS indicates that the month and day are divided annually. seconds seconds 3) view monthly calendar: Cal 3 2002 for viewing March 2002 Calendar 4) View annual Calendar Cal 2008 for viewing the 2008 calendar

3, monitoring network status information (1) Display the network Statistics command netstat, this command is used to display the entire system current network conditions. For example, current connections, packet-passing data, or routing table content. This command is directly entered to use: for example: Netstat-an NETSTAT-ANP display the ID of the process (2) Detect host Connection Command ping: is a network detection tool, it is mainly used to detect whether the remote host is normal, or whether the ring between two hosts is broken, whether the network cable is off or the NIC fault  。 Such as: Ping the other IP address

(3) Show Packet History command: traceroute This command can be used directly to detect the process of packet transmission over the network. The full path of the host from native to remote. Help administrators solve problems (4) route-so-called routing refers to the network operations that send data from the source network to the destination. In a large network, routing is very complex, because when a packet arrives at the destination, it may have many nodes, and the routing table is a form that is stored on the router or some other connection settings. It records the network path to the specified destination, along with the associated values for those paths. This command can be used directly to view native routing scenarios.

4, MySQL database use under Linux (1) MySQL installation   steps: 1) First copy the installation files to the installation directory, that is, mount/mnt/cdrom load copy cp mysql-* /home/   2) and then unzip the installation file: TAR-ZXVF file name. GZ   3) The folder name: MV mysql-standard-4.0.26-pc-linux-gnu-i686  MySQL   (Create a folder named MySQL)   4) Groupadd mysql    (means to create a MySQL group for easy Management)   5) useradd-g MySQL mysql  (indicates that a MySQL user was built and put it into the MySQL group)   6) scripts/mysql_install_db--user=mysql  (indicates initialization of the database , which is the user who added MySQL) This command needs to go to the MySQL master directory to execute correctly.   7) chown-r root. (The owner of the modified file) indicates that the owner of all files and folders under the current path is changed to root. where "." Represents all files and folders under the current path, "-r" for recursive operation   8) chown-r MySQL data (modifies the owner of the date folder) means that the owner of the Data folder is modified to MySQL.   9) chgrp-r MySQL. (change user group) means to change the user group of all files and folders under the current path to the MySQL user group   10) start MySQL: Start from the bin directory.   bin/mysqld_safe --user=mysql &   (2) How do I get to MySQL?  1) go to the installation directory to execute   first CD to the bin directory   then execute./mysql-u root-p Enter the password.  

  Exit Mysql:quit.    2) Set environment variable:  env |more  View the value of the environment variable path. All the paths in the environment variable are saved in the root directory. Bash_profile file (available for viewing with Ls-al). Therefore, modifying the path only requires adding a path to the file.  .bash_profile files are each user has one, when using each user login is, will go to read each user's. bash_profile file to load the appropriate environment variables. Therefore, if you log in with another user, you need to modify the following. bash_profile file for the appropriate user.   (3) MySQL use under Linux      requirements:  1) set up a database and table  2) add some data   3) Write a Showusers.java file that displays the user in the console, especially the location where the MySQL driver is to be stored (that is, in the JDK directory, the JDK's home directory/jre/lib/ext). The implementation steps are as follows:  1) enter MySQL  2) to build the database and tables  create the DB spdb1;//build Library  create table users (userid varchar (8), Username varchar (8));  3) Insert data  insert into users values (' 002 ', ' shunping ');  4) Write a Showuser.java file that displays the user name  vi Showuser.java

in the console

Improt java.sql.*; public class showuser{public static void Main (string[] args) {try{//connect to MySQL class.forname ("com.mysql.j Dbc.      Driver ");       Connection ct=drivermanager.getconnection ("Jdbc:mysql://127.0.0.1:3306/mysql?user=root&password=liujiyu");      StateMent sm=ct.createstatement ();     ResultSet rs=sm.executequery ("SELECT * from users");   while (Rs.next ()) {System.out.println ("Username=" +rs.getstring (1));  }}catch (Eception e) {e.printstacktrace (); }       }    }

(4) How to use the command line to back up and restore the MySQL database into the MySQL database of the installation home directory under/bin, execute the following command 1) Backup: mysqldump-u root-p Password database name >data.bak 2) Restore: mysql-u Root-p Password database name <data.bak Restore the database, you need to set up an empty database!! That is, all data is restored to the empty database after the database is restored.

5, SSH (secureshellclient) use (link between Windows and Linux) SSH is a remote operation of Linux, and file upload and download software, in the software company almost all Linux programmers will use SSH. Safety and convenience are his greatest features. (1) Install SSH (secureshellclient) (2) due to Linux system, its system comes with the SSHD service, the default is the open state, and its listening port is 22.linux view listening port with netstat- ANP command to see if monitoring is actually turned on. (3) Login to Linux using the SSH client (provided that Linux sshd is started. And you need to confirm that between Windows and Linux can be ping (if the virtual machine needs to ensure that the virtual machine and host only in the same network segment). ) (4) Enter the IP address and user login information of the Linux system to log in. (5) You can transfer files between Windows and Linux via SSH (equivalent to FTP)

6. Installation and configuration of FTP

6.1 Current directory: PWD relative directory: Refers to access a file (folder) absolute directory from the current directory: refers to the root directory to access a file (folder) working directory:

CP Copy Command cp-r dir1 dir2 recursive copy command (copy subdirectory information) MV Move file and change file name rm delete files and directories RM-RF * Delete all content (including directories and files), where R is recursive and F is mandatory. ln establishes a symbolic link ln-s source target ln-s/etc/inittab inittab (means inittab points to the actual file/etc/inittab) grep queries the text for the content: grep "12" file name; Grep-n "12"   name; Pipe command: | Find/-name *.html|grep bookmark////-name represents search files and directories by name find specific files and directories 2) search for and display files and directories with the specified name in a specific directory find:1 -AMIN-10 files or directories accessed within 10 minutes (corresponding to-) FIND/HOME-ATIME-10 files and directories accessed within 10 hours find/home-cmin-10 files and directories changed within 10 minutes find/home-c Time +10 10 hours ago changed files and directories (previously corresponding to +) 3) Search by file size: find/home-size +10k means to find a file or directory of size 10k in the/home directory

7, Shell's use of command history and Interaction: with the UP and DOWN ARROW keys can repeat the command command completed previously entered: The TAB key to automatically complete the relevant commands, press TAB again to get the list. Shell script file: is a collection of files, commands, permissions to execute, how to execute (./file name)

1) Shell script files that are executed automatically after the user logs on:. BASHRC (which is located in the home directory) before it executes the system script/ETC/BASHRC is primarily a basic configuration data file:. bash_profile file (which is located in the home directory),  The system script file that was executed before it was:/etc/profile file, mainly configuring environment variables. Description: The profile configuration environment variable is a common system environment variable for all users, and the. bash_profile file is the environment variable that each user needs to configure. The. bashrc file is a file that is executed every time a user logs on, such as when a user is logged on,  Automatically executes a program that you can place in the file. If you want each user to log in and execute a program, you can put the program in the profile file.

2) Configure the. bashrc file to specify that some programs start when the user logs on. The way to do this is to add the appropriate execution statement to the file.

3) Use export path= $PATH: $HOME/bin:/root/test/t1 temporarily join a path. Represents the output environment variable path, which references the original value $path $HOME represents the working home directory, ":" is a path delimiter defined environment variable: Shell: Default shell path: Path User: User name of the currently logged on user displays variable contents: Echo $PAT H Echo $USER Echo $SHELL

4) wildcard * represents multiple letters or numbers?      Represents a letter or a number such as: LS a * ls a?    ls? at? LS abc[1-6].tif escape character: \ Ls/mnt/win1/my\document

5) Alias use alias if you want to give an individual name to a command statement. Example: Alias showdir= ' ls-l/home '

8, Linux startup process (need to understand the single-user mode, start does not read/etc/inittab files) Linux system startup process is as follows: 1) BIOS self-test: Mainly on the hardware boot mode detection. 2) Start Grub/lilo:3) run the Linux kernel and detect hardware 4) The first process that runs the System init 5) Init reads the information from the System file boot configuration file/etc/inittab to initialize 6)/etc/rc.d/ Rc.sysinit System Initialization script 7)/etc/rc.d/rcx.d/[ks]* termination of service starting with "K" based on RunLevel x Configuration service start service with "S" 8)/etc/rc.d/rc.local perform local special configuration 9) other special services

9, compression and decompression method   (note: File and folder differences) in zip and unzip processing. zip file  1) Zip command Basic use method:  zip file.zip The original file name, the zip after the compressed file name, Enter the file you want to compress at the back of it   compress multiple files:  zip file.zip The original file name 1, the original filename 2 、、、; The name of the zip after the compressed file, after which you enter the file to be compressed  2) compressed, automatically delete the original file  zip-m file.zip to.txt After compressing the to.txt file into a file.zip file, To.txt automatically deletes the  3) and compresses the subdirectories together  zip-r file.zip The original file name, indicating that the subdirectories under the current directory are compressed together  4) ignores the contents of subdirectories and Nbsp;zip-j file.zip The original file name  5) remove the compressed or unnecessary compressed files  zip-n .mpg:.jpg:.gif  (note the middle of the file to use: Separate)  6) compress files after one day & Nbsp;zip-t 102002 File.zip indicates that the file is compressed after October 20, 2002 in the current directory. &NBSP;7) does not compress the original file name of the linked file  zip-y file.zip The original file name  8) compression rate issue. -1--->-9  9 compression rate up to  zip-9 file.zip original file name  9) exclude files that do not need to be compressed  zip file.zip The original file name-X File2.txt represents the time of compression The File2.txt file in the current directory is excluded. Extract the. zip file with the Unzip command:  1) directly unzip the file  unzip file.zip  2) exclude files that do not need to be decompressed  unzip file.zip-x file2 In addition to the File2 file, all other files are decompressed  3) to view the contents of the compressed package  unzip-z File.zip means to view the contents of the File.zip compressed package. You can also use "-L", "-V" to view the contents of the compressed package.

Process. gz files with gzip and gunzip

10, Linux under the Java Network Programming->my QQ Linux Server public class myservertest{public static void Main (string[] args) {

try{//server-side Accept message Part ServerSocket Ss=new serversocket (8888);//Create a server, listen 8888 Port System.out.println ("I am Listen"); Socket sk=ss.accept (); Listen, know a client to connect to itself, once the connection is successful, return a scoket (understood as a data pipeline) InputStreamReader isr=new InputStreamReader (Sk.getinputstream ());// The information sent from the client can be read Bufferreader br=new Bufferreader (ISR);//For better reading, put it into bufferreader

String kk=br.readline ();//Read it out

SYSTEM.OUT.PRINTLN ("Client send::" +KK);   Return a message from the server to the client section OutputStreamWriter osw=new OutputStreamWriter (Sk.getoutputstream ());      BufferedWriter bw=new BufferedWriter (OSW);      PrintWriter pw=new PrintWriter (osw,true); Send Pw.println ("I Get your Mes" +kk);

}catch (Exception e) {e.printstatictrace (); } }

}

Windows client public class myclienttest{public static void Main (string[] args) {try{scoket s=new Socket ("172.16.54.23" , 8888);//link server-side outputstreamwriter osw=new OutputStreamWriter (S.getoutstreamstream ());      Write send information via file stream bufferedwriter bw=new bufferedwriter (OSW);      PrintWriter pw=new PrintWriter (bw,true); Send Pw.println ("Hello Wrold");

Read the information returned by the server side InputStreamReader isr=new inputstreamreader (Sk.getinputstream ());//can read information sent from the client Bufferreader br= New Bufferreader (ISR);//For better reading, put it into the Bufferreader

String response=br.readline ();//Read it out

SYSTEM.OUT.PRINTLN ("Server response is:::" +response);  }catch (Exception e) {e.printstacktrace (); }  }

}

Linux Learning Notes 4:linux task scheduling, process management, MySQL installation and use, use of SSH tools, Linux network programming

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.