Linux-Basic Instructions

Create ordinary users

Command to
create a user name: useradd user
name Set a password for the created user name: passwd user name
  If the above two steps are executed successfully, you can enter the password you want to set, then enter the password and see that the cursor does not move. Press Enter to end, enter again to confirm the password, and press Enter to end.

ls command

Command: ls
Function: List all files in the current folder.
Insert picture description here
  Because there is only one work file in the current directory, only one is displayed here.

Command: ls -a
Function: List all files in the current folder, including hidden files
Insert picture description here
  . The difference between hidden files and visible files is that hidden files start with a dot. Here, -a is a command line parameter, and -a is passed to the ls command as a parameter.

Command: ls -l
Function: Display the detailed information of all files in the current folder.
Insert picture description here
Abbreviation: ll
Insert picture description here

  Under the linux operating system, files are not distinguished by suffixes, but are the same as the first letter in the file information. For example, the first letter of this file is d.
Insert picture description here
  D means dir (folder). For example, the first letter may be -Wait,-means that this file is a normal file.
  Under the window operating system, the suffix is ​​used to distinguish file types.
eg:
  exe: executable file
  txt: text file
  obj: 3D model file
  dll: dynamic link library file
  lib: static library

Command: ls -al
function: display the detailed information of all files in the current directory (including hidden files)
Insert picture description here
command: ls -lrt
function: sort the files in reverse order according to the modification time of the files in the current directory where
  r stands for reverse order, here t stands for time.
Insert picture description here
  Because I only have one file here, it is not very obvious.

pwd command

Function: You can view the current path
Insert picture description here

/ Root directory

Command: /home/lixin
function: the'/' in front of home is the top-level directory of the Linux operating system, all files or folders are expanded under the root directory, because my username is lixin, so this directory Also known as the home directory of lixin users.
  User home directory: the initial directory where the current user is located after logging in to the Linux operating system. Among them, the administrator user root is a special case. His directory is under /root. This is the add directory table for the root user. The user home directories of the remaining users are all in home.

Command: ls /
function: display the top-level directory
Insert picture description here
  , there is an etc file in it, and all Linux device files are stored in it

cd command

Command: cd Path
function: switch directory
  where c means change, d means dir
Insert picture description here
  so that I can switch from the user's home directory to the root directory, the front of the user's home directory is ~, and the front of the root directory is /.
Insert picture description here
  This way I can switch back to the user's home directory from the new directory.
  Since both the user's home directory and the root directory have special symbols, there are the following shortcuts :
cd / directly to the root directory
Insert picture description here
cd ~ directly to the user's home directory
Insert picture description here
cd… back to the parent directory
Insert picture description here
cd-back to the previous directory
Insert picture description here

Tab

  If you can’t write a word or need to complete it, you can press the tab key to complete the command.

mkdir

Command: mkdir folder name (folder name)
Function: create a folder
Insert picture description here

touch

Command: touch Common file name (file name)
function: create a common file
Insert picture description here
  touch supports the creation of multiple files at once. Although the file suffix is ​​not different under the linux operating system, it is different for the software. The .c file is For c language, .cpp, .cc, and .hpp are all c++ files.

rm

Command: rm file name
function: delete files
Insert picture description here
  rm supports deleting multiple files at once

Command: rm -r folder name
function: delete the folder and the files
Insert picture description here
  in it. I have a test folder in the user's home directory of lixin, and I have two files ac and b in the test folder. Return to the user's home directory, delete the test file successfully, display the files in the user's home directory, and test has been deleted. The specific deletion method is as follows:
Insert picture description here
  If you want to delete the test folder, first the system will enter the test folder to see if there are any files in it. If the ac file is found, delete the a and c files first, and then find the b file until the test After deleting all files in the folder, return to the directory where the test folder is located, and delete the test file.
Command: rm -ri Folder name
function: Delete the folder and its files, but you will be asked
  -i is a command line parameter that prompts you to delete step by step (not commonly used, too troublesome)
Insert picture description here
Command: rm- rf/
Function: Forced deletion from the root directory
  -f is for forced deletion. Ask for command line parameters.
Note : You must be careful when deleting files. Deleted files cannot be retrieved.

Guess you like

Origin blog.csdn.net/weixin_43580319/article/details/112910012