linux command explain du -h --max-depth=1 [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 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.

Related

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.

Meaning of different indicators when using 'ls -F' [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 4 years ago.
Improve this question
I'm currently studying Bash shell and have encountered command ls -F. I know it ls function is to append indicators to items lists, so to distinguish between different file types. I know that / is appended to directory and * is appended to executable files. But I have checked the manual page on ls command but couldn't find any information on indicator =>#|.
Could someone tell me what they represent? And it would be even better if can inform me where to find this kind of information when in need.
Try info ls, under "What information is listed":
‘-F’
‘--classify’
‘--indicator-style=classify’
Append a character to each file name indicating the file type.
Also, for regular files that are executable, append ‘*’. The file
type indicators are ‘/’ for directories, ‘#’ for symbolic links,
‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors, and nothing for
regular files. Do not follow symbolic links listed on the command
line unless the ‘--dereference-command-line’ (‘-H’),
‘--dereference’ (‘-L’), or
‘--dereference-command-line-symlink-to-dir’ options are specified.

Linux du command without traversing mounted file systems [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
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.

How to find current folder size 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 7 years ago.
Improve this question
When I type df -h it shows a folder of size 200GB, but when I try to find the size of any of the sub-directories by du -sch /path the folder size is 10kB. I know that certain sub-folder should be of size 100GB.
How do I find the size of the current folder/directory in Linux?
Use: du -sh * , this will give you the size of all the directories, files etc in the pwd in a readable format (you can get rid of the * if you wish obviously to get the size of just the pwd).
Read man du , also this has some very nice examples.
When you run du -sch /abc it doesn't show the size of hidden files (the files/directories that have the prefix dot(.) in their names) in the abc .
To check the size of all the files you can run, assuming you are in the directory abc
for i in `ls -a`; do du -sh $i ; done | sort -h
This will also sort the list.

Does unix 'find' give the same order every time? [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 years ago.
Improve this question
If I run find (Ubuntu, specifically), can I expect it to give me the same order of results every time? (Assuming, of course, that the actual files haven't changed.)
In other words, if I run
$ find foo
and it gives me
bar.txt
foo.txt
can I expect that it will never give me
foo.txt
bar.txt
?
The answer is "probably" but you shouldn't rely on it because any number of things can affect it.
What order do you want the files in? Decide on that and then use a find command (perhaps piped into sort) which reproducibly gets the result you need.
The order of the files is determined by the fine details of the filesystem format and the filesystem driver. You can't rely on it. Depending on the filesystem and operating system, here are things that might change the order:
A file is created or removed in a traversed directory (even if none of the listed files changed).
The files are moved around (e.g. transfered to a different filesystem or restored from backup).
A defragmenter or filesystem check ran and decided to move things around.
If you want a reproducible order, sort the results. find … | sort will do nicely if none of the file names contain newlines.

Resources