Linux Common Position / Display command
Advertisements
Linux Common Position / Display command
December 30, 2009, 5:28 pm <! - By marco ->
Linux Find / positioning function in order:
| Common commands | Brief English description | Program directory |
| more | Page displays a file or any output, press q key to stop the show | / Bin |
| less | And the more command similar to the difference is less ordered in addition to press the space bar down to display the file, but also can use the arrow keys to scroll documents that support reverse queries | / Usr / bin |
| cat | Displays the entire contents of the file does not flip feature, so often and the more command with the use | / Bin |
| whereis | In a particular directory to find matching documents | / Usr / bin |
| find | Complex query for a document search | / Usr / bin |
| slocate | Find document or directory | / Usr / bin |
| locate | Search for files by file name tool | / Usr / bin |
| grep | Find the contents of a string instrument | / Bin |
| env | View environment settings | / Usr / bin |
| which | $ PATH environment variable set in the directory where the files to find qualified | / Bin |
| apropos | In the whatis database to search for specific strings | / Usr / bin |
more [file name]
more command's primary role is to output in the form of pages displayed on the screen, a stop time, for example, x ls command to find a letter at the beginning of the file, if the ls x * too many files are still listed (more than a screen), will work with the pipe symbol and the more command: ls x * | more to page display output to the terminal. more command to stop about a screen, press the space bar will continue to show the contents of the next screen. more like DOS's DIR command on the / P option.
Can also use the more command page shows the contents of the article, for example,
more /etc/XF86Config cat /etc/XF86Config | more
But because more birth defects, if you read this page, you want to look back at previous does not work, must be from the first page again, that does not support page up. This is more reason for the command is rarely used, it is often less command instead of using the more command or directly with a text editor view.
less [filename]
Page Display a file and can reverse query
less command of the name is very interesting, deliberately playing with more orders with Taiwan, you called the "more", I call "less", just like toothpaste, I told you call black white, like toothpaste. The fact that they literally meaningless. less order to improve the most important point is that relative to the more command is, less negative view command support functions (press PgUp key).
type
type command can not be considered fact, find command, which is used to distinguish the type of a command that comes from the shell (internal order), or by the external shell of independent binary file (or shell scripts, etc.). If an external command, then when using the-p parameter type commands, the output will show the path of the order, which is equivalent to the command.
type command to use examples:
1 2 3 4 5 6 | # The system will prompt, cd is shell The native command (build-in) type cd # Prompted, grep is an external command , And shows the path of the command type grep # With-p parameter , Which is equivalent to the command type -p grep |
whatis keyword ...
Specified in the whatis database keyword search command. whatis database contains a brief description of all system commands, and whatis commands in the database keyword search command line, and the results shown in the standard output (standard output). whatis database is created with makewhatis this command. Also, whatis and apropos commands similar to the command, are based on the whatis Database search keywords.
whereis command / program name
whereis is a small handy file search tool designed to search for executable programs, original programs and user manual.
1 2 3 4 5 6 7 8 9 10 11 12 | Syntax :whereis [-bfmsu][-B < Directory >...][-M < Directory >...][-S < Directory >...][ File ...] Supplement :whereis Instruction in a specific directory to find qualified file. These files should belong to the original code of potent , Binary file, or the Help file . Parameters : -b Find only binary files . -B< Directory > Only in the setting of the directory to find the binary file . -f Does not display the path name of the file name before . -m Only to find documentation . -M< Directory > Only in the setting of the directory to find documentation . -s Only to find the source code files . -S< Directory > Only in the setting of the directory to find the source code files . -u Find the file does not contain the specified type . If you omit the argument, it returns all the information . |
Such as fdisk command did not know the store where you can use the whereis fdisk command to find.
If you do need to find the procedure, but with the whereis can not find it, it means the system does not install the program, such as whereis goic. That can only be used whereis command / program name in the search, not search for regular files.
1 2 | whereis which # output:which: /bin/which /usr/bin/which /usr/share/man/man1/which.1.gz |
where <br /> and whereis command similar to, but it will not search for the command / program's Help file.
1 2 3 4 5 | where which # output: which: shell built-in command /usr/bin/which /bin/which |
which
which commands and whatis / whereis command is very similar.
1 2 3 4 5 6 7 8 9 |
Syntax :which [ File ...]
Help :which The role of the command, in the PATH Variable specifies the path, the search for a location system commands , And return the first result .
In other words, the use of which Command, you can see the existence of a system command , And perform in the end is a position which commands. And whereis Set out the
With binary commands and source code .
Parameters :
-n< File name length > Specify the file name length specified must be greater than or equal to the length of the longest of all the documents file name
-p< File name length > The same with the-n parameter , But here < File name length > Including the file path
-w Specifies the width of the output field
-V Display version information
|
which command only in the $ PATH environment variable to set the search path to find commands. For example:
1 2 3 4 | # which Only $PATH Path to find and list only the first ( Jibei executed copy of the order that the position ) which fdisk # /sbin/fdisk # whereis Will find out all whereis fdisk # fdisk: /sbin/fdisk /usr/share/man/man8/fdisk.8.gz |
find
find is the most common and most powerful search command, you can use it to find any file you are looking for. Its parameter options are abundant, which also led it difficult to use, but I think when you know it, it will be your most capable assistant.
find the use of the following format:
find < Specified directory > < Specified conditions > < Routine >
- < Specified directory >: The Search for directory and all subdirectories. The default is the current directory .
- < Specified conditions >: The characteristics of the file to search .
- < Routine >: Search results specific treatment .
If you do not add any parameters, find the default search current directory and its subdirectories , And does not filter any results ( That is, return all documents ), Will they all appear on the screen .
Use the following example:
Search current directory ( Including subdirectories, following the same ) , All the file names my Beginning of the document find . -name 'my*' The search root directory /( Including subdirectories, following the same ) , All the file names my* At the beginning of the file and print find / -name my* -print Search the current directory, all files names my At the beginning of the file and display them for more information find . -name 'my*' -ls Search the current directory, all in the past 10 Minutes in the updated common file. If not -type f Parameters, the search regular file + Special file + directory find . -type f -mmin -10
-Print option is to print the output to the terminal. It also has other, more complex applications. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Search by time : From the / usr directory to find the most recent 3 Days to take off the paper memory
find /usr -atime 3 - print
# Search by time : From the / usr directory to find the most recent 5 Days modified files
find /usr -ctime 5 - print
# From the / doc directory to find the owner is jacky And the file name of all files beginning with j
find /doc -user jacky -name 'j*' - print
# From the / doc directory to find the file name ja At the beginning or the beginning of the document ma
find /doc \( -name 'ja*' -o- -name 'ma*' \) - print
# Remove the / doc directory of any file name ending bak File .
# -exec Option is the implementation of means, rm is the remove command ,{ } Indicates that the file name ,"\;" Is the end of the command under
find /doc -name '*bak' -exec rm {} \;
|
If you only know a certain file size, modification date and other characteristics can also use the "find" command to find out, and WINDOWS system "search" function is basically the same. For example, the user can press the name, type and size of the search files and folders. Users can even search for specific text file contains. If the user is using Active Directory, this time can also search with a specific name or location of the printer.
For example, a Linux file size of 1,500 bytes, but we use the following command to check find /-size 1500c, character c shows that the size of the file you want to find the unit is bytes. If we in this paper do not know the specific size, then Linux can also find the means to resolve ambiguous. For example, we enter find /-size +10000000 c of this order, indicating that we specify the system to find out the root directory of more than 10 million bytes of the file and displayed. Command + is the only list that requires a system is greater than the specified size of file, use the "-" indicates less than the specified size of the required system files are listed. The following list is to use a different Linux "find" command system to make the search action, it is easy to see from the use of Linux find command in the way are many, find command to locate the file as long as the flexible application, no better than in the WINDOWS Find poor.
1 2 3 4 5 6 7 8 | find / -amin -10 # Find the last 10 minutes in the system file access find / -atime -2 # Find in the system to access the files the last 48 hours find / -empty # Find empty in the system file or folder find / -group cat # Find in the system files are groupcat find / -mmin -5 # Find the last 5 minutes in the system files modified in the find / -mtime -1 # Find in the last 24 hours the system files modified find / -nouser # Find the user in the system file is invalid find / -user fred # Find in the system belongs to the user's files FRED |
The following list is of the order to find the specified file to find the characteristics of part of the conditions. Here does not list all the search terms, reference books about Linux to know all about the search function find the command.
1 2 3 4 5 6 7 8 9 | -amin n Find the last N minutes to access the system files -atime n Find the final system n*24 Hour access to the file -cmin n Find the system state of the last N minutes, the file was changed -ctime n Find the final system n*24 H file is changed the state -empty Find an empty file system, or a blank file directory , There is no subdirectory or directory folder -false Find the file system is always wrong -fstype type Find the system exists in the specified file system file, for example, :ext2 . -gid n Find the file system ID for the digital group n File -group gname Find the file system, file group belonging to gnam , And specify the group and the ID of the file |
find command, control options Description:
find command also provides some unique options to the user to control the *** to find. The following table summarizes our most basic, the most common find command control options and their usage. Options and uses Description:
1 2 3 4 5 6 7 8 | -daystart Test system within 24 hours from today's paper , Use similar -amin -depth Find the process using deep-level approach, to a certain level of priority to find the file specified directory contents -follow Follow the links to ways to find a wildcard ; Alternatively, you can ignore the link means wildcard queries -help Display command summary -maxdepth levels At one level, the directory in accordance with the descending method lookup -mount Not find the file system directory, use similar -xdev. -noleaf Prohibit non-UNUX file system ,MS-DOS System, CD-ROM file system optimized to find -version Print version number |
Use the-follow option, find an order link to follow a wildcard way to find, unless you specify this option, otherwise the general find command will ignore file wildcard way to find the link.
-Maxdepth option is to limit the role of command in the directory and find ways to find documents according to decreasing the time to search for files much more than a certain level or search the directory, this has led to look to slow down, look to spend too much time. For example, we want the current (.) Directory and its subdirectories to find a file named fred, not down to find three subdirectories, you can use the command:
find.-maxdepth 2 -namefred
If the fred file ./sub1/fred directory, then the command will locate the file directly, find it easier. If the file ./sub1/sub2/fred directory, then the command can not find. As previously to find the largest command in the directory inquiries directory level 2, only to find 2 layers directory file. The goal is to find the command to make a more accurate positioning file, if you already know about a file where the file directory series, then added-maxdepth n will soon be able to find success in the specified directory.
find ways to find mixed conditions
find command can search using the hybrid method, for example, we want to / tmp directory to find Dayu 100 000 000 bytes and 48-hour modified in a file, we can use-and to find the option to link the two together to form Find a mixed approach:
find /tmp -size +10000000c -and -mtime +2
Computer language learning been friends all know, in computer languages, the use and, or, respectively, "and" and "or" relationship. Find command in the Linux system in the same general. There are examples of this, find /-user fred-or-usergeorge, can be interpreted as the / tmp directory to find fred or george are both user files. In the find command can also use the "non" to find the relationship between the documents, if the / tmp directory does not belong to panda to find all the files, use find / tmp!-User panda command can be resolved.
find find and display the file <br /> If you want to know find the file details and attributes, if taken first to find files, then use the ls command to view the file information is very tedious, you can use these two commands together :
1 2 3 | find/-name"httpd.conf"-ls # Find the httpd.conf file system appears on the screen immediately after the httpd.conf File Information 12063 34 -rw-r--r-- 1 root root 33545 Dec 30 15:36 /etc/httpd/conf/httpd.conf |
Here are some commonly used to find files and display file information, and use the parameters:
1 2 3 4 5 6 7 | -exec command; Find and execute the command -fprint file Print file full file name -fprint0 file Print file full file name including the empty file -fprintf file format Print file format -ok command; To the user command *** For, according to the user Y Confirm the input implementation -printf format Print file format -ls Print the same file format . |
locate filename
locate command to search for files by file name tool, its use is relatively simple.
locate the command is "find-name" another formulation, but faster than the latter, because it does not search for specific directories, but search a database (/ var / lib / locatedb), this database contains All local all the file information. Linux system automatically create the database, and automatically every day (cronjob) updatedb update the index database, so use the locate command finding out over the latest changes in the file. To avoid this situation, you can use locate before using the updatedb command, manually update the database.
If the new software is installed or stored in a new file, it must first run the updatedb command to generate the latest index database, and then locate search can reflect the true results.
1 2 3 4 5 6 7 8 9 10 | # First run updatedb to create or update the index database updatedb # Looking at which files are location vsftpd.conf : locate my.so # Etc directory to search all sh Beginning of the document locate /etc/sh # Search user home directory, all m Beginning of the document locate ~/m # Search user home directory, all m At the beginning of the file, and ignore case locate -i ~/m |
slocate (secure locate)
slocate itself has a database, which documents stored in the system and directory information. slocate command to use the database to find documents or directories.
1 2 3 4 5 6 | Syntax :slocate [-u][--help][--version][-d < Directory >][ Find a document ] Parameters : -d< Directory > Or --database=< Directory > Specify the directory where the database -u Update slocate database --help Display help --version Display version information |
apropos keyword ...
apropos searches the whatis database consistent with the description keyword, and the results shown in the standard output (terminal).
grep [- options] [string] [file name]
Find the file containing the contents of a string instrument. For example, we want a directory of 200 files inside, find out which file that "lucky" word: grep lucky *. Other common options are:
1 2 3 | -n At the same time the term appears in the article listed in the first few lines . -c Calculate the number of occurrences of the string . -i When compared, the difference does not care about the case . |
The following is written by the help of grep command to find the document tools grep_for:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#!/bin/bash
if [ -z "$1" ]
then
echo 'Usage: grep_for CONTENT_PATTERN FILENAME_FILTER_PATTERN [OPTION_FOR_GREP]'
exit 1
fi
content=$1
if [ -z "$2" ]
then
shift
else
flag=`echo $2 | sed 's/^\(.\).*$/\1/'`
if [ "$flag" == "-" ]
then
shift
else
filter=$2
shift
shift
fi
fi
if [ -z "$filter" ]
then
find -print0 | grep -zv '\.svn' | xargs -0 grep --color $content $@
else
find -print0 | grep -zv '\.svn' | grep -z $filter | xargs -0 grep --color $content $@
fi
|
Move the script to the appropriate directory, you can use, for example:
cd /usr/local/bin sudo mv ~/workspace/grep_for . sudo chmod 755 grep_for #usage grep_for ruby
env View environment settings
env command used to set system environment variables, such as the terminal type (bash, sh, zsh, etc.), default browser, the user home directory (Home Directory) and so on. The most common is to check the value of the PATH environment variable. PATH environment variable controls the directory in which to look at the terminal enter the command, the default command search order is:
1 2 3 4 5 6 | /usr/bin /sbin /usr/sbin /usr/local/bin /usr/X11R6/bin /root/bin |
You can ~ /. Bashrc or ~ /. Profile (current user) or / etc / profile (global) directory to reset the PATH variable, add a custom search path:
1 2 3 | export ANDROID=~/mobile-dev/android/tools export PATH=/usr/local/git/bin:/usr/local/git/libexec/git-core:$ANDROID:$ANT_HOME/bin:$PATH export MANPATH=/usr/local/git/manual:$MANPATH |
Can also use the env command to re-set the PATH variable, if you want to add the path to find the command / usr / local / myshell directory and the / root / bin to remove:
1 | env PATH=/usr/bin;/usr/sbin;/usr/local/bin;/usr/local/shell |
<Script src = "http://w.sharethis.com/button/sharethis.js # publisher = 1ebe271a-29f6-4637-aa8c-e3066e1c4ce5 & type = wordpress & headerTitle = Share% 20This% 20Article" type = "text / javascript "> </ script>
Monitor Your Web Site 24 / 7 - Receive Email and SMS alerts Anytime your Web site goes down
Related Posts of Linux Common Position / Display command
-
hibernate call stored procedure
hibernate call stored procedure
-
hibernate using c3p0 connection pooling
Private http://www.lifevv.com/tenyo/doc/20070605102040991.html c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is v ...
-
Hibernate configuration parameters hibernate.hbm2ddl.auto
Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...
-
Build flex + spring + blazeds + hibernate application
Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...
-
Hibernate connection pool configuration
Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15
-
hibernate generic generic DAO
package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *
-
Java technology: Eclipse explain the use of techniques
Editor settings: Window -> Preferences -> Java-> Editor appearance: Display line number, emphasizing symmetry shown in square brackets, to emphasize that the existing line to show Print Margins its check, Tab width set 4, print made from the fiel
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q
-
Hibernate secondary cache
Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...
-
Hibernate's lazy strategy
hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...












