Linux SSH cleanup disk large File sample

Source: Internet
Author: User
Tags ssh disk usage

Remove command rm under SSH

Start to find online explanation RM [path] can delete files/folders
But when I used to delete, I was prompted:

RM admin1
Rm:cannot remove ' admin1 ': is a directory

Later found RmDir, but only the empty folder can be deleted
After the search was finally resolved: RM-RF [Folder]

Reference:

RmDir deleted directories, each level of the directory is empty, no other files. If a directory at any level has files, it cannot be deleted. You will use the RM-RF command to force the deletion. However, it is a bit unsafe to delete with RM-RF, will not make any prompts, or use Rm-ri better, because when the deletion, there will be warning prompts (each file and folder will be prompted).

Additions to RM:

The function of this command is to delete one or more files or directories in a directory, and it can also delete a directory and all the files and subdirectories under it. For linked files, only the link is disconnected and the original file remains unchanged.
The general form of the RM command is:
RM [Options] File ...
If the-r option is not used, RM does not delete the directory.

The options for this command have the following meanings:
–f ignores files that do not exist and never gives a hint.
–r instructs RM to delete all the directories and subdirectories listed in the parameters recursively.
– I for interactive deletion.
Use the RM-RF command to be careful. Because once the file is deleted, it cannot be restored. Prevents this from happening, you can use the I option to confirm the files that you want to delete individually. If the user enters Y, the file is deleted. If you enter anything else, the file is not deleted.

Example

First with du-sh/usr/* | Sort-rn This command to view the USR directory

Found this directory is very large and then go to see which directory is big

Finally found cd/usr/local/mysql/data this directory to the largest and then use Du-h–max-depth=1 to list the directory dozen files

God, what are these logs and bins? Finally find the information:
MYSQL-BIN.000001, Files such as mysql-bin.000002 are database operations logs, such as update a table, or delete some data, even if the statement does not have matching data, this command will also be stored in the log file, including the time of each statement execution, will also be recorded. This is primarily used for operational review and multiple database synchronization. Ib_logfile is used to record the consistency of the InnoDB table, only when the machine can play a role. Maria_log.00000003 is the MARIADB-specific document used by Burguez, and the function is similar.

Then restart the MySQL server, the problem is fixed! Free space instantly increases number gb!

1. Df-lh

2. Du-s/usr/* | Sort-rn
This is sorted by byte

3. du-sh/usr/* | Sort-rn
This is sorted by megabytes (M)

4. Select 10 of the preceding
Du-s/usr/* | Sort-rn | Head

5. Select the following 10
Du-s/usr/* | Sort-rn | Tail

Du-h–-max-depth=0 User
du-sh–-max-depth=2 | More

This article specifically describes the Linux in the du command? ⑹ ǎ?⒂ ether 菔, irresolute suppressed the patellar 溆 Plum ā?/p>

Du command feature Description: Statistics the size of the disk space that a folder (or file) occupies.

Syntax: du [-ABCDHHKLMSSX] [-l < Symbolic connection >][-x < files >][–block-size][–exclude=< folders or files] [–max-depth=< folder layers >][–help][–version][folder or file]

Often used:

-A or-all displays disk usage for each of the specified files, or displays the respective disk usage for each file in the folder.
-B or-bytes displays the folder or file size in bytes.
-C or –total displays the sum of all folders or files in addition to the size of the folder or file.
-D or –dereference-args displays the source file size for the specified symbolic connection.
-H or –human-readable to k,m,g to improve the readability of the information.
-H or –si and-h?⑹???? Entropy, M,g is converted to 1000 units instead of 1024.
-K or –kilobytes in 1024 bytes.
-L or –count-links a file that repeatedly calculates hardware connections.
The source file size for the symbol connection specified in the-l< symbol connection > or –dereference< symbol connection > Display option.
-M or –megabytes is in 1MB.
-S or –summarize displays only totals, that is, the current folder size.
When-S or –separate-dirs displays the size of each folder, it does not contain the size of its subfolders.
-X or –one-file-xystem the file system at the start of the process, and if you encounter a different file system folder, skip.
-x< file > or –exclude-from=< file > specify folder or file in < file >.
–exclude=< folder or File > skips the specified folder or file.
–max-depth=< folder layers > folders that exceed the specified number of layers are ignored.
–help display Help.
–version Displays version number information.

The du command in

Linux uses a demo example:

1> to display disk usage for a folder tree and each subtree
Du/home/linux
This displays the number of disk blocks in the/home/linux folder and each subfolder.
2> to display the disk usage of a folder tree and each subtree in 1024 bytes
Du-k/home/linux
This displays the number of 1024-byte disk blocks in the/home/linux folder and each subfolder.
3> Displays the disk usage of a folder tree and each subtree in MB
du-m/home/linux
This displays the number of MB disk blocks in the/home/linux folder and each subfolder.
4> Displays the disk usage of a folder tree and each subtree in gigabytes
Du-g/home/linux
This displays the number of GB disk blocks in the/home/linux folder and each subfolder.
5> View the size of all folders and subfolders under the current folder:
Du-h.
“.” Represents the current folder. can also be replaced with a clear path.
-H represents the humanized form of K, M, and G
6> View the size of the user folder under the current folder, and do not want to look at other folders and their subfolders:
Du-sh User
-S indicates the meaning of the summary, That is, simply listing a summarized value,
du-h–max-depth=0 user
–max-depth=n, only goes deep into the N-tier folder, which is set to 0, which means that it does not go deep into the subfolder.
7> Lists the size of all folders and files under the user folder and its subfolders:
Du-ah User
-A to include folders and files
8> lists the size of folders in the current folder that do not contain XYZ strings:
Du-h–exclude= ' *xyz* '
9> want to list a number of other information about the user folder and subfolder size in one screen:
du-0h user
-0 (bar 0) means that each folder is listed with information, not wrapped, Instead, you output the information for the next folder directly.
10> only displays all disk usage for one folder tree
du -s/home/linux

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.