Linux boot process, PATH, filter level directory, CD parameters, LS-LRT, command cut logs

Source: Internet
Author: User
Tags system log



 


The second wave of orders is coming to us: start-up process, PATH, filter level directory, CD parameters, LS-LRT, command cut logs

1.1 Linux boot- up process 1.1.1 Post (Bios)--MBRBoot--GRUBMenu-- Load Kernel (Kernel)-- RunINITProcess-- Read/etc/inittabconfiguration file-- Execution/etc/rc.sysinitScripts (init scripts, such as settingsIP,hostname)-- Execution/ETC/RC.D/RC(software that is powered on at run level) script-- Start/sbin/mingettyprocess (Display login interface)

1.2 What is PATH environment variable, what role does it have? 1.2.1 View PATH environment variable

[Email protected] ~]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

1.2.2 PATH function:

1) Environment variables

2) The location of the command is stored

1.2.3 the process of executing a command?

1)ls or mkdir

2) The system will go inside the PATH to find out if the command exists

3) exist on the run

4) Error if not present: Command notfound or no Sush file or directory

1.3 How to filter out the first level directory under the/oldboy directory?

method One: [Email protected] oldboy]# TREE-DL 1

.

├──ext

├──test

├──xiaodong

├──xiaofan

└──xingfujie

Note: 1.-D directory-L equivalent to--level, display up to several levels of directories

Method Two: [Email protected] oldboy]# find-maxdepth 1-type d! -name "."

Note: 1. MaxDepth Deepest

2.! To take the opposite meaning

Method Three: [Email protected] oldboy]# ls-l |grep "^d"

Drwxr-xr-x. 3 root root 4096 Dec 10:35 ext

Drwxr-xr-x. 2 root root 4096 Dec 10:35 test

Note: Find the line that starts with D, the ^ number is used only by three Musketeers, and the regular expression is ... Line starting with

method Four: [Email protected] oldboy]# Ls-l | awk ' $2>1 '

Note:The second line is a $ =

Method Five: [Email protected] oldboy]# ls-f |grep "/"

ext/

test/

Note: -F adds different tags (tails) to different files

1.4 use of the CD command and its options

Note: The CD is an internal command and can be viewed in the manual using man cd or help CD

1.4.1 CD-

[Email protected] oldboy]# CD-

Note: Quickly go back to where you were last

1.4.2 CD.

[[Email protected]/]# CD.

Note: Indicates the current directory

1.4.3 CD..

[Email protected]/]# CD.

Note : Return to the top level directory

1.4.4 CD ~

[Email protected]/]# CD ~

[[Email protected]/]# CD

Note: Enter the current user's host directory, and CD a role

1.5 To View the Help manual:

1)helpCD view internal commands

2)ls--help view external command

3)mancd view full help

Note: Chinese man manual (man.linuxde.net)http://linux.51yip.com/ http://man.linuxde.net/

1.6 how the LS command is displayed in chronological order 1.6.1 When LS is displayed in chronological order

Note: The default is a-Z display

[Email protected] oldboy]# LS-LT

Note:-T is displayed according to the modified time of the file (most recent file on top)

1.6.2 ls displayed in reverse order of time

[Email protected] oldboy]# LS-LRT

Note:-r Displays content in reverse order (including time, letters), latest files at the bottom

1.6.3 ls According to the time of the year/ month / day / hour / minute / display

[Email protected] oldboy]# ls-l--time-style=long-iso

-rw-r--r--. 1 root root 0 2017-12-12 123.txt

1.7 To cut a log by command  Note: You can alsoMonitor the log by software, monitor the size of disk space, etc.1.7.1 Modify the system time

[[email protected] oldboy]# date-s "2017-12-19 11:01:00"

1.7.2 the access log for the Nginx/apache service is logged by day in the server local directory /app/logs/ , which is most required to keep The access log for the last 7 days, how can I resolve it? ( Replace rmwith ls-l first)

1) show Log for 7 days (7)

[Email protected] logs]# Find-type f-mtime 7

2) display logs for the last 7 days (-7)

[Email protected] logs]# find-type f-mtime-7 |xargs ls-l

3) display logs up to 7 days ago (+7)

[Email protected] logs]# find-type f-mtime +7 |xargs ls-l

1.7.3 Find the/aap/logs below with . Log and the modified time is 7 days before the file is deleted (first with ls-l instead)

To create a running environment:

Mkdir-p/app/logs
Cd/app/logs
For time in {01..20};d o date-s "201705$time"; Touch access_www_$ (date +%f). Log;d One
Date-s "20170520"

Workaround:

method One: [Email protected] logs]# Find-type f-mtime +7-exec ls-l {} \;

Method Two: [Email protected] logs]# find-type f-mtime +7 |xargs ls-l

Method Three: [[email protected] logs]# ls-l $ (find-type f-mtime +7)

1.7.4 Debug System service Yes, want to see the/vat/log/secure system Log update in real time, how to do?

[Email protected] logs]# tail-f/var/log/secure

Note:tail-f displays end-of-file updates in real time

1.7.5 Find All files under/oldboy that are larger than 1M at the end of log Copy to / tmp .

method One: [[email protected]/]# CP $ (find/oldboy-type f-size +1024k-name "*.log")/tmp/

Method Two: [Email protected]/]# find/oldboy-type f-size +1024k-name "*.log"-exec cp {}/tmp/\;

Method Three: [Email protected]/]# find/oldboy-type f-size +1024k-name "*.log" |xargs cp-t/tmp/

Note : cp-t reverse copy, put the files to be copied on the last side (normal situation in front)

1.7.6 Merge 2 or more file sizes together

[Email protected] logs]# cat/etc/services/etc/services >/123.log

Note:Cat full name is concatenate, merging the meaning of the associated



Linux boot process, PATH, filter level directory, CD parameters, LS-LRT, command cut logs

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.