Important catalog file

data / var variable variable
/ var / log / messages log default
content to run the business, service, the timing generating default logging tasks. Log is to see your process running what is wrong, bug
tail / var / log / messages to see the end of the ten lines of the log

/ var / log / secure system security log user login information
output real-time log output of the tail of the second function
tail -f / var / log / secure
settings to log in xshell wrong password, the system will appear in the Security log error information
grep 'Failed' / var / log / secure

Logs cut to prevent the log file is too large or
the system default to our cutting logs, or log files in order to prevent excessive
ll / var / log / secure *

Log too much influence
experiment: to build a large test file.
Result: The
log is too large card system is found, loaded, however, the impact on the system

/ proc
/ proc / cpuinfo cpu information
processor: 0 core number (starting from 0)
PHYSICAL the above mentioned id: 0 few CPU (starting from 0)
modify the virtual machine and cpu cores

Dual quad-core

grep 'physical id' / proc / cpuinfo CPU qty 0011 a two CPU core CPU two
grep 'processor' / proc / cpuinfo cores 0123 quad-core

lscpu View CPU Information

CPU (s): 1 Number of Core
On-line CPU (s) list : 0 Core number
Socket (s): 1 1 cpu th

CPU (s): 4 cores
On-line CPU (s) list : 0-3 No core
Core (s) per socket: 2 2 th CPU
/ proc / meminfo view memory information
MemTotal: 995880 kB memory size
MemFree: 860232 kB available memory
buffers: 0 kB write buffer
cached: 25864 kB read cache

free -h view memory information

/ proc / loadavg load average load average
load average
cat / proc / loadavg

Is a measure of how busy the system: whether the total number of cores
core 2 ====== maximum number of the CPU 2 loading
4 ====== 4
0.00 0.01 2339 0.07 2/107
average of 1 minute 5 minutes the average value averaged over 15 minutes
w view load information

Note: Inside the FROM option, do not know if the ip address may lie behind the server was hacked
you can also see the user manipulate files

uptime view cpu load information
load a user runtime

What is the measure of the load?
cpu hard disk

top view system details
Press 1 to see all the core
by m can check the memory for up to
exit the command:
Ctrl + c
q

/ proc / mounts to mount information
to understand like, the main concern / etc / fstab
summary
/ etc /
/ etc / sysconfig / Network-scripts / the ifcfg-eth0
NIC configuration file
/ etc / hostname
hostname of the system
/ etc / hosts
IP address and correspondence between the domain name, the local DNS server
/etc/resolv.conf
DNS configuration file 223.5.5.5 nameserver
/etc/rc.local
at startup configuration file, execute permissions to
/ etc / fstab
boot automatically mount the configuration file
/ etc / inittab
operation of the system-level configuration file
/ etc / issue
message before log
/etc/issue.net
prompt before logging in
/ etc / motd
message after the system log in
/ etc / profile
environment variable configuration file
/ etc / bashrc
alias
/ etc / redhat-release
version number to view the system's
/ usr / local
edit the default installation directory
/ var
/ var / log / messages
The default system log
/ var / log / secure
system security log
/ proc
/ proc / cpuinfo
to see cpu information
/ proc / meminfo
to view memory information
/ proc / loadavg
see the average load on the system
/ proc / mounts
to view Mount Details
Create a regular user
useradd username
useradd alex
the above mentioned id alex view the user information
switch users to switch to ordinary users do not need root privileges, password. Switch directly
su - alex - when switched on behalf of the updated environment variables

Case:

Exit alex ordinary users to root
Exit
Ctrl + d
Zimbabwe Logout

xshell create alex user's connection

In the root user password to the general user passwd alex alex
open xshell the conversation window, copy a conversation, rename alex, then set the option, the user name was changed to alex, OK, no password, we'll set a password, the root alex user to set a password.
alex To switch to the root user password is required

PS1 variable to modify the command line format

[\ U @ \ H \ W] \ $
the User @ \ hostname path prompt the user
to know

modify:

