Linux Foundation II

Source: Internet
Author: User
Tags disk usage

1-1:
VI (Visual interface, visual interface, notepad similar to Windows)
Vim (vi upgrade version)
Vim vs. VI ascension:

VIM supports multi-level undo; (Ctrl + Z, unlimited undo up-step operation)
Vim can be run across platforms;
VIM supports syntax highlighting;
Vim supports graphical interface;
1-2:
Mode of operation of the VIM editor:
Command mode (Commandmode)
I//Enter the input mode;
://Enter the last line mode;
DD//Delete the entire line of the cursor;
Input mode (Insertmode)
://Enter the last line mode
Bottom row/Last line/last-line mode
Q//Do not save exit;
Q! Force not to save exit;
WQ//Save exit;
wq! Force save to exit;
ESC key//exit last line mode, return to the previous operation mode;
The command format for the VIM editor:
Vim +n[file name]
+//indicates that after opening the file, the cursor is in the last line, and n means locating to the nth row of the file;

2-1:
DF//View the usage status of the disk partition;
①-l//Show only local disks (default);
②-A//Displays disk usage for all file systems, including 0-byte partitions; for example,/proc/
③-h//In 1024 binary calculation of the most appropriate units display disk capacity;
④-h//In 1000 binary calculation of the most appropriate units display disk capacity;
⑤-T//display disk partition type;
⑥-T//Display the disk partition of the file system of the specified type;
⑦-x//does not display disk partitions for the specified type of file system;

The file size on the DU//statistics disk, default in kilobytes;
①-b//In Byte (bytes) for the statistical file;
②-k//In kilobytes per unit of statistical files;
③-M//In MB for statistical files;
④-h//According to 1024 in the most appropriate unit statistics file;
⑤-h//According to 1000 in the most appropriate unit statistics file;
⑥-S//Specify statistical objectives;

2-2:

The total number of primary partitions and extended partitions cannot exceed four!

There can be at most one of the extended partitions!

The extended partition cannot access the data directly, it must be created within the extended partition to access the data!


2-3:

Hot-swappable//can connect new hardware in live;

2-4:

The hardware devices in the Linux system exist in the/dev directory in the form of files, and the hardware devices are automatically identified by the Linux system;
The newly added hard disk must be partitioned, formatted and mounted before it can be used;


2-4:

Partition mode of the hard disk:
1. MBR:
No more than 4 primary partitions;
The maximum capacity of a single partition is 2TB;
FDISK is limited to MBR partition mode only;
2. GPT:
The number of primary partitions is "almost" unlimited; (up to 128 primary partitions can be supported);
The capacity of a single partition is "almost" unlimited, (the size of each partition breaks through the 2TB limit of the MBR partition, and the GPT partition capacity supports 18EB[1EB=1024PB,1PB=1024TB,1TB=1024GB]);

3. GPT Partition mode:
GPT partition mode does not have the concept of primary partition, extended partition, partition is called partition, partition, only partition start and end location, and the default unit is MB, using Unit[kb/mb/gb/tb/pb/eb] can set the default partition unit ; not suitable for systems that install the X86 architecture (32-bit operating system); parted can be used for GPT partitioning, and MBR partitioning is also supported;

GPT Partition details:
① Enter the parted command to launch the parted partition tool
② enter Help to view assistance information
③ switch partition destination disk, enter SELECT/DEV/SDC
④ Specify the type of partition table for the target hard drive before you can add partitions to the hard disk, enter the mklable command (if you use MBR partitioning, enter mklabelmsdos; use GPT partitioning, enter Mklabel GPT)
⑤ Enter Print to view the current partition details, enter the print all command to view all the partition details,
⑥parted Partition operation mode:
(1) Interactive mode (select using question mode)
(2) Command mode


Interactive mode to add partitions:
① add partition directive: Enter Mkpart command
② Enter the partition name,
③file system type? [ext2]? Select the partition system type (default ext2),
④start? The partition starts from the first few megabytes: starting from 0
⑤end? End Position: 2000MB
⑥ignore/cancel? (4K alignment, important for hard disk partitioning, for best performance, split 1-2000MB space to align data blocks)
⑦ Input Cancel Cancel


Command mode to add partitions:
①mkpart Test (partition Name) 2000 (start position 2000MB) 3000 (end position MB) Note: When adding a partition using the command mode, the partition name is not omitted.
② Delete Partition: RM 3 (partition number)
③unit GB Command: Specify start and end locations using GB for partitions
④quit command: Exit GPT partition


