Type of command:
Internal command: Command that comes with the shell program
External command: itself is an independent executable program
How to distinguish internal commands from external commands: Using the "type command"
PRINTENV Display Environment variables
Hash Display cache
Help Hash
Hash-r Clearing Cached content
Logout Log out session
Whatis "Commands" To view the man chapter
External Command lookup: $PATH
The first runtime is found in $path, and the lookup results are cached
Bash Key Features
echo $HISTCONTROL History command display settings
Histcontrol can be assigned a value
Ignoredups: Ignoring duplicate commands, successive identical commands will be considered duplicates
Ignorespace: Ignore commands that start with whitespace characters
Ignoreboth: Both of these ignore
Date Command common options
+%F: Format with%y-%m-%d
+%d: Format with%m/%d/%y
+%t: Time, format with%h:%m:%s
+%y: Year
+%m: Month
+%d: Date (01-31)
+%h: Hours (00-23)
+%i: Hours (01-12)
+%m: minutes (00-59)
+%s: Seconds (00-60)
+%s: Timestamp timing, the number of seconds elapsed from the beginning of Unix (1970-01-01-00:00:00) to this moment.
+%u: Show weeks
Linux has two clocks: system clock and hardware clock
Hwclock display hardware clock
Date display system clock
Hwclock-s the hardware clock is the standard
-W with system clock
Which display the full path of the command
which--skip-alias ls skip command alias
Stat Display file meta data
Stat/root/.bash_history
Changes in file content influence Modify-time Mtime
File meta-data changes affect Change-time CTime
Touch Changes Atime and Mtime
Touch-a Change only Atime
-M only changes Mtime
Cat command: Connect and display file contents
Cat/etc/{issue,fstab}
CAT-E Display newline characters
Text file: Is data stream (stream)
Echo-n does not end with a newline character
Echo-e echo-e ' Hello \ n World ' makes escape character
\ t \ n Common
Display color \033[single digit: controls the font itself
3#: #是一个数字, 3 means control foreground color
4#: #是一个数字, 4 for controlling background color
Combined use
Echo-e ' \033[33mhello\033[0m '
M: Fixed format
\033[0m: The control function ends, and if there is no control flag, the CAP font does not revert to color.
Cp-p preserving file meta data
Sort:-F ignores character case
-T Specify delimiter
-k Specifies the sort field
-N Sort by numeric value
-U Go Heavy
Uniq: Go to the heavy command
-D Show only duplicate rows
-U displays only non-repeating rows
-C shows the number of repetitions per line
Bash features input, output rewrite direction, and piping
Set-c Turn off the overwrite function of output redirection
>|: Overwrite operation is still performed when output redirection override is turned off
&>: Correct, error output to the same file
<: Input redirection
<<:here Document
Cat <<end: End after input end
Cat >>/tmp/myfile <<eof
/etc/shells Directory
Users cannot log on to the system if the user is using a default shell that is not in this directory
md5sum file name
MD5: fixed length output 128bits
Sha512sum file name
SHA1: fixed length output 160bits
Encrypt password
OpenSSL passwd-1-salt 12345678
User Management
/etc/shadow format
User name: encrypted password: Last password change time (days): Minimum password Age: Password maximum age: Password Expiration warning interval: Inactivity period: Account expiration: Reserved area
Usermod-g modify additional groups by appending it with the "-a" option
Usermod-d modifies the location of the home directory with the "-m" option to ensure that the home directory is created and that the user's original files are moved to the new home directory.
USERMOD-L User name: Modify user Name
Chsh USERNAME Change Shell
CHFN USERNAME Change Annotation information
Id:
ID-G user1 display Group ID
ID-GN User1 Display Group name
Id-u user1 display User ID
Determine if a user exists
ID User1 &>/dev/null
echo $?
Su:switch User
Su-l = Su-
Su-c ' COMMAND '
Temporarily switch basic groups
Log on to the user who wants to switch groups, NEWGREP group name
Bash's configuration file
Global configuration
/etc/profile,/etc/profile.d/*.sh,/etc/bashrc
Personal configuration
~/.bash_profile,~/.bashrc
File for Profile class:
Setting environment variables
Run a command or script
BASHRC class file
Setting Local Variables
Defining command aliases
How the login shell reads the configuration file
/etc/profiel-/etc/profiel.d/*.sh-~/.bash_profile-~/.bashrc-/etc/bashrc
Non-sign-on shell
~/.bashrc-/etc/bashrc-/etc/profile.d/*.sh
Linux Common commands