![]() ![]() I hope that this quick tip helps you level up your sysadmin fundamentals. There are also graphical tools to check disk space, such as the ncdu command, but for me, the du command is simple, direct, and efficient. For example, here's what I get when I run a command to sort the output by the first column (capacity): $ du -ahx -max-depth=1 /var | sort -k1 -rh The good news is I can sort the output in any order I want by passing sort -k1 -rh as input. That way, it's even easier to read at a glance. While this output is good, it would be even better to sort it by capacity. Here's the sample output from my usual du command: $ du -ahx -max-depth=1 /var Unlike the -one-file-system option, the size reported remains the same with this option I just don't have to see as much output. If you use 2 instead, it prints folders two levels below /var. -max-depth=1 ( -d): Print the total for a directory (or file, with -all) only if it is, in this case, one level below /var.This ensures I see the disk space used under only one directory path and not across physical media. The result is that if /var/log is mounted separately, it isn't counted because it's on a separate filesystem. -one-file-system ( -x): Skip directories on different filesystems.-human-readable ( -h): Print sizes in big chunks rather than in bytes (for instance, 1K instead of 1024).Here is a breakdown of each option (with the short version in parentheses):ĭownload now -all ( -a): Print all files and folders. Here's my standard du command, with long options for clarity: $ du -all -human-readable \ Suppose I want to check all directories in /var. This way, I know which directories are my biggest offenders. I usually like to check the usage of multiple directories simultaneously. Here is one of my favorite tricks with du. For all of the options, refer to the du man page. It offers many helpful options individually or in the correct combinations. The du command summarizes disk usage of each file and recursively for each directory. The rm command in Linux removes files and directories.It uses the following syntax: rm options file or directory name Note: To remove multiple files or directories using the rm command.Recursive use of grep. To use the find command, type: find /path/to/search -name 'filename'. My favorite command for this type of data gathering is the du command. The find command will search through all of the files in the directory you specify. This knowledge allows you to plan for storage upgrades, manage and rotate files, and do other necessary sysadmin tasks. Knowing how much space a file or folder consumes on a partition is essential for a system administrator or developer. Linux system administration skills assessment.A guide to installing applications on Linux. Find file linux recursive download#
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |