Get the App
SLTechnology News&Howtos  ›  Network Security  › 

User and file rights management

Shulou Source: shulou.com Published: 2022-06-01 02:56:32 09月27日 Update

Experimental environment:

The Linux host of the company will be provided to the Technology Department for use as a development server. According to the composition of project groups in the department, it is necessary to establish corresponding group accounts and user accounts, and set permissions for relevant directories; it is also necessary to set up a common data storage directory to facilitate data exchange among colleagues.

Requirement Description:

1. Create a user directory.

Create directories/tech/benet and/tech/accp to host user accounts for each project group. For example, the hosting directory for kylin users should be located at/tech/benet/kylin.

Mkdir -p /tech/benet

Mkdir -p /tech/accp

Second, add a group account.

(1) Add group accounts benet and accp for two project groups, and set GID numbers to 1001 and 1002 respectively.

Groupadd benet -g 1001

Groupadd accp -g 1002

Tail -2 /etc/group

(2) Add a group account tech for the technology department, and set the GID number to 200.

Groupadd tech -g 200

Tail -3 /etc/group

Third, add user accounts.

(1) Benet group consists of three users, namely kylin, tsengia, obama. The host directory uses the folder with the same name as the account in/tech/benet/directory. Kylin user accounts were set to expire after March 15, 2013.

Useradd -d /tech/benet /kylin -g benet -G tech -e 2013-3-15 -s /sbin/nologin kylin

Useradd -d /tech/benet/tsengia -g benet -G tech tsengia

Useradd -d /tech/benet/obama -g benet -G tech obama

Tail -3 /etc/passwd

(2) Accp group includes two users, handy and cucci, and the host directory uses the folder with the same name as the account in the/tech/accp/directory. The login shell for cucci users is set to/bin/ksh.

Useradd -d /tech/accp/handy -g accp -G tech handy

Useradd -d /tech/accp/cucci -g accp -G tech -s /bin/ksh cucci

Tail -5 /etc/passwd

All of the above user accounts are required to join the tech group.

In the test phase, only the initial password "123456" is set for kylin, tsengia and handy, and other users do not set passwords temporarily.

Passwd kylin

Passwd tsengia

Passwd handy

1. Set directory permissions and ownership.

(1) Set the group of/tech directory to tech, removing all permissions of other users.

Chown :tech /tech

Ls -l /(View permissions, show 755)

Chmod 750 /tech

(2) Set the group of/tech/benet directory to benet, removing all permissions of other users.

Chown :benet /tech/benet

Chmod 750 /tech/benet

Ls -l /tech

(3) Set the group of/tech/accp directory to accp, removing all permissions of other users.

Chown :accp /tech/accp

Chmod 750 /tech/accp

Ls -l /tech

2. Establish a public data storage directory.

Create a/public directory that allows all users within the tech group to read, write, and execute files, and prohibits access to this directory by users outside the tech group.

Mkdir /public

Chown :tech /public

Chmod 070(770) /public

Tags: User directory account permission file host technology data folder project project team three two password technical department not for storage host between company Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia vpn MySQL macOS