In case you don't know du command is used to find out the size of directories and files in Linux. It summarizes disk usage of each FILE, recursively for directories.
But in case you want to skip out any specific directory from the usage calculation you can use the below steps
Now I have a directory "work". lets check out the size of the files inside this directory
This gave us an output with size of all the directories inside work. But what if I want to skip "deep" from the calculation?
Observe the below command
So as you see "deep" directory was not touched for size calculation. Similarly if you want to exclude multiple directories use the below method
You can also sort the output according to the size of the files using below command
Related Articles:
How to check the lock status of any user account in Linux
How to exclude some directories from find command in Linux
How to mount windows share on linux
How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
What are the s and k scripts in the etc rcx.d directories
How to check all the currently running services in Linux
How to configure PXE boot server in Linux using Red Hat 6
How to detect new hard disk attached without rebooting in Linux
How to detect new NIC/Ethernet card without rebooting in Linux
But in case you want to skip out any specific directory from the usage calculation you can use the below steps
Now I have a directory "work". lets check out the size of the files inside this directory
[root@nfsserver work]# du -sch *
1.2G deep
58M dir1
81M dir2
18M dir3
595M myfile.txt
1.9G total
-s, --summarize : display only a total for each argument
-c, --total : produce a grand total
-h, --human-readable : print sizes in human readable format (e.g., 1K 234M 2G)
This gave us an output with size of all the directories inside work. But what if I want to skip "deep" from the calculation?
Observe the below command
[root@nfsserver work]# du --exclude=deep -sch *
58M dir1
81M dir2
18M dir3
595M myfile.txt
751M total
So as you see "deep" directory was not touched for size calculation. Similarly if you want to exclude multiple directories use the below method
[root@nfsserver work]# du --exclude=deep --exclude=dir1 --exclude=dir2 -sch *
18M dir3
595M myfile.txt
613M total
You can also sort the output according to the size of the files using below command
# du -sch * | sort -h -r
1.9G total
1.2G deep
595M myfile.txt
81M dir2
58M dir1
18M dir3
I hope I made my self clear.
Related Articles:
How to check the lock status of any user account in Linux
How to exclude some directories from find command in Linux
How to mount windows share on linux
Follow the below links for more tutorials
How to secure Apache web server in Linux using password (.htaccess)How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
What are the s and k scripts in the etc rcx.d directories
How to check all the currently running services in Linux
How to configure PXE boot server in Linux using Red Hat 6
How to detect new hard disk attached without rebooting in Linux
How to detect new NIC/Ethernet card without rebooting in Linux