One linux Command every day, and one linux Command

Source: Internet
Author: User
Tags call shell

One linux Command every day, and one linux Command

2014-08-19

Redirection symbol greater than sign: redirects a command execution result (standard output, or error output, which is originally printed on the screen) to other output devices (files, open file operators, or a printer) Example: 1.ls> B .txt: Write the result of lsss to B .txt file (if any, the contents of B .txt are overwritten) 2.ls> B .txt: add the result of lsls to the end of B .txt file (if no B .txt file is created) 3. mysqldump-u root-p test> 20101216_test. SQL returns less data than the code: the input obtained by the command from the keyboard by default is changed to the input from the file, or other open files and device input instances: 1. mysql-u root-p-h test <20101216_test. SQL import data

2014-08-18

Pipeline: the Pipeline character "|" provided by Linux separates the two commands, and passes the command execution result on the left to the command on the right through the pipeline and then executes the instance: ls-al | grep java this command means to first execute ls-al to list all the current files or directories, then, use the pipeline "|" to forward it to grep to query whether the directory or file containing java is commonly used: 1. ps aux | grep java 2. tail-100f log.txt | grep log

2014-08-17

Locate: find filenames quickly. The locate speed is faster than find. It is not a real search, but a database. Generally, the file database is in/var/lib/slocate. db, so the locate search is not real-time, but is based on the database updates commonly used parameters: 1. -e will be excluded from the search range. -1 if it is 1. The security mode is enabled. In security mode, users do not see files that cannot be viewed by permissions. This slows down because the locate must obtain the permission information for the file in the actual file system. -F exclude a specific file system. For example, we have no reason to put the files in the proc file system in the database. -Q quiet mode. No error message is displayed. -N: displays up to n outputs. -R uses the regular formula for search conditions. -O specifies the data inventory name. -D specifies the path of the database-h displays the auxiliary message-V displays the version information of the program instance: 1. locate pwd to find all pwd-related files. search all files starting with sh in the etc directory by locate/etc/sh. locate-r/etc/sh $ search for all files ending with sh in the etc directory

2014-08-16

Less: the opposite of more (opposite of more)-B <buffer size> sets the buffer size.-e when the file display ends, automatically exit-f to force the opening of special files, for example, the peripheral device code, directory, and binary file-g only mark the last search keyword-I ignore the case when the search-m shows the percentage similar to the more command-N shows the row number-o <File Name> Save less output content in the specified file-Q does not use warning sound-s to display consecutive null behavior a row-S will discard the excess part for a long time-x <number> display the "tab" key as a specified number space/string: search down the "string" function? String: the function of searching "string" up n: Repeat the previous search (and/or? Related) N: Repeat the previous search (and/or? () B flip one page backward d flip half page h display help interface Q exit less command u scroll forward half page y scroll forward one line space key scroll one line enter key scroll one page [pagedown]: scroll down a page [pageup]: Scroll up a page

2014-08-15

More: more will display one page at a time to help users read the command parameters page by page (file perusal filter for crt viewing: + n: Display from rows 'N'-n defines the screen size as n rows +/pattern: search for the string (pattern) before each file is displayed ), then, from the first two lines of the string, the-c is displayed on the top of the screen, and the-d prompt is displayed, "Press space to continue, 'q' to quit (Press the space key to continue, press the q key to exit) ", disable the bell function-l ignore the Ctrl + l (for page feed) character-p by clearing the window rather than scrolling the screen to swap the file, similar to the-c option,-s displays multiple consecutive blank lines as one line.-u removes the offline lines in the file content. 4. common Operation Command: Enter n rows down, which needs to be defined. The default value is 1 line Ctrl + F scroll down one screen space key scroll down one screen Ctrl + B Return the previous screen = output the row number of the current line: f. The output file name and the row number V call the vi editor! Command to call Shell, and execute command q to exit more

2014-08-14

Which command to view the location of the executable file (locate a program file in the user's path) which command will search for the location of a system command in the PATH specified by the path variable, the first search result is returned. Instance: which java

2014-08-13

Nl automatically adds the number lines of files-B a: indicates that the line number (similar to cat-n) is also listed no matter whether it is empty or not ); -B t: if there are blank rows, do not list the row number (default) for the empty row;-n ln: the row number is displayed on the leftmost side of the screen;-n rn: the row number is displayed on the rightmost side of its own column without adding 0;-n rz: the rightmost side of the row number in its own column is displayed with 0;-w: the number of digits used by the row number column. Instance: 1. nl-B a file1 output content and list row number 2. nl-B a-n rz file1 to list the row number and add 0 3 to the row number. nl-B a-n rz-w 3 file1 keep the listed row number three digits

2014-08-12

Tail: the command writes the file to the standard output (display the last part of a file) from a specified point. Common parameters:-f loop read-n <number of rows> Number of lines displayed-s, -- sleep-interval = S and-f are used together, indicating that the instance is sleeping for S seconds at each repeated interval 1. tail-n 10 file1 displays the content at the end of 10 rows 2. tail-100f file1 dynamically displays the 100 rows at the end 3. tail-100f file1 | grep java Dynamic Display of the last 100 lines containing java content

2014-08-11

Cat: Connection files or standard input and print (concatenate files and print on the standard output) common parameters:-A, -- show-all is equivalent to-vET-B, -- number-nonblank: numbers of non-Null Output rows-e is equivalent to-vE-E. -- show-ends displays $-n at the end of each row, -- number indicates the number of all rows in the output, starting from 1 to the number of rows in the output-s, -- squeeze-blank has a blank row with more than two rows in a row, replace the blank line-t with-vT equivalent-T, -- show-tabs will show the hop character as ^ I-v, -- show-nonprinting uses ^ and M-reference, except for LFD and TAB. cat file shows the entire file content 2. cat file1 file2> merge file to file 3. tac file displays the file content in reverse mode

2014-08-10

Cp: copy files 1. cp file1 file2 copy file file1 to file file2 2. when cp-I file1 file2 copies file file1 to file file2, you need to ask whether to copy file 3. cp-f file1 file2 forcibly copies file file1 to file2 4. cp dir1 dir2 copies the directory dir1 to dir2 5. cp file1 file2 file3 dir copy multiple files to the dir directory

2014-08-09

Mv: move files 1. mv file1 file2 rename file1 to file2. mv file dir: Move the file to the directory dir. 3. mv-I file1 file2 rename the file file1 to file2. If file2 already exists, ask if it overwrites 4. mv-f file1 file2 rename the file file1 to file2. Even if file2 exists, it overwrites 5 directly. mv dir1 dir2 if the directory dir2 does not exist, change the directory dir1 to dir2; otherwise, move dir1 to dir2 6. mv file1 file2 file3 dir1 move multiple files to the dir1 directory

2014-08-08

Rm: remove directory entries-f, -- force Delete. Ignore non-existing files and do not Prompt confirmation-I need to confirm before deleting-r,-R, -- recursive recursively Delete directory and its content-v, -- verbose detailed display steps (pay attention to using rm with caution, you can customize the recycle bin function if you are afraid of accidental deletion) custom recycling steps: 1. myrm () {D =/tmp/$ (date + % Y % m % d % H % M % S); mkdir-p $ D; mv "$ @" $ D & echo "moved to $ D OK";} 2. alias rm = 'myrm'

2014-08-07

Mkdir: create a directory (make directories) 1) mkdir-m 777 test-m, -- mode = mode, set the permission <mode> (similar to chmod) 2) mkdir-vp src/{lib/, java/}-p, -- parents can create multi-level directories-v, -- verbose displays information each time a new directory is created

