Linux File System Management

Source: Internet
Author: User
Tags asymmetric encryption

Linux File System Management
|-File System composition
|-Device Mount
|-Partitioning and formatting principles
|-Disk quotas
|-system Backup

I. Composition of the file system
※/usr/bin,/bin: Holds commands that all users can execute
※/usr/sbin,/sbin: Store only commands that can be executed by root
※/home: User Default host Directory
※/proc: Virtual file system, storing current memory image
※/dev: Storing device files
※/lib: Storage of shared libraries required for System program operation
※/lost+found: To store some system error check results
※/tmp: Storing temporary files
※/ETC: System Configuration file
※/var: Contains frequently changing files, such as mail, log files, scheduled tasks, etc.
※/USR: Store All commands, libraries, manual pages, etc.
※/MNT: Installation point for temporary file system
※/boot: Save location for kernel file and bootstrap program file

Common commands
View Partition usage: df-h|-m
View file, directory size: du
[Email protected] ~]# du-h/etc/services
364k/etc/services
[Email protected] ~]# du-sh/etc
130m/etc
Detect repair File system: fsck, E2fsck (single-user mode execution)
Judging file types: Files
[Email protected] ~]# file/etc/services
/etc/services:ascii 中文版 Text

Using the optical drive
※ Mount Optical Drive
# Mount/dev/cdrom/mnt/cdrom
# Df-h Mount Information
# Cd/mnt/cdrom
# Ls/mnt/cdrom
※ Unmount the optical drive
# Umount/mnt/cdrom
# Eject

Add a disk or partition
Partitioning (FDISK)
Create File System (MKFS)
Try mounting (Mount)
Write configuration file (/etc/fstab)
[Email protected] ~]# DMESG | grep SDB to see if a disk exists
[[email protected] ~]# fdisk-l/DEV/SDA View disk information
1) partition Fdisk/dev/sdb/www 10g/bak
M help
P Show partition Table
n Add a new partition ext3
T change system file type
D Delete Partition
W Save exit
Q Do not save exit
2) Formatting Mkfs
[Email protected] ~]# MKFS.EXT3/DEV/SDB1
3) Mount
[Email protected] ~]# Mkdir/bak
[Email protected] ~]# Mount/dev/sdb1/bak
4) Write the configuration file for automatic mount (/etc/fstab)
label=//ext3 Defaults 1 1
Physical Partition name/Volume label = =/DEV/SDA1
Mount point
File system
Default settings
Whether to detect 1/0
Detection sequence 0,1,2
/dev/sdb1/bak ext3 Defaults 1 2
Add Volume label E2LABEL/DEV/SDB1 backup

Swapfile to dynamically increase swap space
1. # Mkdir/var/swap
# chmod 700/var/swap
2, # dd If=/dev/zero of=/var/swap/file.swp bs=1024k count=64
3. # MKSWAP/VAR/SWAP/FILE.SWP
4, Vi/etc/fstab
/VAR/SWAP/FILE.SWP swap swap defaults 0 0
5. Free
6, Swapon/var/swap/file.swap
7. Free

Second, disk quotas
1. Enable Partition quota function
Edit the/etc/fstab file to add a flag Usrquota or Grpquota on the Mount attribute
/dev/sda3/home ext3 Defaults,usrquota 1 2
Mount-o Remount/home
Temporary settings: Mount-o remount,usrquota/home
2. Set up quota database (enter single user mode)
Quotacheck-cvuga-cvu/test
Generates Aquota.user, aquota.group two files
3. Start Quota function
Quotaon Partition name Quotaon/home quotaoff closing quotas
4. Edit User Quotas
Edquota User name edquota-g user group name
Edquota-t Setting the grace period
Copy user Quotas
Edquota-p template User Replication User 1 replication User 2
Quota command to view user quota usage
Administrator View quota information: repquota-a

Third, system backup
1. Backup
2. Backup partition Ro, umount
3. Compression bzip2
4. Check Md5sum-c
5. Encryption GnuPG Asymmetric Encryption

※CP Command Backup Example
Backup directory:
CP-RPU Backup Directory Destination Directory
-P Keep backup directory and file attributes
-U Incremental Backup
Remote Backup available SCP

※tar Command Use Example
# Tar-zcf/backup/etc_20110303.tar.gz/etc/boot
Backup/etc directory, can package multiple directories at the same time
# TAR-ZCF Bakup_user_20110303.tar.gz/etc/passwd/etc/shadow/etc/group/etc/gshadow
Backup of specified files in/etc directory
# TAR-ZTF Backup_user_20110303.tar.gz
To view a file in a backup package (no package)
# tar-zxf/backup/etc_20110303.tar.gz
Restore/etc directory, default restore to packaged file source directory,-C can specify restore directory
# TAR-ZXF backup_user_20110303.tar.gz Etc/group
Restore only the specified files in the backup


Linux File System Management

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.