linux common terminal command (a) a terminal command format (ii) common command files and directories

A, linux terminal command format

1, a terminal command format

command  [-options]  [parameter]

Description:

    • the Command : command name, abbreviation English word or words corresponding function
    • [-options] : option can be used to control the command can be omitted
    • [Parameter]  : The parameters passed to the command, may be zero, one, or more

[] On behalf of optional

2, access command help information

command --help     display command help command

man command    Read command manual command

Second, the files and directories frequently used commands

  • View directory contents

          ls

  • Change directory

          cd

  • Create and delete operations

          touch

          rm

          mkdir

  • Copy and move files

          cp

          mv

  • View the file contents

          cat

          more

          grep

  • other

          echo

          Redirect > and >>

          Pipeline   | 

 

Terminal practical tips

Zoom window terminal

    • ctrl + shift + =          enlarged font display terminal window
    • ctrl + -         reduced font display terminal window

Autocomplete

    • In the input  file / directory / command  during the first few letters, press the tab key,
      • If the input is not ambiguity, the system will auto-complete.
      • If there are other file / directory / command , then click the tab key, the system will prompt commands that may be present and so on.

It has been used command

    • Press Up / Down key to switch between commands have been used
    • If you want to opt-out, and do not want to execute the currently selected command, press ctrl + c

1, view directory contents

1.1, ls command Description

  •  ls is the English abbreviation list, function list the contents of a directory. Quasi DOS's dir .

Features under linux files and directories

    • File and directory names up to 256  characters.
    • To Documents for the beginning of the hidden files, you need to use -a display parameters to
    •  . Represents the current directory
    •  .. on behalf of parent directory

Common options

parameter meaning
-a All subdirectories and files in the directory display, including hidden files
-l Show details of the file as a list
-h -L displays the file size with the humane way

 

 

 

 

 Use wildcards

Tsuhaifu meaning
* It represents any number of characters
? Represent any one character, at least one
[] It represents a set of characters match any of
[abc] Matching a, b, c of any one of
[a-f] Match any one character to within a range of f

 

 

 

 

 

 

2, change directory

2.1、cd

  • cd function is to change the current working directory

All linux directory and file names are case sensitive

command meaning
cd [directory] Change the current working directory
cd Switch to the current user's home directory (/ home / user directory)
cd ~ Switch to the current user's home directory (/ home / user directory)
cd . Remains unchanged in the current directory
cd .. Return to the parent directory
cd - Switch between the two most recent catalog of work

 

 

 

 

 

 

Relative and absolute paths

    • Relative path in the input path, not the front or represents the relative current directory the directory location of
    • Absolute path in the input path, is the front or to indicate from the root directory / home directory specific directory starting position

3, create, and delete operations

3.1、touch

  • Create a file or modify file time
    • If the file does not exist , you can create a blank file
    • If the file exists the last modification time, modify file

3.2、mkdir

  • Create a new directory
Options meaning
-p Create directories recursively

 

 

3.3、rm

  • To delete a file or directory

Rm command can not be recovered after deletion

Options meaning
-f Force delete, ignore the file does not exist, without prompting
-r Contents of directories recursively delete, when you delete a folder must be added to this parameter

 

 

 

4, copying and moving files

No. command English correspondence effect
01 tree [directory name] tree A tree chart lists the file directory structure, ubuntu is not installed by default
02 cp source file destination copy Copy the file or directory
03 mv source file destination move Moving a file or directory / file or directory rename

 

 

 

 

4.1、tree

  • tree can list the files in the directory structure in a tree diagram
Options meaning
-d Display only a directory

 

 

4.2、cp

  • cp specified file or directory to another file or directory
Options meaning
-i Prompt before overwriting files
-r If the given file is a directory file, cp will copy recursively all directories and files in the directory, the target file must be a directory name.
It will be directly overwritten without prompt.

 

 

 

 

4.3、mv

  •  mv may be used to move a file or directory can be re-used for a file or directory command
  • It will directly overwrite the file
Options meaning
-i When prompted to overwrite files

 

 

 

5, view the file contents

No. command English correspondence effect
01 cat filename concatenate View the contents of the file, create a file, merge file, additional features such as file content
02 more filename more Split-screen display file contents
03 grep search text file name grep Search the contents of a text file

 

 

 

 

5.1、cat

  • cat can be used to view the contents of the file , create a file , merge files , additional file contents and other functions
  • a cat will display all the contents of the file
Options meaning
-b Non-blank line output line number
-n Output line number for all lines

 

 

 

There is also a linux nl command and cat -b command the same effect

5.2、more

  • More split-screen display file contents, the contents of each page is displayed

Using more operation keys:

Operation keys Features
space bar Scroll down a screen
Enter Scroll down one line
ctrl + b Scroll down a screen
ctrl + f Scroll up a screen
q drop out
/word Search word character

 

 

 

 

 

 

5.3、grep

  • grep command is used to find files that match the criteria string
  • grep allows text files to look for patterns, so-called modes, namely a regular expression.
Options meaning
-n Line number
-v Show all lines mismatch (corresponding inversion)
-i Ignore case

 

 

 

 

Two commonly used mode

parameter meaning
^a Beginning of the line, the search begins with a line
The $ End of the line, the search ends with the line ke

 

 

 

 

6, other

6.1、echo

  • echo parameter specifies the text displayed in the terminal, usually in combination with redirection

6.2 redirect> and >>

  • linux allow command execution result redirected to a file
  • Original content displayed on the terminal output / append to the specified file

among them

  •     Represents the output, if the file exists, it will overwrite the original contents of the file. Does not exist, create a file
  • >>     represents an additional, if the file exists, the contents will be appended to the end of an existing file. Does not exist, create a file

6.3, the pipeline |

linux allows output of a command may be through the pipeline as another command input

Commonly used for piping commands are:

More : split-screen display content

grep : command to query the specified text on the basis of the results of the query

Guess you like

Origin www.cnblogs.com/linz1230/p/11550706.html