Linux file properties

Source: Internet
Author: User

Chapter 1th Linux File properties
1.1 Failure Cases:
Low disk space no space left on device
Inode Number file type permissions hard link number belongs to the main genus Group
Index node owner belongs to family size modified time file name (not file attribute)
Index node
xxx
1.2 Soft connection and hard link difference
[Email protected] ~]# Ls-lhi
Total 304K
660149-rw-r--r--1 root root 387 Jul 09:39 1.txt
660139-rw-r--r--. 1 root root 0 Jul 03:21 alex.txt
660134-RW-------. 1 root root 1.1K Jul 18:25 anaconda-ks.cfg
1046995 d rwxr-xr-x. 2 root root 4.0K Jul 12:56 data
654083-rw-r--r--. 1 root root 22K Jul 18:25 Install.log
654084-rw-r--r--. 1 root root 5.8K Jul 18:24 install.log.syslog
660140-rw-r--r--. 1 root root 0 Jul 03:21 lidao.txt
660151-rw-r--r--1 root root 893 June 17:18 Node_exporter.yml
Hard Link Door
Hard links number of front and rear doors in supermarkets
1.3 Inode and block
Inode index node XXX number file property information (Size permission time file type hard connection number)
Location of block
No file name
Block Data Block file contents
The relationship between cat Oldboy.txt and Inode and block

The characteristics of inode and block

1.4/ETC/PASSWD Content
++++++++++++++++++++++

+