2-6:

MKFS//partition format command;
①mkfs. [File System] [Device name]
②mkfs-t[file system] [device name]

2-7:
/etc/fstab//mount (Mount) configuration file

2-8:
To add swap swap partitions to the hard disk:
① to build a normal Linux partition
② modifying the partition type to 16 binary encoding
Enter T to enter the number of the disk to be modified;
Enter L to view the types that can be modified;
Re-enter the (Linux swap), save success! You can view the saved situation by entering p.
Then enter W to save the partition;
③ format swap partition;
Mkswap [device name]
④ Enable swap partition
Swapon [device name]//enable swap partition;
Free//view swap loading status;
swapoff[device Name]//deactivate swap partition;


3-1:

/etc/group//This file stores all user group information in the current system (each row of data is a group, each row of data is divided into four segments, as follows):
GROUP:X: 123:abc,def,xyz
Group name: group Password placeholder: Group number: List of user names in the group
/etc/group:
Group Password Placeholder//group the group password in the file is masked by x;
uncorrupted Set Code//root Group encoding fixed to 0,1-499 is the system reservation, to the related services, programs reserved group encoding; The group number of user groups created manually is usually starting from 500;
The group user list in the Group user list//group file is empty, only on behalf of the group may not have users, but does not mean that the group must not have users, single from the configuration file, when there is only one user in the user group and the user name and user group name in the same group, the user list can be omitted;

/etc/gshadow//Store password information for user groups in the current system
group:*/!/Empty: xxxxx:abc,def,xyz
Group name: group Password placeholder: Group Manager: List of user names in groups
/etc/gshadow:
Group Password placeholder: when displayed *,! Or empty, there is no password on behalf of the user group;
Group Manager: Indicates which user can manage the user group, generally this placeholder is empty, which means that all users in the group can manage the user group;


/ETC/PASSWD//store information for all users in the current user's system
User:x:123:456:xxxxxxx:/home/user:/bin/bash
User name: Password: User-id:group-id: Comment Information: Home directory: Shell type
/ETC/PASSWD:
User number: The user number for Super Admin root must be 0

/etc/shadow
Password: User Real login password, the password is encrypted using MD5 algorithm;

3-2:
Group command:
Groupadd [group name]//create user group;
GROUPADD-G [group number] [group name]//create user's simultaneous set group number;
groupmod-n [New group name] [original group name]//change name;
GROUPMOD-G [group number] [group name]//change number;
Groupdel [group name]//delete user group;
When deleting a user group, users in the user group must be deleted before the user group can be deleted;
User command:
useradd [user Name]//Create new user;
useradd-g [group name] [Username]//create user at the same time specify the user group;
useradd-d [directory] [user name]//create user at the same time specify the user home directory;
USERMOD-C [Note Information] [user name]//modify user comment information;
usermod-l [new user name] [original user name]//modify user name;
usermod-d [directory] [user name]//modify user home directory;
usermod-g [group name] [user name]//Modify the group to which the user belongs;
Userdel [Username]//delete user (but not delete user home directory)
Userdel-r [Username]//delete user, delete user home directory at the same time;

/etc/nologin

3-3:

passwd-l [user name]//Lock the user;
passwd-u [user name]//unlock user;
passwd-d [user Name]//clear user password;

Primary and secondary groups:
Users can belong to multiple groups at the same time:
A primary group
Multiple satellite groups
gpasswd-a [user name] [subordinate group group name]//Add a satellite group to the user, (if the user wants to add more than one satellite group, it will be separated by "comma" after the group name of the satellite);

gpasswd-d [user name] [subordinate group group name]//delete the satellite group for the user, (if the user wants to delete more than one satellite group, it will be separated by "comma" after the group name of the satellite);

NEWGRP [group name]//Switch User Group, (group password is used when switching group password)

USERADD-G [Primary Group name]-G [Secondary group name] [user name]//Specify primary and secondary groups while creating users;

GPASSWD [group name]//set group password;


3-4:
Su [user name]//switch user identity;
SU//switch to root user;
WHOAMI//Display the current login user name;
ID [Username]//display specified user information (including user number, user name, primary group number and name, satellite group list)
Groups [Username]//Display all groups where the user is located;
CHFN [user Name]//Set up user data, enter user data in turn;
Finger [user Name]//display user details;


This article is from the "It_boomer" blog, make sure to keep this source http://liangjing.blog.51cto.com/8582041/1844422

Linux Fundamentals two

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.