Regular Expressions
1. Use du-sh/* to see how much memory is consumed by all directories under the root
2.lsof-i: view Port
3. empty the file,cat/dev/null>access_log empty a file
4. If you are creating a directory under the Oldboy/ett directory, what is the number of hard links in/oldbot/ett and why?
2 , because of the following sub-directory : is a hard link to the parent directory
5 Detect if a command is a built-in command:type command name
Linux Multi-user multi-tasking introduction:
1. The identity of the user is identified by UID(useridentify) and GID (groupidentify) .
2. Super User uid=0,gid=0, reproduction environment is generally forbidden to use the root user directly SSH connect to the server. Other users are virtual users, the feature is not to log on
- 0 for Superuser,1-499 for virtual user,500-65535 on behalf of ordinary users
4. The service runtime requires a user role, you can not login, so in the work we want to run the MySQL database, you can create the following users
GROUP-G 49
Useradd-u 49-s/sbin/nologin-g 49
-S interpreter command instead of requiring user login, direct access to
ID MySQL
Tail-1/etc/passwd
Su-mysql
Chattr-i/etc/passwd/etc/shadow/etc/group/etc/gshadow Add a lock
Chattr +i/etc/passwd/etc/shadow/etc/group/etc/gshadow Unlock
There are 3 types of time stat file names in Linux
Regular Expressions
1. The regular expression is a set of processing string rules and methods, in the behavior of the string processing, through special symbol assistance, fast filter, replace some strings.
2. Operations, a large number of access error logs, how to quickly filter out the content we want, we need regular expression
Regular Expressions in 3.Linux based on awk/sed/grep Regular Expressions
^word: Indicates that it starts with word
word$: represents the end of word
grep "M" Oldboy.txt filter out sentences with m in the file
Grep-i "M" oldboy.txt case insensitive
grep "m$" Oldboy.txt filters out the end of m
4. represents any one character
grep "Bl.og" Olboy.txt matches a blog sentence
Gerp "BO.G" Oldboy.txt matches a bog sentence
5 \ Escape character to restore prototypes of characters with special identity meaning
6. Grep-n. Oldboy.txt The dots here represent all,-n is to add line numbers to all rows
grep "\." Oldboy.txt to filter out all the dots .
*: Repeat 0 or more of the preceding characters, for example 0*;
grep ". *" Oldboy matches all
grep "^.*" oldboy.txt matches any character beginning with the
7.[] character set of a repeating special character symbol
grep "B[lo]og" Oldboy.txt matches an l or o unit blog or Boog;
8.[^] denotes what does not begin with
grep "[^0-9]" oldboy.txt matches a sentence that does not contain a number
9.\{n,m\} repeats n to m times, the previous repeating word such as a\{n,m\}
A\{n,\} repeats at least n times, before a repeating character;
\{n\} repeats n Times, previous character
grep "64\{2,3\}448" Oldboy.txt
To extend the regular expression: Ere
1)+ indicates repetition of one or more preceding characters
Grep-e "64+581" Oldboy.txt
Egrep "64+581" Oldboy.txt
2)? Represents 0 or 1 characters
Grep-e "464?581" Oldboy.txt
Egrep "464?581" Oldboy.txt
3) Use a vertical bar to find multiple strings that match
Egrep "33041|1521"/etc/services
4) Find the "user group" string,grep-e "B (lo|oo) g" Oldboy.txt find the blog and Boog;
title : Remove the IP address of the eth0
The first approach
Ifconfig eth0|grep "inet addr" |awk-f ":" ' {print '} ' |awk-f ' "' {print '} '
The second approach
Ifconfig eth0|sed-n "2p" |awk-f " ": "+" '{print '}'
with a colon space as a delimiter,the + symbol changes the number of consecutive delimiters to 1 .
The third method of
Ifconfig eth0 |sed-n ' inet addr/p ' |sed ' s#^.*addr:# #g ' |sed ' s# bc.*$# #g '
Fourth method
Ifconfig eyh0|sed-n ' s#^.*addr:\ (. *\) BC.*$#\1#GP '
The content in parentheses represents the IP, followed by \1 to replace other content
echo "DDD KKK" >b.txt
Sed ' s#\ (ddd\) \ (kkk\) #\1 \2#g ' B.txt
Ifconfig |sed-n ' ^. #addr: \ ([0-9].*\) bcast:\ ([0-9].*\):* $#\|\2#GP '
A space can not be wrong, to be very precise
How do I get permissions for/etiantian?
Stat-c%a/etiantian directly Filters The 644 's permissions .
What is the number of hard links in Test,ett If you create a directory under /oldboy/ett?
3 ,test . hard links representing the previous level of directory
Eth0 Nic Path:/etc/sysconfig/network-scripts/ifcfg-eth0
Client path :/etc/resolve.conf
a lamp server is placed into an advertisement, and the site is opened with a bad effect on calling this address.
Idea: Traverse all directory files, delete the contents of the above content
simulating cd/root/oldboy implant content
Find/root/oldboy-type F|xargs sed-i ' 1 I <script language=javascripts src=www.baidu.com></script> '
All the files and packages have been advertised.
1. Identify issues with OPS personnel
2. Make a plan, back up the data, and then batch Modify
3. Write solutions to their operations
4. Ask for the results and tell us to write a detailed review log to find the source of the problem
5. Provide a solution to the problem (Site Directory solution)
Delete the contents of the hacker's hair
Find/root/oldboy-type F|xargs sed-i ' 1 I/<script language=javascripts src=www.baidu.com><\/script>/d '
Do not forget to find the source of the problem and repair the vulnerability, the directory permissions of the site is reduced, upload the attachment of the entrance is not detailed filtering.
Echo-n "Oldboy"; echo "Oldboy" no newline output
Echo-n 123
123[[email protected]~]#
Echo-e "Oldboy\noldboy" line break
please give the following format Date command,11-02-26, and then give the implementation of the weekly output, such as output Saturday;
Date +%y-%m-%d
Date-s Modification Time
Date +%w shows the week
To print with Echo, use the back quotation marks.
echo ' Date +%f ' or $ (date%F)
Enterprise Case Packaging
1.tar ZCVF oldboy.tar.gz./oldboy
2.tar TF oldboy.tar.gz Viewing the contents of a package
3. date of the package per day tar zcvf oldboy-$ (date +%f). tar.gz./oldboy packs a day, showing the date
4. retain content for the last 7 days find/log-type f-name "*.log"-mtime +7|xargs rm-f
when using a normal user, execute ifconfig, prompting for no command for any reason
because ifconfig is a system command, can be executed with full path, can be placed under the home directory . bash_profile ;
Regular Expressions under Linux