![]() This command recursively deletes all files in the trash folder. ![]() To permanently remove files from the trash, use the following command:.This command lists the files in the trash folder. Execute the following command to view the contents of the trash directory:.Run the following command to navigate to the user's home directory:.These files can accumulate over time and consume valuable storage. On a server without a user interface, you can manually clear the trash and temporary files to free up disk space. Step 5: Clearing the Trash and Temporary Files: Sudo apt-get autoclean - This command removes only the obsolete package files from the cache directory. Sudo apt-get clean - This command clears the local repository of retrieved package files. To clean the package cache, run the following commands: APT stores downloaded package files in the cache directory, which can consume a considerable amount of disk space. Ubuntu uses the Advanced Packaging Tool (APT) to manage software packages. Note that this operation requires administrative privileges. Sudo rm /var/log/*/*.log - This command removes log files from the /var/log directory. To clear logs manually, use the following command: Ubuntu uses the logrotate utility to manage logs. It's recommended to periodically clear these logs to free up storage. System logs can accumulate over time and occupy a significant amount of disk space. The -r flag is used to remove directories recursively, and -f is used to force deletion without confirmation.ĭouble-check the paths before executing the command to avoid accidental deletion of important data. ![]() Sudo rm -rf /path/to/file_or_folder - Replace /path/to/file_or_folder with the actual path of the file or folder you want to delete. To remove files and folders, use the rm command: However, exercise caution while deleting files, as some may be critical to the system or other applications. Once you've identified large files or folders that are no longer needed, it's time to remove them. Analyze the output and identify the ones consuming excessive disk space. The output will display the sizes of the files and folders in human-readable format (e.g., 10G for 10 gigabytes). Sudo du -hsx * | sort -rh | head -n 20 - This command lists the top 20 largest files and folders in the current directory, sorted by size. Open a terminal and execute the following commands:Ĭd / - This command changes the directory to the root directory. Ubuntu provides several command-line tools to accomplish this task effectively. The first step in managing disk space is to identify the large files and folders that are consuming the most space. Step 1: Identifying Large Files and Folders: By following these steps, you can regain valuable disk space and maintain a healthy server environment. In this tutorial, we will explore how to detect and remove large files and folders when your disk space is full on Ubuntu-based Linux servers. Disk space is a valuable resource on any Linux server, and it's crucial to manage it efficiently to ensure optimal performance and prevent system slowdowns or crashes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |