preface

The purpose of this article is to record the situation encountered in the study and work, if there is anything wrong please correct ~~

Command line form

  • imperative
    • % command [Parameter 1 Parameter 2…
    • output
  • interactive
    • % command
    • < User input >
    • [Output]

Command authority

#

The root permission is the administrator permission of the current user

$

Common user rights.

To switch to root for a common user, perform the following operations:

su root
Copy the code

The following occurs when a common user switches to root

su: Authentication failure
Copy the code

The possible causes are as follows:

  • The root password may be incorrect. Check whether the password is incorrect

  • The root user password is not set, so you can try to set the password

sudo passwd
Copy the code

digression

If you change files such as /etc/profile, or ~/.bashrc, you can replace them with any symbol.

In Linux, the identifier before entering a command is root@locate~

  • ~Represents the user’s home directory
  • The root is/root
  • Generally, the user is /home/username
  • . /.Represents the current directory
  • ../Represents the parent directory

Command line classification

Common foundation

echo

Return what you type, shorthand “talking to yourself”.

A string is output when a string of characters is entered, and a variable value is output when a system variable is entered

$ echo Jylie
Jylie

$ echo $HOME
/c/Users/Administrator
Copy the code

pwd

Print Working Directort. Shorthand: Where am I?

$ echo $HOME
/c/Users/Administrator
Copy the code

cd

Change Directory, short for Change Directory. Shorthand: Somewhere else.

$ cd.Return to the previous layer
$ cd ../path
Copy the code

ls

Displays documents and Directory information in the current Directory, short for List Directory Content.

$ ls
$ ls -l # list mode
$ ls -l -a  # is equal to ls minus la. list + all files
$ ls -lh # list + human readable size
Copy the code

Ask for help

man

User manual. Manual for

$ man pwd
$ man man
Copy the code

-h

Built-in help command

$ man -h
$ grep --help
Copy the code

The file content

cat

Print file contents, short for Concatenate and Print Files.

$ cat file.txt
$ cat < useruid.ini.bac
[General]
useruid=3c291a336132451791d146d625355387

Copy the code

The head and tail

View the contents of the beginning/end of the file

The built-in command

  • If not, the entire content is displayed
  • -q Hides the file name
  • -v Displays the file name
  • -c< Number > Number of bytes to display.
  • -n< number of rows > Number of rows to be displayed.
$ tail useruid.ini Display all contents without passing the parameter
[General]
useruid=3c291a336132451791d146d625355387

$ tail -n 1 useruid.ini # count 1 line of content from the end of the text
useruid=3c291a336132451791d146d625355387

$ head -n 1 useruid.ini Display 1 line of content counting from the beginning
[General]

Copy the code

less

You can browse files at will, support page turning and search, support page up and page down.

$ history | less View the command history and display it through less pagination

$ ps -ef |less # ps Displays process information via less pagination

$ less log2021.log log2022.log # Browse multiple files
# description:
Enter n and switch to log2014.log
Enter: p and switch to log2013.log
Copy the code

more

The Linux more command is similar to cat, but will be displayed as a page by page, which is more convenient for users to read page by page. The most basic command is to press the space key to display the next page, press the B key to display the back page, and also has the function of searching strings (similar to vi). For instructions in use, please press H.

$ more +20 testfile Display the document contents of testFile starting at line 20
Copy the code

wc

Short for Word line and Byte Count

# Find a single file
$ wc useruid.ini The # useruid.ini file has 2 lines, 2 words, 53 bytes
 2  2 53 useruid.ini

Use channel statistics
$ cat useruid.ini | wc
      2       2      53

# find multiple files
$ wc nuuid.ini ntuser.ini
 2  2 45 nuuid.ini
 2  0 20 ntuser.ini
 4  2 65 total

Copy the code

To be continued


Document links

  • Original official number link – left pen