Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of LINUX user and disk management

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "LINUX user and disk management method is what", the explanation content in the article is simple and clear, easy to learn and understand, please follow the small series of ideas slowly in-depth, together to study and learn "LINUX user and disk management method is what" it!

I. User Account Management 1.1 Add User Account (useradd)

Command: useradd [-option] [username]

Options:

-u: UID tag number

-d: Specify host directory

-e: Specify account expiration time

-g: Specifies the UID user's base group name

-G: Specify additional group names for GIDs

-M: Do not create an initialization host directory for users

-S: Specify user login shell

1.2 Set user password (passwd)

Command: passwd [-options] [username]

Options:

-d: Clear password

-l: Lock user account

-S: View user status

-U: Unlock user account

1.3 Modify user account attributes (usermod)

Command: usermod [-options] [username]

Options:

-l: modify user login name

-L: Lock user account

-U: Unlock user account

-u d e G s same as useradd

II. Group Account Management 2.1 Group Account Add

Command: groupadd [-option] [username]

Options:

-g: Add group account

2.2 Add group members (gpasswd)

Command: gpasswd [-options] [username]

Options:

-a: Add user

-d: Delete user

-M: Custom add multiple users separated by ","

2.3 Delete group members (groupdel)

Command: groupdel [-options] [username]

Options:

-a: Add user

-d: Delete user

-M: Custom add multiple users separated by ","

2.4 review the user information

id (user): identity

groups (users): groups to which they belong

finger: user details

users, who, w: Logged-in user information [device path]

III. Rights and attribution of users, files, directories 3.1 Access rights

Read r: allows viewing file contents, displaying directory lists

Write w: Allow file content, subdirectories to be modified

Executable x: allows running programs, switching directories

Owner: The user account that owns the file or directory

Group: The group account that owns the file or directory

d(directory), b(block device file), c(character device file)

"-"(normal file),"l"(linked file)

IV. 4.1 Modification of permissions

#chmod +ugoa (owner, group, other, all users)+-= file or directory

#chmod xxx + file or directory (r=4, w=2, x=1)

4.2 modify attribution

chown belongs to main + file or directory

chown: group + file or directory

chown: group + file or directory

Chapter 3 Disk Management and User Disk Quota I. Partitioning, formatting, mounting of disk devices 1.1 Partitioning: Managing disk partitions in an interactive environment

fdisk disk device (path)

Common commands in interactive mode:

-m: View help information

-p: View partition information

-n: New partition

-d: Delete partition

-t: Change partition type

-w: Save and exit

-q: give up and quit

1.2 Create File System (Format)

mkfs -t type partition device

eg: # mkfs -t etx4 /dev/sdb1 //put/dev/sdb1 disk format ext4

1.3. Create swap file system (swap partition)

mkswap partition device

swapon;swapoff

1.4 Mount and unmount file systems

mount [-t type] Storage device mount point directory

mount -o loop image file mount point directory

umount Storage device location

mount mount point directory

1.5 Boot Auto Mount--Modify Configuration File 1.5.1 Modify Configuration File

vim /etc/fstab

/dev/sdb1 disk/var/ltc path ext4 type default 0 0

#Mount -o remount,usrquota,grpquota /dev/sdb1 /home/ltc

//temporarily add disk/dev/sdb1 quota file mounted under/home/ltc

1.5.2 View mount status

#mount -a

#mount

1.5.3 View disk usage

df [-options] [file]

Example: #df -hT

II. LVM (Logical Volume Management) 1.1 LVM Overview

PV: Physical Volume

Normal partition created using fdisk, including many PE's of default 4 kb size

VG: Volume Group

A combination of one or more physical volumes

LV: Logical Volume

A block of space separated from a volume group and used to establish a file system

1.2 creation command

PVVGLV scan Scanpvscanvgscanlvscan Create Createpvcreatevcreate displaypvdisplayvgdisplaylvdisplay Remove removepvremovgremovelvremove extend----vgextendlvextend reduce----vgreducelvreduce

Create pv pvcreate devicename/dev/sdb1

Create vg vgcreate Volume Group Name/ltc Physical Volume/dev/sdb1 Physical Volume/dev/sdb2

Create lvm lvcreate -L Size/100M -n Logical Volume Name Volume Group Name

