grep
Find a string in the specified directory or file, for example:
- grep "Exception" Webx.log, finding the string "Exception" in a file
- grep "Exception" webx.log*, finds the string "Exception" in the file at the beginning of the Webx.log filename
- grep "Exception"-R. , find the string "Exception" under the current directory
- grep "Exception"-V. , look for rows without the string "Exception" in the current directory, and output
- The above is the default output to find the character of the row, plus the parameter-A 1 or-B 2, you can output the row of the found character in the last 1 lines, or the first 2 rows
Grep-a 1 "Exception" Webx.log,grep-b 2 "Exception" Webx.log
Tail
The trailing text of the output file, for example:
- Tail Webx.log, the output webx.log file after 10 lines, the default display 10 lines.
- Tail-4 Webx.log, output the last 4 lines of the Webx.log file.
- Tail +4 webx.log, output webx.log all lines after line 4th.
- Tail-f webx.log, dynamic output webx.log New line, press Crtl+c end.
Cat
Output file contents, such as:
- Cat Webx.log, displaying webx.log file contents on the screen
- Cat-a Webx.log, displaying webx.log file contents on the screen, including special characters
CP
Copy files, for example:
- CP webx.log webx.log.1, copy Webx.log to Webx.log.1
- Cp-r logs Logs-bak, copy files from the entire logs to the Logs-bak directory
MV
Moving files, for example
- MV Webx.log webx.log.1, move file and rename to Webx.log.1
- MV Webx.log. /, move Webx.log file to parent directory
LN
Link files, for example:
- Ln-s work/output/logs logs, link work/output/logs to current logs directory.
Less
View Files
- Less webx.log, view the contents of the Webx.log file, enter, press the F key to page forward, press the B key to page back, Shift+g to the last line of the file, shift+h to the first line of the file
VI
Edit File
- VI Webx.log, editor Webx.log,vi powerful, detailed see VI--h
RM
Delete a file or a path, for example:
- RM Webx.log, delete webx.log file
- RM webx.log*, delete all files with file names beginning with Webx.log
- RM-RF logs, delete the entire logs directory
Tar
File or file directory package, unpack, example:
- TAR-CZVF logs.tar.gz *.log. , package the. log.* to Logs.tar.gz
- TAR-ZXVF logs.tar.gz, unpacking
WC
The function of the WC command is to count the number of bytes, words, and lines in the specified file, and to display the output of the statistical results
- Wc-l fileName, number of rows in the statistics file
which
$PATH environment variable contains the executable file lookup in the path, in the general form: which [-a] filename ...
- Which ' Java ', the absolute path of the executable file named ' Java ' is output to the screen with all paths specified by the current $path variable
- Which-a ' Java ', where the current $path variable specifies all paths named ' Java ' and the absolute path of the executable file is output to the screen, containing all matches, including the files that ln connects to ' Java '
If the thing you're looking for is an executable file and under $path, it will be much more efficient than find.
Find
File lookup, general form: Find Pathname-options [-print-exec-ok ...]
- Find-name ". Log.", find all *.log* log files under current path, output on screen
- Find-name ". Classpath", the current path to find all files named. classpath, output on the screen
http://www.linuxsir.org/main/?q=node/137, this article has a detailed introduction to the use of find
sed
editing work, document processing
- Sed-i ' s/\/home\/zxf\/antx/d:\/antx\/dist\/antx/'. Classpath, in the. classpath file, replace/home/zxf/antx with D:/antx/dist/antx
http://fanqiang.chinaunix.net/a6/b9/20010729/0905001041.html See more about this introduction
PS
System management, monitoring without ps,ps aux and PS ax is my most used
- -A lists all trips
- -W display widen to show more information
- -au Show more detailed information
- -aux Show all itineraries that contain other users
DF
Displays usage information for system disk space. Note the use of the system disk partition, the amount that can be displayed, is not the actual size of each directory.
- -h displays values in k/m/g form
- One of the implications of using this command is that when disk space is full (for example,/home usage exceeds 90%), then memory-intensive operations (such as updating antx, second-party class libraries), the Linux system initiates the paging daemon KSWAPD (this is not necessarily the case to start the process, KSWAPD is automatically managed by Linux), the main role of this process is related to memory and cache, but this memory-consuming operation makes the memory is not enough, and the disk does not have enough cache space, the KSWAPD process will continue to execute and occupy high CPU resources, Linux server load will reach about 1.5, the user executes the command is basically not responding. So when the Linux system load value is higher, you can run this command to see how the system disk is being used, and perhaps you can find the problem.
du
Statistics file space usage.
- You can count the amount of space a folder occupies.
- -h displays size in k/m/g form
- -S shows only the total
Common Linux Commands