Text File Operations & amp; user and user group management, text file operations

Source: Internet
Author: User

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:

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.