lvm lvextend -L + size/dev/volume group name/logical volume name

1.3 Convert physical volumes/volume groups/logical volumes

Divide the partition with fdisk command, set the type to "8e"lvm create with pvcreate

#pvcreate /dev/sdb1 /dev/sdc1

#vgcreate jdy /dev/sdb1 dev/sdc1

#lvcreate -L 100M -n zr jdy

1.4 Logical Volume LVM Capacity Expansion

#Lvextend -L 100M /dev/volume group/logical volume

1.5 Create ext4 file system format

# mkfs -t ext4 /dev/volume group/logical volume

III. disk quota

Features of Disk Quota

Restricted scope: For specified file systems (partitions)

Restricted objects: user accounts, group accounts

Limit type: disk capacity, number of files

Limiting methods: soft limits, hard limits

3.1 Enable and disable quota support for file systems

quotaon -u [device] /path to mount

quotaoff

3.2 Detect disk quotas and create quota files

rpm -qa quota /-ql

quotacheck -ugcy file system

quotacheck -augcy

u g Detect user and group quotas

c: Create quota data file

v: Display execution process

a: Detect all available partitions

3.3 Edit user quotas and enable quotas

#edquota -u username

#edquota -g group name

#quotaon -ugv /ltc

#quotaoff -ugv /ltc

3.4 Verify Disk Quotas

Partition/mount directory to switch users to quota

Command dd to configure

#cd /ltc

#dd if=/dev/zero of=myfile bs=10M count=120

3.5 View quota usage

#quota -u username

#quota -g group name

#request file

IV. Laboratory environment requirements and configurations

Requirements: 1 Add 2 new disks/dev/sdb /dev/sdc

2 Create 4 physical volumes pv 2 volume groups vg 1 logical volume

3 Set the logical volume to boot automount

4 Limit user quota for this logical volume to a maximum of 50 MB

Step 1 Add Disk

1. Add 2 new hard disks to the virtual machine and restart to initialize the hard disks

2.#fdisk /dev/sdb #fdisk /dev/sdc

n: Create selection type extended primary partition

p: Select partitions 1-4

t: Select type

#/dev/sdb sdb1 8e sdb2 8e sdb3 83

//in/dev/sdb this disk type 8e lvm 83 standard partition

#/dev/sdc sdc1 8e sdc2 8e sdc3 8e sdc4 5 Extend

Step 2 Create Physical Volume Volume Group Logical Volume

1 #pvcreate /dev/sdb1 /dev/sdb2 /dev/sdc1 dev/sdc2 /dev/sdc3 View pvs

2 #vgcreate jdy1 /dev/sdb1 /dev/sdc1

#vgcreate jdy2 /dev/sdb2 dev/sdc2 /dev/sdc3 View vgs

3 #lvcreate -L 200M -n zr jdy2 View lvs path/dev/jdy2/zr

4 #mkfs -t ext4 /dev/jdy2/zr Format Support Mount

5 Automatic mounting

#vim /etc/fstab

#/dev/jdy2/zr /test ext4 default,usrcheck,grpquota 0 0

//logical volume LVM address mounted to/test format ext4 support quota

Step 3 Disk quota limits

1 Check if configuration software exists

#rpm -q quota

#rpm -ql quota

2 Create a disk quota profile

#quotacheck -ugc /dev/jdy2/zr //Create a quota file for the lvm disk

3 Go to the mounted directory to view

#ls -l /ltc //view directory

Step 4 Add quotas to users

1 Edit configuration settings for user and group accounts

# edquota -u 1/username

filesystem blocks soft hard inodes soft hard

/dev/jdy2/zr 10 20 5 10

System Equipment Soft Quota K Hard Quota Number of Soft Files Number of Hard Files

2 Enable and disable file system quotas

#quotaon -ugv [device path]

#quotaoff -ugv [device path]

3 Verify disk quota functionality

View disk quota information repquota -a

Switch users to create a file in the directory displayed is small b

(ltc)#dd if=/dev/zero of=/host directory file path bs=1M count=10

Thank you for reading, the above is "LINUX users and disk management method is what" the content, after learning this article, I believe that everyone on LINUX users and disk management method is what this problem has a deeper understanding, the specific use of the need for everyone to practice verification. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report