PS1 = [\ u @ \ h \ W \ t \ $

yum source modify
the first milestone view the current use of warehouse
yum repolist default warehouse randomly select a university or a warehouse site
second milestone modify the default yum source
mv /etc/yum.repos.d/CentOS-Base .repo /etc/yum.repos.d/CentOS-Base.repo.backup
using wget or curl wget command to download if it is provided that wget installed
curl -o /etc/yum.repos.d/CentOS-Base.repo HTTP : //mirrors.aliyun.com/repo/Centos-6.repo
installation companies expand the installation package epel
install wget
Ctrl + f search page content epel
wget -O /etc/yum.repos.d/epel.repo HTTP: // mirrors.aliyun.com/repo/epel-7.repo
installation command completion packet
yum -y install bash-completion-extras

Close selinux Key (must be closed)
selinux enhanced version of the US National Security Agency developed firewall

永久关闭selinux
        修改配置文件/etc/selinux/config
        重启生效
    临时关闭selinux
        如何查看当前是否关闭了selinux
        getenforce
        [root@oldboy ~]#setenforce 
        usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
        [root@oldboy ~]#setenforce 0
        [root@oldboy ~]#getenforce 
        Permissive
        Enforcing  =====1
        Permissive =====0

Close firewalld focus on learning can close the prohibition closed
centos7.x centos6.x
firewalld iptables focus on
1) Check firewall status c6.x view firewall state
systemctl Status firewalld /etc/init.d/iptables Status
2) temporarily turn off the firewall temporarily turn off the firewall
STOP STOP firewalld /etc/init.d/iptables systemctl
. 3) is permanently closed off permanently firewall firewall
systemctl disable firewalld chkconfig iptables off

Job: curl, date, centos6 install
curl
1 curl http://www.centos.org
save downloaded by -o / -O option file to the specified file:
-o: Save the file to the file specified on the command line file name in
-O: use the URL in the default file name to save the file locally
?
1
2
3
No.4 download the file to a local named mygettext.html
curl -o mygettext.html http://www.gnu.org /software/gettext/manual/gettext.html

Save the file to a local named gettext.html

-O curl http://www.gnu.org/software/gettext/manual/gettext.html
you can also use the shift character ">" the output is steering output
simultaneously acquire multiple files
?
1 URL1 curl -O -O URL2
if when the download multiple files from the same site, curl will try to reuse the link (connection).
-L redirection option by
CURL not sent HTTP Location headers (redirected) by default when a requested page is moved to another site, it sends a Loaction the HTTP
header as a request, and then redirects the request to the new the address.
For example: When you visit google.com, you will be automatically redirected to the address on google.com.hk.
?
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is curl http://www.google.com
<the HTML>
<the HEAD>
<Meta HTTP-equiv = "Content-type" Content = "text / HTML; charset = UTF - ">
<TITLE> Moved </ TITLE>

<The BODY>
<H> Moved </ H>
of The Document Moved has
<A the HREF = " http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http:// </A> www.google.com.hk/&ust=amp;usg=AFQjCNFoumfjyJpNDPuFKTibavEaA">here ;.
</ the BODY>
</ the HTML>
the output requested description files are transferred to the http://www.google. com.hk.
This can be done by using the -L option to force the redirection
1 # curl make use redirection address, then queries the site google.com.hk
2 curl -L http://www.google.com
HTTP
by using -C option can be used for large file HTTP functionality, such as:
?
1
2
3
4
5
6 # when the file download is complete before the end of the process
$ curl -O http://www.gnu.org/software/gettext /manual/gettext.html
##############.%

Continue to download the file by adding the -C option already downloaded files will not be re-downloaded

-C curl - -O http://www.gnu.org/software/gettext/manual/gettext.html
. ###############%
using a network speed of CURL
by - -limit-rate option to limit the maximum network usage of CURL

The maximum download speed will not exceed 1000B / second

Rate -O-1000B --limit curl http://www.gnu.org/software/gettext/manual/gettext.html
download the specified file modified time
when downloading a file, the file's last-modified date judge, if the file is modified during the specified date, download it, or do not download.
This feature can be achieved by using the -z option:

If yy.html file has been updated only after downloading 12/21/2011

the -z 21-Dec-curl 11 http://www.example.com/yy.html
CURL authorization
when accessing a page that requires authorization, can provide a user name and password authorized by the -u option
curl -u username: password URL

The usual practice is to enter the command line, only the user name, and then prompts for a password, so the password can be guaranteed not to leak when viewing history

