Operations on text files & user and user group management, and operations on text files
Text File Operations
#Input redirection
Tr 'a-Z'
Hello
HELLO
World
WORLD
After redirection
Tr 'a-Z' <file
HELLO WORLD
#Format the input content to a file:
#Standard input, standard output, and standard errors
Standard input 0 (read only on keyboard), standard output 1, and standard error 2 (write only on display)
For example, the passwd file contains standard output 1 and standard error 2.
Only display standard error 2 to display, standard output 1 Write passwd. OK
Only display standard output 1 to the display, standard error 2 Write passwd. err
View the written files passwd. OK and passwd. err.
The standard output 1 and standard error 2 are both written to passwd. OK (Note: directly write ">", append to the original file and add "> ")
#Pipeline "|"
Meaning: The correct output of the previous command is used as the standard input of the command after the pipeline operator;
Here, only two entries are entered correctly.
Convert a standard error to a standard output: "2> & 1"
# Tee
Saving the output as a file does not affect the display of the display (Example 3 ))
#Exercise:
1 ).
2) display line 15-18 of the/etc/passwd file;
3). The display/Bind file contains a large master file and saved to the bin_upper_file.txt file,
The statistics are displayed on the screen;
User and User Group Management
#User Management
User File:/etc/passwd
User: passwd: uid: gid: user Description: user's home directory: shell Type
Command: useradd usermod id (userdel-r username)
#User Group Management
User group file:/etc/group
Groupname: passwd: gid: group member
Command: groupadd (-g) groupmod groupdel
#Manage user passwords
User Group file:/etc/shadow
Command: passwd chage
#Grant sudo permissions to users
Use sudo useradd hello
#Exercise:
The creation result is as follows:
Passwd and chage commands can be used for modification.
The result is as follows: