Listing Large Files over SSH: Step-by-Step Guide Month Read Expired: 3 Minute Listing large files in a specific directory over SSH is very important for server management and disk space optimization. In this article, we will explain step-by-step how to list files larger than a certain size. Our example will list files larger than 100 MB under the /var/log directory. You can adjust the directory and file size according to your needs. Requirements: Basic SSH knowledge Terminal or SSH client (e.g., PuTTY) Command structure: To list large files, we will use the following command:find /var/log -type f -size +100M -exec ls -lh {} ; | awk '{ print $5 ": " $9 }' | sort -n Let’s break down the command step-by-step: find /var/log -type f -size +100M: This part finds all files larger than 100 MB under the /var/log directory. /var/log: Directory to search -type f: Only files -size +100M: Files larger than 100 MB -exec ls -lh {} ;: Runs the ls -lh command on each found file, listing file sizes in a readable format. -exec: Execute a command on each found file ls -lh: List files with human-readable sizes {}: The file found by find ;: End of the exec command awk '{ print $5 ": " $9 }': Prints the file size and name from the ls -lh output. $5: File size $9: File name sort -n: Sorts the output numerically by file size. Example usage: Follow these steps to list large files in a directory: Connect to your server via SSH using: ssh username@server_ip_address Run the command: find /var/log -type f -size +100M -exec ls -lh {} ; | awk '{ print $5 ": " $9 }' | sort -n Review the output, which will list files larger than 100 MB, for example:105M: /var/log/example1.log200M: /var/log/example2.log Customization: You can change the /var/log directory and the 100M size limit as needed. For example, to list files larger than 50 MB in /home/user, use:find /home/user -type f -size +50M -exec ls -lh {} ; | awk '{ print $5 ": " $9 }' | sort -n Conclusion: In this guide, you learned how to list large files over SSH. This method is very useful for managing disk space efficiently and identifying unnecessary large files. Adjust the directory and file size to better manage your server. Did you find it useful? Thank you for your feedback. Sorry about that :( We'll work to make it better. You voted before. (30 times viewed / 0 people found it helpful)