4 curl -u username URL
from an FTP server to download files
also support FTP download CURL, if specified in the url is the path to a file rather than the specific name of a file to be downloaded, CURL will be all under the directory lists file name and not to download all files in this directory

List all the files in the public_html folders and files

curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/

Download file xss.php

curl -u ftpuser: ftppass -O ftp: //ftp_server/public_html/xss.php
upload files to the FTP server
can be specified by the local file uploaded to the FTP server options -T
?
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
# 11 myfile.txt upload files to the server

curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com

Uploading multiple files

curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com

Content from the standard input file gets saved to the server specified in

curl -u ftpuser: ftppass -T - ftp://ftp.testserver.com/myfile_1.txt
For more information
For more information about the link by using the -v and -trace
by dictionary lookup word

Discover the meaning of the word bash

curl dict://dict.org/d:bash

Lists all available dictionaries

curl dict://dict.org/show:db

Bash query word in the dictionary meaning foldoc

curl dict: //dict.org/d: bash: foldoc
to CURL proxy settings
can be added to the proxy function -x option CURL

Specify a proxy host and port

-x proxysever.test.com:3128 curl http://google.co.in
other sites organize
preservation and use of the Site cookie information

Save the cookies information site to sugarcookies file

curl -D sugarcookies http://localhost/sugarcrm/index.php

Use the last saved cookie information

-b sugarcookies curl HTTP: //localhost/sugarcrm/index.php
transfer request data
default curl using GET method request data, which is transmitted directly via the URL data
transfer can be specified by data --data / -d mode using the POST method

GET

curl -u username https://api.github.com/user?access_token=XXXXXXXXXX

POST

curl -u username --data "param=value¶m=value" https://api.github.com

Can also specify a file, the content file is transmitted as data to the server

--data @filename curl https://github.api.com/authorizations
Note: By default, the data is transmitted over a POST if special characters, special characters need to be escaped is first passed to the server, such as value value contains spaces, you need to first convert the space into 20%, such as:
curl -d "201% value" http://hostname.com
in the new version of cURL provided a new option --data- urlencode, it will automatically escape special characters by the parameters of the options provided.
urlencode --data-curl "value. 1" http://hostname.com
except GET and POST protocol, but also other protocols can be specified by -X options, such as:
curl -I -X the DELETE HTTPS: //api.github .cim
upload files
curl --form "[email protected]" HTTP: // hostname / Resource
dATE
1, the command: date
2, function: date or can be used to display the date and time settings of the system.
3, command parameter
-d <string>: date and time display string referred to. Before and after the string must be enclosed in double quotes;
-s <string> : Character string set date and time.
Before and after the string must be enclosed in double quotes; -u: display GMT;
--help: online help;
--version: show the version information.
4, the date format string list

% H hours (represented 00-23).
% I h (expressed in 01-12).
H% K (expressed in 0-23).
h% l (expressed 0-12).
% M min (00-59 represented).
% P AM or PM.
% r time (minutes and seconds when the content, expressed in hours 12 hours AM / PM).
% s total number of seconds. Starting time is 1970-01-01 00:00:00 UTC.
% S seconds (expressed in local usage).
% T time (minutes and seconds when containing hours in 24-hour format).
% X time (expressed in local usage).
% Z downtown.
Abbreviations% a week.
% A week's full name.
% b abbreviated English name of the month.
% B full English name of the month.
% c date and time. Only instruction input date also show the same results.
Date% d (expressed in 01-31).
% D date (including date).
% j day of the year in.
Month% m (expressed in 01-12).
Weeks of the year in% U.
% w the number of days of the week, 0 for Sunday, 1 for Monday, and so on different terms.
Date% x (expressed in local usage).
% y Year (00-99 to be represented).
% Y year (expressed in four digits).
% n in the display, insert a new row.
% t in the display, insert tab.
MM Month (necessary)
DD date (necessary)
HH h (necessary)
mm minute (necessary)
SS seconds (optional)