2014-08-06

One linux Command pwd every day: when the current directory (Print the name of the current working directory) pwd-P shows the actual path pwd-L directory connection link, output connection path (pwd is pwd-L by default) $ variables in the current PWD Directory, which can be Output Using echo $ PWD. The results are the same as those in the directory on $ OLDPWD.

2014-08-05

Cd [directory name]: Switch the current directory to dirName (Change the current directory to DIR. cd/enter the system root directory 2. cd .. return to the upper-level directory 3. cd ~ Or cd's current user home directory (note: "current user home directory" and "system root directory" are two different concepts) 4. cd-Return to the directory where the directory is located 5. cd! $ Run linux cd! $ Use the last parameter of the previous command as the input

2014-08-04

Ls: list all subdirectories and files in the target directory (list directory contents) common combination parameter 1) ls-al-a,-all list all files in the directory, including. implicit file-l lists the permissions, owner, file size, and other information of the file in detail. 2) the ls u * star is a regular expression matching. (3) ls-F lists all files and directories in the current working directory. Add "/" after the name "/", add "*" after the executable file name "*"

Linux commands

Step by step,
First, ls-lR/etc/shows all the files (-l) in the/etc/folder in detail and recursively displays the contents (-R) in the subfolders)
Second, the channel | indicates that the standard output (stdout) of the previous command (screen output, standard input on the keyboard) is used as the input of the subsequent command.
Thirdly, tee reads data from the standard input device, outputs its content to the standard output device, and saves it as a file. For example, if ls-lR/etc/| tee stagel. out is used, the ls content is output to the screen and saved as stage1.
Then, | sort | tee stage2.out, sort sorting command, because tee stage1.out outputs the result to the screen, then enters the result to sort through the channel, and then inputs the result to tee, output the result to the screen and save it as the file stage2.ou
Then, sort-r | tee stage3.out, which is similar to the previous one, but it is in descending order.
Then, | uniq-c | tee stage4.out, uniq-c, duplicate rows are displayed only once, and the number of repetitions is marked.
Finally,> stage5.out is critical. As I mentioned earlier, tee will be output to the screen, but when you run this command, you will find that there is no screen output, and the problem is here.> it is a redirection symbol, to redirect the standard output to stage5.out
Hope to help you

How are linux commands managed?

In linux, system-level environment variables and user variables both have variables named PATH (in fact, in windows). This variable records what others call PATH.

In linux, the command rules are usually bash, so we don't need to mention space segmentation. man can understand the syntax at a glance.

Where can I find the command entered in linux terminal? How do I determine whether a command exists? His working mechanism is like this.
A command. By default, linux searches for three locations in order:

1. It is alias, or an alias. For more information, see alias-l. Here we can see that our common ll is not actually a system command.
Instead, we define ll = ls-l -- color. Similarly, we can also define other commands, such as ifconfig = rm-rf/(this is a waste, so don't try it)

2. Go to the PATH of the PATH variable record.

3. Find the current directory.

Make sure the order is correct.

For example. We alias a command for ifconfig = rm-rf/, then we re-enter terminal to knock the command for ifconfig.

Then, the system action is not to call the path/bin/ifconfig, but to find the ifconfig record in alias and directly execute rm-rf/

Bash's TAB completion is a BASH function, and ksh and csh are not available. Its completion is also matched by the command you typed above.

You don't know. If you have any questions, you can send me a message from Baidu Hi or Baidu.

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.