Problem:
Enterprise Case: If you write data to disk, you are prompted with the following error: No space left on device (insufficient disk space), through df-h view disk space, found not full, may I ask what is the reason? What situations can cause this problem to occur in an enterprise scenario?
The inode is exhausted.
Large number of small files (scheduled tasks)
1.5 Insufficient analog disk space
#1, Block's full.
Seq 500000000 >>/var/log/nt.avi
[Email protected] ~]# Du-sh/
Du:cannot Access/proc/2217/task/2217/fd/4‘: No such file or directory<br/>du: cannot access/PROC/2217/TASK/2217/FDINFO/4 ': No such file or directory
Du:cannot Access/proc/2217/fd/4‘: No such file or directory<br/>du: cannot access/PROC/2217/FDINFO/4 ': No such file or directory
16G/
[Email protected] ~]# Du-sh/See which file under the root is large
8.0k/app
8.0k/backup
7.6m/bin
38m/boot
68k/data
220k/dev
30m/etc
24k/home
214m/lib
27m/lib64
16k/lost+found
4.0k/media
4.0k/mnt
52k/oldboy
32k/opt
Du:cannot access /proc/2218/task/2218/fd/4‘: No such file or directory<br/>du: cannot access /PROC/2218/TASK/2218/FDINFO/4 ': No such file or directory
Du:cannot access /proc/2218/fd/4‘: No such file or directory<br/>du: cannot access /PROC/2218/FDINFO/4 ': No such file or directory
0/proc
372k/root
16m/sbin
4.0k/selinux
4.0k/srv
0/sys
99m/tmp
1.1g/usr
14g/var
[Email protected] ~]# du-sh/var/
|grep g See which files are large under/var/and will be filtered out at the end of G
14g/var/log
[Email protected] ~]# du-sh/var/log/|grep g View more information
14g/var/log/lidao.mp4
[[email protected] ~]# Ls-lh/var/log/lidao.mp4 to see which files under/var/log are large and will be filtered by the end of G
-rw-r--r--1 root root 14G Jul 10:16/var/log/lidao.mp4
DF-H Insufficient disk space
1.df-h, where's the full?
2.du-sh, one floor, one layer of troubleshooting.
Du-sh/
|grep G
3. Troubleshoot specific files or directories
4. Delete after confirmation
2nd Chapter Sort
Seq 20|sort–hr Sort
-H human readable form sequencing
-R reverse Order/reverse order
Du-sh/*|sort–h See all sorted by size
2.1 Inode Exhausted

Mkdir-p/app/logs
DD If=/dev/zero OF=/DEV/SDC bs=8k count=10
Ls-l/DEV/SDC
Mkfs.ext4/dev/sdc
Mount-o Loop/dev/sdc/app/logs
2.1.1 Ready to simulate block full.
[[email protected] ~]# DF–H view block
Filesystem Size used Avail use% mounted on
/dev/sda3 19G 16G 2.4G 87%/
Tmpfs 931M 0 931M 0%/dev/shm
/DEV/SDA1 190M 40M 141M 22%/boot
/DEV/SDC 73K 14K 55K 21%/app/logs
[Email protected] ~]# Ls-lh/bin/ls
-rwxr-xr-x. 1 root root 115K Mar 2017/bin/ls
[Email protected] ~]# cp/bin/ls/app/logs/
Cp:writing '/app/logs/ls ': No space left on device
[Email protected] ~]# \rm-f/app/logs/ls
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda3 19G 16G 2.4G 87%/
Tmpfs 931M 0 931M 0%/dev/shm
/DEV/SDA1 190M 40M 141M 22%/boot
/DEV/SDC 73K 14K 55K 21%/app/logs resolution block is full.
2.2 The analog inode is exhausted
[Email protected] ~]# df–i view Iondes
Filesystem inodes iused IFree iuse% mounted on
/dev/sda3 1250928 57431 1193497 5%/
TMPFS 238282 1 238281 1%/DEV/SHM
/DEV/SDA1 51200 51161 1%/boot
/DEV/SDC 5 69%/app/logs

2.2.1 Creating multiple Small files
[Email protected] ~]# Touch/app/logs/{1..7}.txt
Touch:cannot Touch /app/logs/6.txt‘: No space left on device<br/>touch: cannot touch /app/logs/7.txt ': No space left on device
[Email protected] ~]# Touch/app/logs/oldboy.txt
Touch:cannot Touch '/app/logs/oldboy.txt ': No space left on device

2.2.2 Troubleshooting
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda3 19G 16G 2.4G 87%/
Tmpfs 931M 0 931M 0%/dev/shm
/DEV/SDA1 190M 40M 141M 22%/boot
/DEV/SDC 73K 14K 55K 21%/app/logs
[Email protected] ~]# df-i
Filesystem inodes iused IFree iuse% mounted on
/dev/sda3 1250928 57431 1193497 5%/
TMPFS 238282 1 238281 1%/DEV/SHM
/DEV/SDA1 51200 51161 1%/boot
/DEV/SDC 0 100%/app/logs inodes full.
2.2.3 Solution

Summary: Insufficient disk space
1.block Troubleshooting
df-h; du-sh/confirm and delete after one layer

2.inode df-i; Find out if the directory size in the system is larger than 1M delete small files
Find/-type d-size +1m
The 3rd Chapter title:
1) Find files less than 4k in the system (awk array)
2) Find the directory size in the system larger than 1M find out which directory has a large number of small files
The directory block holds the file name in the directory
3.1 Deleting a large number of small files
[Email protected] ~]# mkdir-p/tmp/test
[Email protected] ~]# cd/tmp/test
[[email protected]/tmp/test]# Touch {1..500000}
-bash:/bin/touch:argument list too long column
[Email protected]/tmp/test]#
[[email protected]/tmp/test]# echo {1..500000}|xargs touch
[[email protected]/tmp/test]# echo {1..500000}|xargs touch
[[email protected]/tmp/test]# LS |wc–l count
500000
3.2 Failure: Unable to delete large number of files
[Email protected]/tmp/test]# \rm-f
-bash:/bin/rm:argument list too long lists cannot be deleted
[[email protected]/tmp/test]# ls
3.3 FIX: Delete a large number of files
[[email protected]/tmp/test]# ls |xargs RM Delete a large number of files
[[email protected]/tmp/test]# ls
[email protected]/tmp/test]# LL
Total 0
Summary: Delete a large number of small files
1.ls/find +|xargs RM
2. Reduce the scope of the deletion
LS 1
|xargs RM
LS-|xargs RM
3. Delete the directory where the files are located (permissions and properties are logged)
The 4th chapter shows the user
[[email protected]/tmp/test]# ID
Uid=0 (Root) gid=0 (root) groups=0 (root)
[[email protected]/tmp/test]# ID Oldboy
uid=500 (Oldboy) gid=500 (Oldboy) groups=500 (Oldboy)
[[email protected]/tmp/test]# ID Nobody
Uid=99 (nobody) gid=99 (nobody) groups=99 (nobody)
[Email protected]/tmp/test]# Su-oldboy
[Email protected] ~]$ Logout
[Email protected]/tmp/test]# Su-nobody
This account was currently not available.
5th Chapter Permission
What are the permissions in 5.1 Linux
R W X
rw-permissions of the user R-Group and R-Other permissions
5.2 Ways to grant permissions:
Read and write execution
Character type R W x
Digital Type 4 2 1
Chowd: Granting Permissions
For directory usage: CHOWN–R User name Directory name
CHOWN–R Group Name Directory name
Chown–r User name Group name Directory name
For file Usage: chown–r (user name text file) (master)
CHOWN–R Group name File
Chown–r User Name Group name file
Note: Users must be included in the group
Chmod: Modify the owner and group can only modify three kinds of properties: A user Group G o Other
Build Group: Groupadd plus multiple users to group: gpasswd–m

Linux file properties

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.