How to check disk space in linux?
How to check disk space in linux?: To check the disk space in Linux, you can use the command-line interface and various built-in tools. Here are the steps to check the disk space:
Open the terminal: Launch the terminal application on your Linux system. You can usually find it in the applications menu or by using the keyboard shortcut Ctrl+Alt+T.
Use the “df” command: In the terminal, type the following command and press Enter:
- bash
- Copy code
- df -h
The “df” command stands for “disk free” and the “-h” option is used to display the disk space in a human-readable format, showing sizes in gigabytes (GB) or terabytes (TB) instead of raw bytes.
View disk space information: After executing the command, you will see a table displaying information about the disk space usage on your system. The output will include details such as the filesystem, total size, used space, available space, and the mount point for each partition.
Here’s an example output:
bash
Copy code
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 8.6G 10G 47% /
/dev/sdb1 100G 30G 70G 30% /home
In the example above, “/dev/sda1” represents the root partition, and “/dev/sdb1” represents the “/home” partition. The “Size” column indicates the total size of the partition, “Used” shows the amount of disk space in use, “Avail” represents the available space, and “Use%” displays the percentage of disk space utilized.
By examining the output of the “df” command, you can determine how much disk space is available and how much is being used on each partition of your Linux system.
Remember to periodically check the disk space to ensure you have enough available storage and to identify any potential issues with disk usage.
How to check disk size in Ubuntu?
- Open the terminal: Press Ctrl+Alt+T on your keyboard to launch the terminal application in Ubuntu.
- Use the “lsblk” command: In the terminal, type the following command and press Enter:
lsblk
The “lsblk” command lists information about all available block devices, including disks and partitions.
- View disk size information: After executing the command, you will see a table displaying the disk devices and their associated partitions. Look for the devices labeled as “disk” to identify the disk sizes.
Here’s an example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 20G 0 part /
└─sda3 8:3 0 217.9G 0 part /home
In the example above, “sda” represents the disk device.
Linux check disk space by folder
- Open the terminal: Launch the terminal application on your Linux system. You can usually find it in the applications menu or by using the keyboard shortcut Ctrl+Alt+T.
- Use the “du” command: In the terminal, navigate to the directory you want to check the disk space usage for. You can change directories using the “cd” command followed by the path of the desired directory.
- Once you are in the desired directory, use the following command:
du -sh
The “du” command stands for “disk usage” and the “-sh” option is used to display the summarized size of the current directory in a human-readable format.
- View disk space usage: After executing the command, the terminal will display the disk space usage of the current directory in a human-readable format. The output will show the total disk space occupied by the directory and its subdirectories.
Here’s an example output:
2.5G .
In the example above, the output indicates that the current directory occupies 2.5 gigabytes (GB) of disk space.
By using the “du” command with the appropriate options, you can check the disk space usage of any specific folder or directory in Linux. This can help you identify which folders are taking up the most disk space and manage your storage more effectively.