1. Virtual machine Linux Installation and considerations
- Modify boot in BIOS before Linux installation, choose which disk to read system code to boot
- Partition
- mount point boot file system type EXT4 size 500MB
- File system type Swap (virtual memory) size (typically 1.5~2 times for physical memory, but not more than 8G)
- mount point/(root partition) file system type Ext4
Some important directories in the 2.Linux system
- Bin directory: Store frequently used executable files
- Sbin Directory: The executable file that holds the system
- Home directory: Store the user's own files or directories, the root user's home directory is/root, the normal user's home directory in the/home directory, such as the Tom User's family directory is/home/tom
- Dev directory: Device files directory
- ETC Directory: Configuration file directory
- MNT, OPT, media, TMP directory, generally can be used casually
3. Terminal, user, time, help and other related commands
- Switch virtual terminal: ctrl+alt+f[1~6]
- To open a new terminal: Ctrl+shift+n
- Shutdown: Init 0
- System prompt after a normal user logs on: $
- System prompt after the root user logs on: #
- Exit Current User: Exit
- Create User: Useradd user name
- Useradd-u: Specify UID for user
- USERADD-G: Specify the group to which the user belongs
- useradd-d: Specify the user's home directory
- USERADD-C: Specify user's Notes information
- Useradd-s: Specifies the shell used by the user
- Delete User: Userdel-r user name
- View user information: ID user name
- To modify user information:
- Usermod-u: Modifying the UID of a user
- USERMOD-G: Modifying the user's GID
- USERMOD-G: Adds a user to the specified group, usermod-g the group name user name. Add the specified group to the user's sub-group, and if you use the command consecutively, the sub-group will overwrite
- Usermod-ag: Appends a user to the specified group, without overwriting the last joined sub-group
- Usermod-d: Modifies the user's home directory. Actually modifies the contents of the passwd file, but does not create the modified directory under Home, so you must also manually modify the file
- Usermod-c: Modify user's Notes information
- Usermod-s: Modifying the shell used by the user
- Lock User: Usermod-l user name
- Unlock User: Usermod-u user name
- Set Password: passwd set root password, passwd user name settings specify user password
- Switch User: Su-user name
- View current logged in User: WhoAmI
- View all users currently logged on to the system: WHO
- View Date: Date
- Date Modified: Date ' month/day of year '
- View Calendar: Cal
- View calendar for a specified month: Cal month Year
- Sync Hardware time: hwclock-s
- Synchronization system Time: Hwclock-w
- Clear screen: ctrl+l or clear
- Terminate current command: CTRL + C
- View command Help information
- Man command, Q quit Help manual
- Command--Help
- Completion command: Tab key
4. Directory Switching and browsing
- Linux command Syntax Format: command "Options" "Parameters"
- Show current directory: PWD
- Go back to the top level directory: CD.
- To the current user's home directory: CD or cd~
- Return to the previous directory: cd-
- Browse directories and files under directory: LS
- Browse the contents of the directory containing hidden files: ls-a
- Browse the current directory for more information: Ls-l or LL
- Browse directories that contain hidden files for more information: Ls-al or Ls-all
5. Create, alias, copy, move, delete
- Create directory: mkdir/directory, e.g. Mkdir/opt/b
- Recursively create a tree structure catalog: mkdir-p/directory 1/Directory 2/directory 3, e.g. Mkdir-p/OPT/DIR1/DIR2/DIR3
- Create file: Touch file name, such as Touch a.txt
- Touch/test/{1..9}.txt Create 1.txt, 2.txt ..., 9.txt in the test directory
- Touch/test/{a. Z}.txt Create 26 English-letter txt in the test directory
- Create file under specified directory: Touch/Specify Directory/file name, e.g. Touch/dir1/dir2/a.txt
- View command aliases/aliases: alias command/alias character = ' command '
- Copy file: CP Source path destination path, e.g. cp/opt/a.txt/opt/test/
- Copy file and rename: CP Source path target path new name, for example Cp/opt/a.txt/opt/test/new.txt
- Before the copy overwrite asks: Cp-i, because the CP is the system to cp-i the alias, therefore uses the CP directly, will ask before overwriting. But CP native command location/BIN/CP, using native command will not prompt.
- Recursive replication: cp-r, copy directory and directory files
- Move files or directories: MV Source path Destination Path
- Modify file or directory name: MV Original name New name
- Delete File: RM
- Deleting a file does not use the system hint: rm-f
- Recursive Delete directory: Rm-r
- Deleting any content is not a system hint: RM-RF
6. Write and view the contents of the file
- Write file: Echo ' content ' >> file path
- View File Contents
- Cat:cat file path
- Head: Default Displays the first 10 lines of the file, head-n specifies the first n rows of the file to display
- Tail: Default display of the file after 10 lines of content, tail-n specify the display of the file after n rows of content
- Tail-f: Dynamically viewing changes to the contents of a file
- More: View the contents of a file and display it as a percentage, press the ENTER key to page
- Less: Use the up and down keys to page to view, press the Q key to exit view
Basic use of the 7.vim editor
- Press the A or I key to enter insert mode to modify the file, press ESC to exit the edit
- Press shift+:, enter W save, Q Exit, Wq Save exit, wq! Force save exit
Linux Common commands