Linux du command without traversing mounted file systems [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
If the wording of the question is wrong, please let me know. It might explain why I can’t find an answer.
I want to find the usage on my main disk using a command like:
du -sh /*
The problem is that I have a number of mount points at the root level, and I would like du to skip these.
I thought the -x option was supposed to do this, but either I misunderstand what it does or I’m using it the wrong way.
How can I apply du to only the root disk without traversing the additional mounts?
Thanks

du -x will not traverse any mount points it encounters. But if it is told to start at a mount point then it will do as requested.

This is hacky, but it seems to do what you want, from the shell,
for d in /*; do egrep " ${d} " /proc/mounts > /dev/null || du -sh ${d}; done
Add a sudo in front of the du if needed.

Related

linux command explain du -h --max-depth=1 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 months ago.
Improve this question
Can someone explain to me the following command in linux? (I know that with that command you can find the total space taken by each of the directories)
du -h --max-depth=1
Can you suggest a good way to understand in depth these commands?
thanks.
I assume that you want to know about this command in brief so, I'll just break it up for you:
du: this command is used to estimate file space usage
-h: this parameter is short for --human-readable to print sizes in human readable format
--max-depth=1: this parameter defines how deep in terms of folder structure level you want to see the output like is its level 1 then,
output will show the size for all the files and folders in current
directory but not for the content inside the folders the current
directory has
You can use this website to learn more about linux commands: https://explainshell.com/explain?cmd=du+-h+--max-depth%3D1
I recommend you to use du --help or man du to get help, and try these command yourself. You can remove or change any arguments and find out the differences between them.
-h means human readable, it will display the size like 1K or 3.5G, rather than only a number.
--max-depth=1 means it will only count the files and directories in current directory, sub-directories and sub-files will not display.

How to find disk usage per-user in Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Given a directory d and a list of users, I want to find disk space used by each user in directory d.I cannot install any utility as it's a production environment so need a result using standard LINUX command(s)
you mean just a du -sh of /home/ ?
du -sh /home/*
1.2G /home/user001
...
The following shell script will get the disk usage, in human readable form (-h), sort the results and deliver the top 10 values:
sudo du -Sh | sort -rh | head -10
You can try -
du -shc /home/*
Where,
s :- display total size of a file or total size of all files in a directory.
h :- human readable format.
c :- display a total size usage at the end of result.

Are badblocks related to a partition or permanent? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I ran a check on a partition :
sudo e2fsck -c /dev/sdb3
It found some bad blocks. As far as I understood, it marked the badblocks, so that no files will use them.
My question is : is that "marking" persistent or is it linked to the partition ?
More specifically, if I reformat the partition with something like
sudo mkfs.ext4 /dev/sdb3
are the badblocks still marked ?
That marking is part of the filesystem, and thus should be overwritten by the creation of a new filesystem. mke2fs can rerun the badblock check using -c, or you can plausibly extract the list with dumpe2fs -b and read it back in with -l for either mke2fs or e2fsck. Since the list uses block numbers, the block size must be kept the same.

Using BASH, how would one use "du -ch" to output only the total collective size? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm trying to run du -ch on multiple directories, but I only apart it only shows the total size of all files (I don't want each individual file, then the total at the end which is what -cdoes).
To resolve this issue, run the following command as parameter passing directories.
du -hs
Some ideas:
$ du -sh .
$ du -chs *
$ du -chs * | tail -1

-a option in `cp` command -- what does it do? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
What does the -a option do in the cp command?
I thought that the -a does not preserve the structure of directories. But, I have never found a case where the structure of directories has been destroyed by the -a option.
is there such a case where the structure of directories has been destroyed by the -a option? Thanks.
-a means 3 things:
preserve timestamps, permissions, group, user (if you're running as root).
preserves symbolic links (no dereference)
recursive copy
read the man page, it has all info there
-a, --archive
same as -dR --preserve=all
To my understanding, it should recursively copy the directories while keeping all the attributes. In which case, it shouldn't be destroying the structure at all.
http://man7.org/linux/man-pages/man1/cp.1.html

Resources