Introduction to basic commands under Linux (v)

Source: Internet
Author: User

I. User's permissions

1. For documents:

R: Readable, you can view the contents of the file using commands like Cat

W: writable, can edit or delete this file

X: Executable, exacutable, can be submitted to the kernel at the command prompt as a command to run

2. For catalogs:

R: You can perform LS on this directory to list all internal files

W: You can create files in this directory

X: You can use the CD to switch to this directory, or you can use Ls-l to view the details of internal files, directories generally have to have execute permissions

3.RWX:

r--: Read-only

R-x: Read and Execute

---: No permissions

0---: No permissions

1 001--x: Execution

2 010-w-: Write

3 011-wx: Write and Execute

4 r--: Read-only

5 101 R-x: Read and Execute

6 rw-: Read and Write

7 111 rwx: Read and write execution


755:rwxr-xr-x

Rw-r-----: 640

660:RW-RW----

rwxrwxr-x:775

The three-bit group uses three bits to represent an octal bit, and 755 indicates that the file or directory has owner permissions of RWX, and that the user's permissions for the group R-x,other the user are R-x

4. Users and Groups:

1. When the user logs on to the computer, the system locates the record of the user name in the database, obtains the user's ID number, and then identifies a user based on the ID number. User details in the/etc/passwd file. The user's password is saved in the/etc/shadow file

2. The details of the group are in the/etc/group file. Group password in the/etc/gshadow file

Question: Groups are not logged in so why do groups need to have passwords

3. There are three types of users in Linux systems

A. Administrator uid number is always 0, user name is root cannot be changed

B. Normal user uid number 1-65535

C. The system user and the general user belong to the ordinary user under

E. Users of the system who---run the background application cannot log on to the system just to run the service UID number 1-499

F. General user--uid number from 500-65535

G. User Group Category:

Administrators group

Normal Group

System Group

General Group

H. User Group Category:

Private group: When a user is created, a group with the same name as the user name is automatically created if the group to which it belongs is not specified

Basic group: Default group for users

Additional groups, additional groups: groups other than the default group

I. Questions:

What is the security context, the permission model, and how the owner and the group are associated with the permission bit

5./ETC/PASSWD---has seven fields

1. Use Whatis passwd---to view a man document with several chapters

2. Use the man 5 passwd---to view the file format information

A. User name

B.password---password placeholder

C.uid---User's ID number

D.gid---user base Group ID

E.comment---notes in detail

f.home--User's home directory

J.shell---user's default shell

The shell inside the/etc/shells is the security shell in the system.

6./etc/shadow--has eight fields

a.account--Login Name

b.password--Password after encryption

Encrypted format:

symmetric encryption: Encrypt and decrypt using the same password

Public Key cryptography: each password appears in pairs, one for the private key (secret key) and one for the public key

One-way encryption, hash encryption: Extracting data signatures, often used for data integrity checks

1. Avalanche effect

2, fixed-length output

Md5:message Digest, 128-bit fixed-length output

Sha1:secure Hash algorithm, 160-bit fixed-length output

C. Number of days from 1970 to last modified password

d. Minimum password usage period

E. Maximum password usage period

F. Password warning time

G. Non-active time-the grace period one login will change the password or you can't use it.

H. Password Expiration Time

7.which Useradd--View the file path for the command

8. User management:

Useradd, Userdel, Usermod, passwd, Chsh, CHFN, finger, id, chage

A.useradd [Options] USERNAME

-u UID

-G GID (Basic group, group must exist beforehand)

-G GID,... (Additional group, group must exist beforehand)

-C "COMMENT"

-d/path/to/directory--Specify user home directory

-S SHELL

-m-k

-M does not create a home directory for users

-r: Add system user cannot log on to system and does not exist home directory

B.userdel---Delete a user

Do not add parameters by default does not delete home under home directory

-r: Delete User's home directory while deleting user

c.finger--retrieving user-related account information

d.usermod--modifying user account attribute information

-u UID

-G GID: Modify basic Group GID

-a-g GID: Do not use the-a option, will overwrite the previous additional group;

-C: Comment Information

-d-m: Modify home directory, have-M will be the original home directory files moved to the new home directory

-S: Specify the default shell

-L: Modify the user's login name

-L: Lock account

-U: Unlock Account

e.chsh--Modifying the user's default shell

g.chfn--Modify user comment information, display the content information for the finger command

h.passwd--Modifying user passwords

--stdin: Read password from standard

-L: Lock user

-U: Unlocking

-D: Remove user password

9. You can set the default attribute value of Useradd in the/etc/default/useradd file

10. Group Management:

Groupadd, Groupmod, Groupdel, gpasswd

A.groupadd---adding groups

-G: Specify GID

-R: Add a system Group

B.groupmod---Modifying user groups

-G: Modify the Group ID

-N: Modify Group name

C.groupdel---Delete a user group

D.GPASSWD GroupName---Add password to group

When you need to switch to another group, you need to use the group password

NEWGRP GroupName---Temporarily switch to a new group, exit with exit

11. Rights Management:

chmod, Chown, chgrp

12. In the/etc/login.defs file, you can set the information when the user adds

13.id command--View user's attribute information

-U: View UID

-G: View GID

-G: View additional group GID

-N: View Group name

14.pwck--Checking user account Integrity

15.chage--Changing the user password expiration time

-D: Last modification time

-E: Expiration time

-I: Inactive time

-M: Minimum period of use

-M: Maximum lifespan

-W: Warning time

Practice:

1, create a user Mandriva, whose ID number is 2002, the basic Group is distro (group ID 3003), the additional group is Linux;

# groupadd-u 3003 distro

# Groupadd Linux

# useradd-u 2002-g distro-g Linux

2, create a user fedora, whose full name is Fedora Community, the default shell is tcsh;

# useradd-c "Fedora Community"-s/bin/tcsh

3, the change Mandriva ID number is 4004, the basic group is Linux, the additional group is distro and fedora;

# usermod-u 4004-g linux-g Distro,fedora

4, to Fedora Plus password, and set its minimum password period of 2 days, the longest is 50 days;

# passwd-n 2-x Fedora

5. Change the default shell of Mandriva to/bin/bash;

# usermod-s/bin/bash Mandriva

6, add the system user HBase, and do not allow its login system;

# useradd-r-s/bin/nologin HBase











This article is from "Luo Chen's blog" blog, please be sure to keep this source http://luochen2015.blog.51cto.com/9772274/1634834

Introduction to basic commands under Linux (v)

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.