You can check the directory capacity with the du command. If no directory name is specified, the current directory will be the target.
du directory name
This is a sample to check the directory capacity with du.
This is a sample output result.
468 templates / blog 8 templates / static / images 12 templates / static / css 4 templates / static / blog 192 templates / static / js / google-code-prettify 292 templates / static / js 324 templates / static 28 templates / common 828 templates
The capacity is displayed in kilobytes for each directory and subdirectory.
To display in an easy-to-understand manner with units
Use the "-h" option to clearly display the units of the du command.
The output result has a unit.
Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% / dev tmpfs 794M 736K 793M 1% / run / dev / sda1 29G 4.1G 25G 15% / tmpfs 3.9G 8.0K 3.9G 1% / dev / shm tmpfs 5.0M 0 5.0M 0% / run / lock tmpfs 3.9G 0 3.9G 0% / sys / fs / cgroup / dev / sda15 105M 3.6M 101M 4% / boot / efi / dev / sdc1 1007G 77M 956G 1% / datadrive / dev / sdb1 16G 45M 15G 1% / mnt tmpfs 794M 0 794M 0% / run / user / 1001
Arrange directory usage from top to bottom
To display the directory usage in order from the top, combine sort and head with the du command. Useful for discovering large directories.
du templates | sort -rn | head -20
The output results are output in descending order of directory capacity.
824 templates 464 templates / blog 324 templates / static 292 templates / static / js 192 templates / static / js / google-code-prettify 28 templates / common 12 templates / static / css 8 templates / static / images 4 templates / static / blog
Specifying "/" for du and waiting for a while is convenient because you can see which directories are consuming space on the entire system.
How to check the capacity of the disk?
Use the df command to check the capacity of the disk.
Note that the du command is a command to check the directory capacity, and the df command is used to check the disk capacity.
What are permissions?
Permissions are the permissions to access a file.
Information about whether the owner, group, or other user has read, write, or execute permissions on the file.
The word file also includes directories. This is because in Linux, a directory is considered to be a type of file.
Owners, groups, and other users
A description of owners, groups, and other users.
What is the owner in permissions
The owner in a permission is the owner user of the file. You can see it at " ls -l". It is displayed in the third column.
What is a group in permissions
A group in permissions is a user who belongs to the owner group of the file. You can see it at " ls -l". It is displayed in the 4th column.
What are other users in permissions?
Other users in permissions are users other than the owner and the users who belong to the group.
Read permission, write permission, execution permission
This is an explanation of read permission, write permission, and execution permission.
What is read permission?
Read permission means that the file can be read.
What is write permission?
Read permission means that you can write to a file.
What is execution permission?
Executable means that the file can be executed as an executable file.
The directory has a special meaning, and you cannot access the directory without execute permission.
In general, give execute permission to all directories.
Representation of permissions
I will explain the expression of permissions.
First, permissions are represented by the following nine pieces of information. Remember this order.
- Owner read permission
- Owner write permission
- Owner execution permission
- Group read permission
- Group write permission
- Group execution permission
- Allow other users to read
- Other user write permission
- Execution permission of other users
String representation of permissions
When permissions are represented by a string. When viewed with the ls command, it is represented by a character string.
drwxr-xr-x 7 admins admins 68 Apr 20 13:13 dir1 -rwxrwxr-x 1 admins admins 724 May 21 13:56 file1
Remove the leftmost "d" and "-" parts.
It has 9 characters, but it corresponds to the 9 information explained above as it is.
r is read permission, w is write permission, and x is execution permission.
Octal representation of permissions
An octal representation of permissions. The chmod command is used to set permissions using octal numbers.
# Octal 644 755 600
Think of this in binary.
4 is "4 + 0 + 0". Therefore, the binary number is "100". You have read permission.
5 is "4 + 0 + 1". So if it's a binary number, it's "101". There are read permission and execution permission.
6 is "4 + 2 + 0". Therefore, the binary number is "110". There are read permission and write permission.
7 is "4 + 2 + 1". So if it's a binary number, it's "111". There are read permission, write permission, and execute permission.
0 is "0 + 0 + 0". So the binary number is "000". You do not have permission.
This corresponds to nine pieces of information. Where 1 stands, there is a permit.
# Binary number 110 100 100 111 101 101 110 000 000
For clarity, we've put a space between the owner's permissions, the group's permissions, and other user permissions.