Basic commands for CentOS
Common basic commands:
Type COMMAND: displays the type of the specified COMMAND.
Whatis COMMAND: View COMMAND summary and Chapter Information
Info COMMAND: online document
Hwclock-w: synchronize system time to hardware time
Hwclock-s: Synchronize hardware time to system time
Touch: file timestamp modification command
Touch-c file: Modify the timestamp. If the file does not exist, it is not created.
Touch-a file: only modify the access time
Touch-m file: only modify the modification time
Touch-m-t TIME file: Specifies the modification TIME
Stat file: view the file Timestamp
Install: You can create directories, copy files and folders like the cp command, and get more man install
Hash: View command Cache
History: displays historical commands.
-C: Clear history commands
-D offset [n]: Command to delete a specified position
-W: Save the history command to the history file [./bash_history]
Tips for using History commands:
! [N]: The Nth command in the execution history command
! -N: Execute the nth command in the History command
!! : Execute the previous command
! String: the most recent command in the History command that starts with a specified string.
! $: Reference the last parameter of the previous command
Esc,.: reference the last parameter of the previous command
File Management commands:
Cat: connect and display
-N: displays the row number.
-E: displays the row Terminator.
-A: equal to-vET
Tac: Display from the last line up
More and less: split-screen display
Head-n ROW: view the first N rows of the file
Tail-n ROW: N rows after the file is viewed
-F: Check the end Of the file. Do not exit. Wait until new content is added to this file.
Cut: format text output
-D: Specifies the field separator. The default value is space.
-F: Specifies the displayed field.
Diffuse representation:
-F: displays the first and third fields.
-F 1-3: display the first to third Fields
Sort: Text sorting
-N: sort by value
-R: sort in descending order
-T: Specifies the field separator.
-K: specify a field as a keyword for sorting.
-U: deletes duplicate rows after sorting.
-F: case-insensitive characters are ignored during sorting.
Note: Only adjacent and identical rows are duplicate rows. Otherwise, non-adjacent rows are not duplicate rows.
Uniq: Text sorting
-D: only duplicate rows are displayed.
-C: displays the number of repeated rows in the file.
Wc: Text statistics
-L: displays only the number of rows.
-W: only display the number of words
-C: only display the number of bytes
-M: only the number of characters is displayed.
-L: the maximum number of characters in a row
Tr: Convert or delete characters
Format: tr [OPTION]... SET1 [SET2]
-D: Delete All characters in the character set.
User management commands:
Useradd [options] USERNAME: create a user
-U: Specify UID
-G: Specify the GID
-G: additional group GID ,...
-C: "COMMENT"
-D: Specifies the home directory.
-S: Specifies the SHELL
-M: do not create a home directory
-R: Add a system user
Userdel [option] USERNAME: delete a user
-R: Delete the home directory at the same time.
Id [option] USERNAME: view User Account attributes
-U,-g,-G,-n
Finger USERNAME: view User Account Information
Usermod [option] USERNAME: Modify user account attributes
-U: UID
-G: GID
-A-G: GID (if the-a option is not used, the previous additional group will be overwritten)
-C: "COMMENT"
-D-m: Specify the new home directory and move all files in the old home directory to the new home directory.
-S: Modify the User SHELL
-L: Modify the user's login name
-E: Specifies the user's expiration time.
-L: locked the account
-U: Unlock the account
Passwd [USERNAME]: Password Management
-- Stdin: Read Password from standard input
-L: the user account is locked.
-U: Unlock the user account
-D: Delete the user password.
Pwck: Check User Account Integrity
Groupadd: Creates a group.
-G: Specify the GID
-R: Add a system group
Groupdel: deletes a group.
Gpasswd: Add group password
Permission management commands:
Chown: Modify the owner and group
Chown USERNAME file ,...
Chgrp GROUPNAME file ,...
Chown USERNAME: GROUPNAME file
-R: recursively modifies directories and their internal file owners and groups.
Chmod xxx: Modify file permissions
-R: recursively modify the Directory and its internal File Permissions
File search commands:
Locate:
Non-real-time, fuzzy match, search based on the entire system file database;
# Updatedb: manually generate a file database;
Find:
Real-time;
Accurate;
Supports multiple search criteria;
Traversing all files in the specified directory to complete the search is slow;
Format: find "Search Path" "Search standard" "find future processing actions"
Search Path: the current directory by default;
Search criteria: All files in the specified path by default;
Action: display to the screen by default;
Matching criteria:
-Name 'filename': exact match of file names
Wildcard File Name:
*: Any character of any length
?
[]
-Iname 'filename': the file name is case insensitive when matching.
-Regex PATTERN: Name matching based on regular expressions
-User USERNAME: search by owner
-Group GROUPNAME: search by group
-Uid UID: search by UID
-Gid GID: search by GID
-Nouser: Search for files with no owner
-Nogroup: Search for files without groups
-Type: search by file type
F: Common File
D: Directory
C: character device
B: Fast Device
L: Link file
P: MPS queue Device
S: Socket Device
-Size [+ |-]: search by file size
[+ |-] # K
[+ |-] # M
[+ |-] # G
+: Greater
-: Less
Combination conditions:
-A: corresponds
-O: or
-Not: non
-Mtime: modification time
-Ctime: Change Time
-Atime: Access time
[+ |-] #
+: At least # days have not been accessed (# days ago)
-: I have visited the website within the last # days (# Within the day)
-Perm mode
-Mode: exact match (exact match)
/Mode: any matching condition is met.
Action:
-Print: Display
-Ls: similar to ls-l
-OK COMMAND \;: the user must confirm each operation.
-Exec COMMAND \;: user confirmation not required