5, examples of the
formatted output:
DATE + "% Y-M-% D%"
2015-12-07
output last date:
DATE -d ". 1 Day ago Member" + "% Y-M-% D%"
2015-11 -19
2 seconds output:
DATE -d "2 SECOND" +: "% D%% Y-M-% H% S% M."
2015-11-20 14: 21.31
legendary 1234567890 seconds:
DATE -d "1970-01-01 1234567890 seconds The" + "% Y-M-% D%% H:% m:% S"
2009-02-13 23:02:30
ordinary transfer format:
DATE -d "2009-12- 12 is "+" the Y% /% m /% D% H:% M.% S "
12/12/2009 00: 00.00
Apache format conversion:
DATE -d" On Dec. 5, 2009 12:00:37 AM "+" Y-M-% D%%% H:% M.% S "
2009-12-05 00: 00.37
after the format conversion time:
DATE -d" On Dec. 5, 2009 12:00:37 AM year ago Member 2 "+" % Y-% m-% d% H :% M.% S "
2007-12-0500: 00.37
subtraction operation:

date +% Y% m% d # day before the date display
date -d "+1 day" +% Y% m% d # previous day of the date display
date -d "-1 day" +% Y% m% d after the day's date # display
date -d "-1 month" +% Y% m% d # date Jan. displayed on the
date -d "+1 month" +% Y% m% d # displays the date of the next month
date -d "-1 year" +% Y% m% d # display year before the date of
date -d "+1 year" +% Y% m% d # display date year

set time:

date -s # set the current time, only root privileges to set up, the other can only view the
date -s 20120523 # set to 20,120,523, which will set the specific time to empty 00:00:00
DATE -s 01:01:01 # Set the specific time, date change will not do to
date -s "01:01:01 2012-05-23" # this sets all-time
date -s "01:01:01 20120523" # this sets all-time
date -s "2012-05-23 01:01:01" # this sets all-time
date -s "20120523 01:01:01" # this sets all the time

Checking a set of time it takes to command:

#!/bin/bash
start=$(date +%s)
nmap man.linuxde.net &> /dev/null
end=$(date +%s)
difference=$(( end - start ))
echo $difference seconds.

Chapter 1 Linux date command Detailed

1, display time
date command to show the date in the specified format, just type the date in a default format to display the current time. as follows:

To display the date in a specified format, can use the "+" character string at the beginning of the format specified in detail in the following format:
% n-: next line
% t: tabbing
% H: hour (00-23)
% the I: h ( 01-12)
% K: hour (0-23)
% L: hour (1-12)
% M: min (00-59)
% P: AM local display or the PM
% R & lt: direct display time (12 hour clock, the format HH: mm: SS [the AP] M)
% S: number of seconds from January 1, 1970 to date 00:00:00 UTC
% S: seconds (00-60)
% T: time displayed directly ( 24 hour)
% X-: equivalent% H:% M:% S
% the Z: display area
% a: week (the Sun-Sat)
% A: week (the Sunday-Saturday)
% B: month (Jan-Dec )
% B: month (January-December)
% C: direct display date and time
% d: day (01-31)
% D: direct display date (mm / dd / YY)
% H: with B%
% J: a on the day of (001-366)
% m: month (01-12)
% U: (the case with Sunday as the first day of the week) the first few weeks of the year (00-53)
% w: The first few days (0-6) of the week
% W: The first few weeks of the year (00-53) (the first day of the week for the case to Monday)
% the X-: direct display date (mm / dd / YY)
% the y-: the last two digits of the year (00.99)
% the Y-: full year (0000-9999)
above format does not have to all keep in mind, you only need to master a few common. E.g. expressed in% Y,% m is the month,% d represents day,% H represents hours,% M indicates min,% S represents seconds,% s represents from 1 January 1970 00:00:00 UTC date the number of seconds, the equivalent time function,% w represents the day of the week.
Examples below:

If you want to display the current time is not time, but the elapsed time operation, you can use the -d option. Three years ago, for example, display the time:

I was very hurt to see this command, the last time can not go back, only to see the command. Show time after three months:

Show time after ten days:

Sometimes the need to obtain the current time from at 0:00 on 1970 experienced the number of seconds 0 seconds, stored in a variable:

2. Set the time
you can set the system time with the -s option:

A variety of ways, either you choose:

You have to believe in intelligent enough date of.

Guess you like

Origin blog.51cto.com/14465325/2427828