Introduction to Linux-Command Basics

Insert picture description here

Classification of Linux commands

The difference between internal commands and external commands

External instructions Internal command
Some special instructions integrated in the shell interpreter program are also called built-in instructions Script file or binary program that can complete specific functions in Linux system
Part of the shell Commands outside the shell interpreter program
There is no separate corresponding system file Each external command corresponds to a file in the system
Automatically load into memory and can be used directly The corresponding file location must be known and can be executed after being loaded by the shell

Lunux general command line format

[Parameter] Command word [Option] —— (English symbols are case sensitive)
1: [Parameter]

  • Command word processing object
  • It can be a file name, directory (path) name or user name, etc.
  • The number can be zero or more

2: Command word

  • Is the most critical part of the entire command
  • The only certain command

3: [Options]

  • Short format option: use "-" symbol to guide
  • Long format option: use'–' symbol to guide
    (multiple single character options can be used in combination)

Edit the Linux command line

1: Auxiliary operations for editing Linux command lines

  • Tab key: auto-complete
  • Backslash'': Force line break
  • Ctrl+U key combination: Clear to the beginning of the line
  • Ctrl+K key combination: empty to the end of the line
  • Ctrl+L key combination: clear screen
  • Ctrl+C key combination: cancel this command edit

2: How to get help commands

1: Internal command hellp

  • View the help information of the shell internal command
    2: The "–hellp" option of the command
  • Applicable to most Linux external commands
    3: Use the man command to read manual pages
  • Use "↑", "↓" arrow keys to scroll a line of text
  • Use Page up and Page Down keys to turn pages
  • Press Q or q to exit the reading environment
  • Press "/" to find content

View the current working directory-pwd

  • Display the user's current working directory location pwd
  • Example:
    Insert picture description here

Switch working directory -cd

  • Change the user's working directory to another location
format Description
cd target location Switch to target location
cd ~ or cd If you do not specify the target location, switch to the current user's home directory
cd - Switch to the directory where you were before the last cd command was executed

**- Absolute path-full path

  • relative path--
  • .Current path...the upper level of the current path.../...the upper level of the current path**

The manifestation of the relative path

Manifestations Description Example
Use directory or file name directly Represents a subdirectory in the current working directory. File location grub.conf
Start with a period "." Indicates to start with the current working directory ./grub.conf
Start with two periods "..." Indicates to use the upper level directory (parent directory) of the current working directory as the starting point …/vmlinuz
Start with "~Username" Indicates that the home directory of the specified user is used as the starting point ~teacher

List the contents of the directory -ls

- displays the contents of the directory, including subdirectories and files related to attribute information
ls [options] [file or directory ...]

-Common options

  • -l,-a, -A , -d, -h, -R, --color

-Combining wildcards

  • "?": Match an unknown character in the file name
  • "*": Match any number of characters in the file name

Set alias-alias

-Simplify commonly used and relatively long commands through the alias mechanism
alias command alias = command
example:
Insert picture description here

Statistics directory and file space occupation-du

-Count the disk space occupied by the specified directory (or file)
du [Options] [File or directory...]

-Common options

Options Description
-a Including all files when counting disk space usage, not just counting directories
-h Has been more user-friendly) (default count in kb, but does not display the unit) shows the statistical results
-s Only the total (Summary) size of the occupied space is counted instead of the size of each subdirectory and file

Example:
Insert picture description here

Create a new directory-mkdir

Insert picture description here

Example:

Insert picture description here

Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Common search condition types

Lookup type Keyword Description
Find by name -name Search according to the name of the target file, allowing the use of "*" and "?" wildcards
Find by file size -size Search according to the size of the target file, generally use the "+""-" sign to set more or less than the specified size as the search condition. Commonly used capacity units include kB (note that k is lowercase), MB, GB
Find by file owner -user Search based on whether the file belongs to the target user
Search by file type -tye Search according to the type of file. File types include ordinary files (f), directories (d), block device files (b), character device files (c), etc.

Insert picture description here

Guess you like

Origin blog.csdn.net/Houtieyu/article/details/107911993