How can I see the size of files and directories in linux?
How can I see the size of files and directories in Linux? If use df -m then it shows the size of all the directory at the top level but for the directories and files inside the directory how to check size?
linux file
add a comment |
How can I see the size of files and directories in Linux? If use df -m then it shows the size of all the directory at the top level but for the directories and files inside the directory how to check size?
linux file
add a comment |
How can I see the size of files and directories in Linux? If use df -m then it shows the size of all the directory at the top level but for the directories and files inside the directory how to check size?
linux file
How can I see the size of files and directories in Linux? If use df -m then it shows the size of all the directory at the top level but for the directories and files inside the directory how to check size?
linux file
linux file
edited Jun 27 '14 at 17:49
Tshepang
6,0951772112
6,0951772112
asked Jul 30 '12 at 10:57
AdvaitAdvait
1,06021016
1,06021016
add a comment |
add a comment |
14 Answers
14
active
oldest
votes
It's simple. Use ls
command for files and du
command for directories.
Checking File Sizes
ls -l filename /* Size of the file*/
ls -l * /* Size of All the files in the current directory */
ls -al * /* Size of All the files including hidden files in the current directory */
ls -al dir/ /* Size of All the files including hidden files in the 'dir' directory */
ls
command will not list the actual size of directories(why?). Therefore, we use du
for this purpose.
Checking Directory sizes
du -sh directory_name /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh * /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/
Including -h
option in any of the above commands (for Ex: ls -lh *
or du -sh
) will give you size in human readable format (kb
, mb
,gb
, ...)
For more information see man ls
and man du
2
ls
won't show you the total size of all contents of a directory.
– Maxim Egorushkin
Jun 23 '14 at 15:30
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
note that thedu
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can usedu -d
to get the actual size asls
does. More info: unix.stackexchange.com/a/106278/155224
– Lucas Alonso
Apr 19 '17 at 21:04
|
show 2 more comments
There is du
command.
Size of a directory:
$ du -sh /tmp
Size of a file:
$ du -h /tmp/xyz
--apparent-size
command line switch makes it measure apparent sizes (what ls
shows) rather than actual disk usage.
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
@FranciscoCorralesMorales-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)
– Maxim Egorushkin
Jul 22 '14 at 19:56
1
I don't think this is right. Whatdu
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster
– mfloris
Jun 20 '16 at 6:45
@mfloris Use--apparent-size
then.
– Maxim Egorushkin
Jun 20 '16 at 9:26
I likedu -hs *
to see the size of all the files, and directories in the current directory.
– Jordan Stewart
Jan 20 '17 at 1:08
add a comment |
Use ls -s
to list file size, or if you prefer ls -sh
for human readable sizes.
For directories use du
, and again, du -h
for human readable sizes.
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
add a comment |
You can use:
ls -lh
Using this command you'll see the apparent space of the directory and true space of the files and in details the names of the files displayed, besides the size and creation date of each.
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with
– Jun711
Sep 13 '18 at 20:58
add a comment |
ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this.
This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).
Note that the --block-size parameter is a GNU extension on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support --block-size as described above.
add a comment |
File Size in MB
ls -l --b=M filename | cut -d " " -f5
File Size in GB
ls -l --b=G filename | cut -d " " -f5
add a comment |
There is also a great ncdu
utility - it can show directory size with detailed info about subfolders and files.
Installation
Ubuntu:
$ sudo apt-get install ncdu
Usage
Just type ncdu [path]
in the command line. After a few seconds for analyzing the path, you will see something like this:
$ ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ---------------------------------------------------------
. 96,1 GiB [##########] /home
. 17,7 GiB [# ] /usr
. 4,5 GiB [ ] /var
1,1 GiB [ ] /lib
732,1 MiB [ ] /opt
. 275,6 MiB [ ] /boot
198,0 MiB [ ] /storage
. 153,5 MiB [ ] /run
. 16,6 MiB [ ] /etc
13,5 MiB [ ] /bin
11,3 MiB [ ] /sbin
. 8,8 MiB [ ] /tmp
. 2,2 MiB [ ] /dev
! 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
8,0 KiB [ ] /snap
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
! 4,0 KiB [ ] /root
e 4,0 KiB [ ] /mnt
e 4,0 KiB [ ] /cdrom
. 0,0 B [ ] /proc
. 0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img.old
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] vmlinuz.old
@ 0,0 B [ ] vmlinuz
Delete the currently highlighted element with d, exit with CTRL + c
add a comment |
I do the following all the time:
$ du -sh backup-lr-May-02-2017-1493723588.tar.gz
NB:
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
add a comment |
You can use below command to get list of files in easily human readable format.
ls -lrtsh
add a comment |
You have to differenciate between file size and disk usage. The main difference between the two comes from the fact that files are "cut into pieces" and stored in blocks.
Modern block size is 4KiB, so files will use disk space multiple of 4KiB, regardless of how small they are.
If you use the command stat
you can see both figures side by side.
stat file.c
If you want a more compact view for a directory, you can use ls -ls
, which will give you usage in 1KiB units.
ls -ls dir
Also du
will give you real disk usage, in 1KiB units, or dutree with the -u
flag.
Example: usage of a 1 byte file
$ echo "" > file.c
$ ls -l file.c
-rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ ls -ls file.c
4 -rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ du file.c
4 file.c
$ dutree file.c
[ file.c 1 B ]
$ dutree -u file.c
[ file.c 4.00 KiB ]
$ stat file.c
File: file.c
Size: 1 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 2185244 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ nacho) Gid: ( 1000/ nacho)
Access: 2018-04-30 20:41:58.002124411 +0200
Modify: 2018-04-30 20:42:24.835458383 +0200
Change: 2018-04-30 20:42:24.835458383 +0200
Birth: -
In addition, in modern filesystems we can have snapshots, sparse files (files with holes in them) that further complicate the situation.
You can see more details in this article: understanding file size in Linux
add a comment |
I'm a Ubuntu 16.04 user myself and I find that the ll
command is by far the easiest way to see a directory's contents. I've noticed that not all Linux distributions support this command, but there's probably a workaround/install for each distro out there.
Example:
user@user-XPS-15-9560:/$ ll
total 188
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ./
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ../
drwxr-xr-x 2 root root 4096 Jan 22 15:13 bin/
drwxr-xr-x 4 root root 12288 Jan 29 11:35 boot/
drwxr-xr-x 2 root root 4096 Sep 3 18:14 cdrom/
drwxr-xr-x 20 root root 4440 Feb 5 08:43 dev/
drwxr-xr-x 153 root root 12288 Feb 2 15:17 etc/
drwxr-xr-x 4 root root 4096 Sep 3 18:15 home/
...
The biggest advantage for me is that it's quick and really intuitive to use.
UPDATE: what I didn't know was that on Ubuntu it's a pre-configured alias. You can easily set it yourself by executing alias ll="ls -la"
on the command line, or by adding this entry in your .bashrc config file:
sudo nano ~/.bashrc
...add line described above and save file by pressing Ctrl+X and Y...
source ~/.bashrc
add a comment |
you can use ls -sh in linux you can do sort also
you need to go to dir where you want to check the size of files
add a comment |
If you are using it in a script, use stat
.
stat -c %s filename
That will give you size in bytes. See man stat
for more output format options.
add a comment |
go to specific directory then run below command
# du -sh *
4.0K 1
4.0K anadb.sh --> Shell file
4.0K db.sh/ --> shell file
24K backup4/ --> Directory
8.0K backup6/ --> Directory
1.9G backup.sql.gz --> sql file
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11720079%2fhow-can-i-see-the-size-of-files-and-directories-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
14 Answers
14
active
oldest
votes
14 Answers
14
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's simple. Use ls
command for files and du
command for directories.
Checking File Sizes
ls -l filename /* Size of the file*/
ls -l * /* Size of All the files in the current directory */
ls -al * /* Size of All the files including hidden files in the current directory */
ls -al dir/ /* Size of All the files including hidden files in the 'dir' directory */
ls
command will not list the actual size of directories(why?). Therefore, we use du
for this purpose.
Checking Directory sizes
du -sh directory_name /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh * /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/
Including -h
option in any of the above commands (for Ex: ls -lh *
or du -sh
) will give you size in human readable format (kb
, mb
,gb
, ...)
For more information see man ls
and man du
2
ls
won't show you the total size of all contents of a directory.
– Maxim Egorushkin
Jun 23 '14 at 15:30
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
note that thedu
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can usedu -d
to get the actual size asls
does. More info: unix.stackexchange.com/a/106278/155224
– Lucas Alonso
Apr 19 '17 at 21:04
|
show 2 more comments
It's simple. Use ls
command for files and du
command for directories.
Checking File Sizes
ls -l filename /* Size of the file*/
ls -l * /* Size of All the files in the current directory */
ls -al * /* Size of All the files including hidden files in the current directory */
ls -al dir/ /* Size of All the files including hidden files in the 'dir' directory */
ls
command will not list the actual size of directories(why?). Therefore, we use du
for this purpose.
Checking Directory sizes
du -sh directory_name /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh * /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/
Including -h
option in any of the above commands (for Ex: ls -lh *
or du -sh
) will give you size in human readable format (kb
, mb
,gb
, ...)
For more information see man ls
and man du
2
ls
won't show you the total size of all contents of a directory.
– Maxim Egorushkin
Jun 23 '14 at 15:30
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
note that thedu
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can usedu -d
to get the actual size asls
does. More info: unix.stackexchange.com/a/106278/155224
– Lucas Alonso
Apr 19 '17 at 21:04
|
show 2 more comments
It's simple. Use ls
command for files and du
command for directories.
Checking File Sizes
ls -l filename /* Size of the file*/
ls -l * /* Size of All the files in the current directory */
ls -al * /* Size of All the files including hidden files in the current directory */
ls -al dir/ /* Size of All the files including hidden files in the 'dir' directory */
ls
command will not list the actual size of directories(why?). Therefore, we use du
for this purpose.
Checking Directory sizes
du -sh directory_name /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh * /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/
Including -h
option in any of the above commands (for Ex: ls -lh *
or du -sh
) will give you size in human readable format (kb
, mb
,gb
, ...)
For more information see man ls
and man du
It's simple. Use ls
command for files and du
command for directories.
Checking File Sizes
ls -l filename /* Size of the file*/
ls -l * /* Size of All the files in the current directory */
ls -al * /* Size of All the files including hidden files in the current directory */
ls -al dir/ /* Size of All the files including hidden files in the 'dir' directory */
ls
command will not list the actual size of directories(why?). Therefore, we use du
for this purpose.
Checking Directory sizes
du -sh directory_name /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh * /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/
Including -h
option in any of the above commands (for Ex: ls -lh *
or du -sh
) will give you size in human readable format (kb
, mb
,gb
, ...)
For more information see man ls
and man du
edited Jun 8 '18 at 0:32
answered Jul 30 '12 at 10:59


mk..mk..
8,290114778
8,290114778
2
ls
won't show you the total size of all contents of a directory.
– Maxim Egorushkin
Jun 23 '14 at 15:30
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
note that thedu
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can usedu -d
to get the actual size asls
does. More info: unix.stackexchange.com/a/106278/155224
– Lucas Alonso
Apr 19 '17 at 21:04
|
show 2 more comments
2
ls
won't show you the total size of all contents of a directory.
– Maxim Egorushkin
Jun 23 '14 at 15:30
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
note that thedu
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can usedu -d
to get the actual size asls
does. More info: unix.stackexchange.com/a/106278/155224
– Lucas Alonso
Apr 19 '17 at 21:04
2
2
ls
won't show you the total size of all contents of a directory.– Maxim Egorushkin
Jun 23 '14 at 15:30
ls
won't show you the total size of all contents of a directory.– Maxim Egorushkin
Jun 23 '14 at 15:30
1
1
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
@MaximYegorushkin Thank you. Corrected.
– mk..
Jun 24 '14 at 9:55
2
2
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
how can I see the size in bytes (Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:14
4
4
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
@FranciscoCorralesMorales ls -lh will show you the size in kb MB GB etc.
– mk..
Aug 5 '15 at 3:25
2
2
note that the
du
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can use du -d
to get the actual size as ls
does. More info: unix.stackexchange.com/a/106278/155224– Lucas Alonso
Apr 19 '17 at 21:04
note that the
du
command shows the disk usage of the file, wich might be larger than the actual size of the file. You can use du -d
to get the actual size as ls
does. More info: unix.stackexchange.com/a/106278/155224– Lucas Alonso
Apr 19 '17 at 21:04
|
show 2 more comments
There is du
command.
Size of a directory:
$ du -sh /tmp
Size of a file:
$ du -h /tmp/xyz
--apparent-size
command line switch makes it measure apparent sizes (what ls
shows) rather than actual disk usage.
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
@FranciscoCorralesMorales-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)
– Maxim Egorushkin
Jul 22 '14 at 19:56
1
I don't think this is right. Whatdu
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster
– mfloris
Jun 20 '16 at 6:45
@mfloris Use--apparent-size
then.
– Maxim Egorushkin
Jun 20 '16 at 9:26
I likedu -hs *
to see the size of all the files, and directories in the current directory.
– Jordan Stewart
Jan 20 '17 at 1:08
add a comment |
There is du
command.
Size of a directory:
$ du -sh /tmp
Size of a file:
$ du -h /tmp/xyz
--apparent-size
command line switch makes it measure apparent sizes (what ls
shows) rather than actual disk usage.
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
@FranciscoCorralesMorales-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)
– Maxim Egorushkin
Jul 22 '14 at 19:56
1
I don't think this is right. Whatdu
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster
– mfloris
Jun 20 '16 at 6:45
@mfloris Use--apparent-size
then.
– Maxim Egorushkin
Jun 20 '16 at 9:26
I likedu -hs *
to see the size of all the files, and directories in the current directory.
– Jordan Stewart
Jan 20 '17 at 1:08
add a comment |
There is du
command.
Size of a directory:
$ du -sh /tmp
Size of a file:
$ du -h /tmp/xyz
--apparent-size
command line switch makes it measure apparent sizes (what ls
shows) rather than actual disk usage.
There is du
command.
Size of a directory:
$ du -sh /tmp
Size of a file:
$ du -h /tmp/xyz
--apparent-size
command line switch makes it measure apparent sizes (what ls
shows) rather than actual disk usage.
edited Jun 20 '16 at 9:26
answered Jul 30 '12 at 10:59
Maxim EgorushkinMaxim Egorushkin
86k1199182
86k1199182
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
@FranciscoCorralesMorales-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)
– Maxim Egorushkin
Jul 22 '14 at 19:56
1
I don't think this is right. Whatdu
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster
– mfloris
Jun 20 '16 at 6:45
@mfloris Use--apparent-size
then.
– Maxim Egorushkin
Jun 20 '16 at 9:26
I likedu -hs *
to see the size of all the files, and directories in the current directory.
– Jordan Stewart
Jan 20 '17 at 1:08
add a comment |
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
@FranciscoCorralesMorales-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)
– Maxim Egorushkin
Jul 22 '14 at 19:56
1
I don't think this is right. Whatdu
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster
– mfloris
Jun 20 '16 at 6:45
@mfloris Use--apparent-size
then.
– Maxim Egorushkin
Jun 20 '16 at 9:26
I likedu -hs *
to see the size of all the files, and directories in the current directory.
– Jordan Stewart
Jan 20 '17 at 1:08
1
1
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
how can I see the size in bytes (Kilo, Mega, Giga,... ) ?
– Francisco Corrales Morales
Jul 22 '14 at 19:17
6
6
@FranciscoCorralesMorales
-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)– Maxim Egorushkin
Jul 22 '14 at 19:56
@FranciscoCorralesMorales
-h
flag should do what you ask: print sizes in human readable format (e.g., 1K 234M 2G)– Maxim Egorushkin
Jul 22 '14 at 19:56
1
1
I don't think this is right. What
du
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster– mfloris
Jun 20 '16 at 6:45
I don't think this is right. What
du
does is Summarize disk usage of the set of FILEs , that is if a file is very small (i.e. 2140 bytes) the output of "du" is (in my case) 4KB because that's the size of the cluster– mfloris
Jun 20 '16 at 6:45
@mfloris Use
--apparent-size
then.– Maxim Egorushkin
Jun 20 '16 at 9:26
@mfloris Use
--apparent-size
then.– Maxim Egorushkin
Jun 20 '16 at 9:26
I like
du -hs *
to see the size of all the files, and directories in the current directory.– Jordan Stewart
Jan 20 '17 at 1:08
I like
du -hs *
to see the size of all the files, and directories in the current directory.– Jordan Stewart
Jan 20 '17 at 1:08
add a comment |
Use ls -s
to list file size, or if you prefer ls -sh
for human readable sizes.
For directories use du
, and again, du -h
for human readable sizes.
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
add a comment |
Use ls -s
to list file size, or if you prefer ls -sh
for human readable sizes.
For directories use du
, and again, du -h
for human readable sizes.
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
add a comment |
Use ls -s
to list file size, or if you prefer ls -sh
for human readable sizes.
For directories use du
, and again, du -h
for human readable sizes.
Use ls -s
to list file size, or if you prefer ls -sh
for human readable sizes.
For directories use du
, and again, du -h
for human readable sizes.
edited Aug 30 '12 at 13:31
answered Jul 30 '12 at 11:46
ThorThor
30.2k67894
30.2k67894
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
add a comment |
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
4
4
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
A tip is to use; 'du -sh *' to list all the directory sizes. :)
– Entalpi
Feb 28 '17 at 9:12
add a comment |
You can use:
ls -lh
Using this command you'll see the apparent space of the directory and true space of the files and in details the names of the files displayed, besides the size and creation date of each.
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with
– Jun711
Sep 13 '18 at 20:58
add a comment |
You can use:
ls -lh
Using this command you'll see the apparent space of the directory and true space of the files and in details the names of the files displayed, besides the size and creation date of each.
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with
– Jun711
Sep 13 '18 at 20:58
add a comment |
You can use:
ls -lh
Using this command you'll see the apparent space of the directory and true space of the files and in details the names of the files displayed, besides the size and creation date of each.
You can use:
ls -lh
Using this command you'll see the apparent space of the directory and true space of the files and in details the names of the files displayed, besides the size and creation date of each.
edited Jun 14 '18 at 13:14
rimalonfire
177217
177217
answered Feb 16 '16 at 17:58
Yenier TorresYenier Torres
34638
34638
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with
– Jun711
Sep 13 '18 at 20:58
add a comment |
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with
– Jun711
Sep 13 '18 at 20:58
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with– Jun711
Sep 13 '18 at 20:58
ls -l
will give u file size including the metadata? as it seems to be slightly 4kb bigger for one of file that i tried with– Jun711
Sep 13 '18 at 20:58
add a comment |
ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this.
This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).
Note that the --block-size parameter is a GNU extension on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support --block-size as described above.
add a comment |
ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this.
This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).
Note that the --block-size parameter is a GNU extension on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support --block-size as described above.
add a comment |
ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this.
This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).
Note that the --block-size parameter is a GNU extension on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support --block-size as described above.
ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this.
This is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as number of 412-byte blocks, if you want to).
Note that the --block-size parameter is a GNU extension on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU coreutils 8.5 does support --block-size as described above.
answered Jul 15 '15 at 18:58


AdiAdi
1,3291120
1,3291120
add a comment |
add a comment |
File Size in MB
ls -l --b=M filename | cut -d " " -f5
File Size in GB
ls -l --b=G filename | cut -d " " -f5
add a comment |
File Size in MB
ls -l --b=M filename | cut -d " " -f5
File Size in GB
ls -l --b=G filename | cut -d " " -f5
add a comment |
File Size in MB
ls -l --b=M filename | cut -d " " -f5
File Size in GB
ls -l --b=G filename | cut -d " " -f5
File Size in MB
ls -l --b=M filename | cut -d " " -f5
File Size in GB
ls -l --b=G filename | cut -d " " -f5
edited Nov 29 '17 at 9:24


Rishabh Agrahari
8941917
8941917
answered Sep 16 '15 at 7:22
RavichandraRavichandra
78111321
78111321
add a comment |
add a comment |
There is also a great ncdu
utility - it can show directory size with detailed info about subfolders and files.
Installation
Ubuntu:
$ sudo apt-get install ncdu
Usage
Just type ncdu [path]
in the command line. After a few seconds for analyzing the path, you will see something like this:
$ ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ---------------------------------------------------------
. 96,1 GiB [##########] /home
. 17,7 GiB [# ] /usr
. 4,5 GiB [ ] /var
1,1 GiB [ ] /lib
732,1 MiB [ ] /opt
. 275,6 MiB [ ] /boot
198,0 MiB [ ] /storage
. 153,5 MiB [ ] /run
. 16,6 MiB [ ] /etc
13,5 MiB [ ] /bin
11,3 MiB [ ] /sbin
. 8,8 MiB [ ] /tmp
. 2,2 MiB [ ] /dev
! 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
8,0 KiB [ ] /snap
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
! 4,0 KiB [ ] /root
e 4,0 KiB [ ] /mnt
e 4,0 KiB [ ] /cdrom
. 0,0 B [ ] /proc
. 0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img.old
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] vmlinuz.old
@ 0,0 B [ ] vmlinuz
Delete the currently highlighted element with d, exit with CTRL + c
add a comment |
There is also a great ncdu
utility - it can show directory size with detailed info about subfolders and files.
Installation
Ubuntu:
$ sudo apt-get install ncdu
Usage
Just type ncdu [path]
in the command line. After a few seconds for analyzing the path, you will see something like this:
$ ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ---------------------------------------------------------
. 96,1 GiB [##########] /home
. 17,7 GiB [# ] /usr
. 4,5 GiB [ ] /var
1,1 GiB [ ] /lib
732,1 MiB [ ] /opt
. 275,6 MiB [ ] /boot
198,0 MiB [ ] /storage
. 153,5 MiB [ ] /run
. 16,6 MiB [ ] /etc
13,5 MiB [ ] /bin
11,3 MiB [ ] /sbin
. 8,8 MiB [ ] /tmp
. 2,2 MiB [ ] /dev
! 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
8,0 KiB [ ] /snap
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
! 4,0 KiB [ ] /root
e 4,0 KiB [ ] /mnt
e 4,0 KiB [ ] /cdrom
. 0,0 B [ ] /proc
. 0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img.old
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] vmlinuz.old
@ 0,0 B [ ] vmlinuz
Delete the currently highlighted element with d, exit with CTRL + c
add a comment |
There is also a great ncdu
utility - it can show directory size with detailed info about subfolders and files.
Installation
Ubuntu:
$ sudo apt-get install ncdu
Usage
Just type ncdu [path]
in the command line. After a few seconds for analyzing the path, you will see something like this:
$ ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ---------------------------------------------------------
. 96,1 GiB [##########] /home
. 17,7 GiB [# ] /usr
. 4,5 GiB [ ] /var
1,1 GiB [ ] /lib
732,1 MiB [ ] /opt
. 275,6 MiB [ ] /boot
198,0 MiB [ ] /storage
. 153,5 MiB [ ] /run
. 16,6 MiB [ ] /etc
13,5 MiB [ ] /bin
11,3 MiB [ ] /sbin
. 8,8 MiB [ ] /tmp
. 2,2 MiB [ ] /dev
! 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
8,0 KiB [ ] /snap
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
! 4,0 KiB [ ] /root
e 4,0 KiB [ ] /mnt
e 4,0 KiB [ ] /cdrom
. 0,0 B [ ] /proc
. 0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img.old
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] vmlinuz.old
@ 0,0 B [ ] vmlinuz
Delete the currently highlighted element with d, exit with CTRL + c
There is also a great ncdu
utility - it can show directory size with detailed info about subfolders and files.
Installation
Ubuntu:
$ sudo apt-get install ncdu
Usage
Just type ncdu [path]
in the command line. After a few seconds for analyzing the path, you will see something like this:
$ ncdu 1.11 ~ Use the arrow keys to navigate, press ? for help
--- / ---------------------------------------------------------
. 96,1 GiB [##########] /home
. 17,7 GiB [# ] /usr
. 4,5 GiB [ ] /var
1,1 GiB [ ] /lib
732,1 MiB [ ] /opt
. 275,6 MiB [ ] /boot
198,0 MiB [ ] /storage
. 153,5 MiB [ ] /run
. 16,6 MiB [ ] /etc
13,5 MiB [ ] /bin
11,3 MiB [ ] /sbin
. 8,8 MiB [ ] /tmp
. 2,2 MiB [ ] /dev
! 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
8,0 KiB [ ] /snap
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
! 4,0 KiB [ ] /root
e 4,0 KiB [ ] /mnt
e 4,0 KiB [ ] /cdrom
. 0,0 B [ ] /proc
. 0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img.old
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] vmlinuz.old
@ 0,0 B [ ] vmlinuz
Delete the currently highlighted element with d, exit with CTRL + c
edited Aug 30 '18 at 9:00
Martin Thoma
41.2k54295516
41.2k54295516
answered Sep 14 '15 at 10:12


avtomatonavtomaton
2,9972234
2,9972234
add a comment |
add a comment |
I do the following all the time:
$ du -sh backup-lr-May-02-2017-1493723588.tar.gz
NB:
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
add a comment |
I do the following all the time:
$ du -sh backup-lr-May-02-2017-1493723588.tar.gz
NB:
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
add a comment |
I do the following all the time:
$ du -sh backup-lr-May-02-2017-1493723588.tar.gz
NB:
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
I do the following all the time:
$ du -sh backup-lr-May-02-2017-1493723588.tar.gz
NB:
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
answered May 2 '17 at 11:39


Fokwa BestFokwa Best
1,05521532
1,05521532
add a comment |
add a comment |
You can use below command to get list of files in easily human readable format.
ls -lrtsh
add a comment |
You can use below command to get list of files in easily human readable format.
ls -lrtsh
add a comment |
You can use below command to get list of files in easily human readable format.
ls -lrtsh
You can use below command to get list of files in easily human readable format.
ls -lrtsh
answered Dec 20 '17 at 2:32
AmitAmit
23143
23143
add a comment |
add a comment |
You have to differenciate between file size and disk usage. The main difference between the two comes from the fact that files are "cut into pieces" and stored in blocks.
Modern block size is 4KiB, so files will use disk space multiple of 4KiB, regardless of how small they are.
If you use the command stat
you can see both figures side by side.
stat file.c
If you want a more compact view for a directory, you can use ls -ls
, which will give you usage in 1KiB units.
ls -ls dir
Also du
will give you real disk usage, in 1KiB units, or dutree with the -u
flag.
Example: usage of a 1 byte file
$ echo "" > file.c
$ ls -l file.c
-rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ ls -ls file.c
4 -rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ du file.c
4 file.c
$ dutree file.c
[ file.c 1 B ]
$ dutree -u file.c
[ file.c 4.00 KiB ]
$ stat file.c
File: file.c
Size: 1 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 2185244 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ nacho) Gid: ( 1000/ nacho)
Access: 2018-04-30 20:41:58.002124411 +0200
Modify: 2018-04-30 20:42:24.835458383 +0200
Change: 2018-04-30 20:42:24.835458383 +0200
Birth: -
In addition, in modern filesystems we can have snapshots, sparse files (files with holes in them) that further complicate the situation.
You can see more details in this article: understanding file size in Linux
add a comment |
You have to differenciate between file size and disk usage. The main difference between the two comes from the fact that files are "cut into pieces" and stored in blocks.
Modern block size is 4KiB, so files will use disk space multiple of 4KiB, regardless of how small they are.
If you use the command stat
you can see both figures side by side.
stat file.c
If you want a more compact view for a directory, you can use ls -ls
, which will give you usage in 1KiB units.
ls -ls dir
Also du
will give you real disk usage, in 1KiB units, or dutree with the -u
flag.
Example: usage of a 1 byte file
$ echo "" > file.c
$ ls -l file.c
-rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ ls -ls file.c
4 -rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ du file.c
4 file.c
$ dutree file.c
[ file.c 1 B ]
$ dutree -u file.c
[ file.c 4.00 KiB ]
$ stat file.c
File: file.c
Size: 1 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 2185244 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ nacho) Gid: ( 1000/ nacho)
Access: 2018-04-30 20:41:58.002124411 +0200
Modify: 2018-04-30 20:42:24.835458383 +0200
Change: 2018-04-30 20:42:24.835458383 +0200
Birth: -
In addition, in modern filesystems we can have snapshots, sparse files (files with holes in them) that further complicate the situation.
You can see more details in this article: understanding file size in Linux
add a comment |
You have to differenciate between file size and disk usage. The main difference between the two comes from the fact that files are "cut into pieces" and stored in blocks.
Modern block size is 4KiB, so files will use disk space multiple of 4KiB, regardless of how small they are.
If you use the command stat
you can see both figures side by side.
stat file.c
If you want a more compact view for a directory, you can use ls -ls
, which will give you usage in 1KiB units.
ls -ls dir
Also du
will give you real disk usage, in 1KiB units, or dutree with the -u
flag.
Example: usage of a 1 byte file
$ echo "" > file.c
$ ls -l file.c
-rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ ls -ls file.c
4 -rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ du file.c
4 file.c
$ dutree file.c
[ file.c 1 B ]
$ dutree -u file.c
[ file.c 4.00 KiB ]
$ stat file.c
File: file.c
Size: 1 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 2185244 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ nacho) Gid: ( 1000/ nacho)
Access: 2018-04-30 20:41:58.002124411 +0200
Modify: 2018-04-30 20:42:24.835458383 +0200
Change: 2018-04-30 20:42:24.835458383 +0200
Birth: -
In addition, in modern filesystems we can have snapshots, sparse files (files with holes in them) that further complicate the situation.
You can see more details in this article: understanding file size in Linux
You have to differenciate between file size and disk usage. The main difference between the two comes from the fact that files are "cut into pieces" and stored in blocks.
Modern block size is 4KiB, so files will use disk space multiple of 4KiB, regardless of how small they are.
If you use the command stat
you can see both figures side by side.
stat file.c
If you want a more compact view for a directory, you can use ls -ls
, which will give you usage in 1KiB units.
ls -ls dir
Also du
will give you real disk usage, in 1KiB units, or dutree with the -u
flag.
Example: usage of a 1 byte file
$ echo "" > file.c
$ ls -l file.c
-rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ ls -ls file.c
4 -rw-r--r-- 1 nacho nacho 1 Apr 30 20:42 file.c
$ du file.c
4 file.c
$ dutree file.c
[ file.c 1 B ]
$ dutree -u file.c
[ file.c 4.00 KiB ]
$ stat file.c
File: file.c
Size: 1 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 2185244 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ nacho) Gid: ( 1000/ nacho)
Access: 2018-04-30 20:41:58.002124411 +0200
Modify: 2018-04-30 20:42:24.835458383 +0200
Change: 2018-04-30 20:42:24.835458383 +0200
Birth: -
In addition, in modern filesystems we can have snapshots, sparse files (files with holes in them) that further complicate the situation.
You can see more details in this article: understanding file size in Linux
answered May 3 '18 at 9:27
nachoparkernachoparker
868710
868710
add a comment |
add a comment |
I'm a Ubuntu 16.04 user myself and I find that the ll
command is by far the easiest way to see a directory's contents. I've noticed that not all Linux distributions support this command, but there's probably a workaround/install for each distro out there.
Example:
user@user-XPS-15-9560:/$ ll
total 188
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ./
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ../
drwxr-xr-x 2 root root 4096 Jan 22 15:13 bin/
drwxr-xr-x 4 root root 12288 Jan 29 11:35 boot/
drwxr-xr-x 2 root root 4096 Sep 3 18:14 cdrom/
drwxr-xr-x 20 root root 4440 Feb 5 08:43 dev/
drwxr-xr-x 153 root root 12288 Feb 2 15:17 etc/
drwxr-xr-x 4 root root 4096 Sep 3 18:15 home/
...
The biggest advantage for me is that it's quick and really intuitive to use.
UPDATE: what I didn't know was that on Ubuntu it's a pre-configured alias. You can easily set it yourself by executing alias ll="ls -la"
on the command line, or by adding this entry in your .bashrc config file:
sudo nano ~/.bashrc
...add line described above and save file by pressing Ctrl+X and Y...
source ~/.bashrc
add a comment |
I'm a Ubuntu 16.04 user myself and I find that the ll
command is by far the easiest way to see a directory's contents. I've noticed that not all Linux distributions support this command, but there's probably a workaround/install for each distro out there.
Example:
user@user-XPS-15-9560:/$ ll
total 188
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ./
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ../
drwxr-xr-x 2 root root 4096 Jan 22 15:13 bin/
drwxr-xr-x 4 root root 12288 Jan 29 11:35 boot/
drwxr-xr-x 2 root root 4096 Sep 3 18:14 cdrom/
drwxr-xr-x 20 root root 4440 Feb 5 08:43 dev/
drwxr-xr-x 153 root root 12288 Feb 2 15:17 etc/
drwxr-xr-x 4 root root 4096 Sep 3 18:15 home/
...
The biggest advantage for me is that it's quick and really intuitive to use.
UPDATE: what I didn't know was that on Ubuntu it's a pre-configured alias. You can easily set it yourself by executing alias ll="ls -la"
on the command line, or by adding this entry in your .bashrc config file:
sudo nano ~/.bashrc
...add line described above and save file by pressing Ctrl+X and Y...
source ~/.bashrc
add a comment |
I'm a Ubuntu 16.04 user myself and I find that the ll
command is by far the easiest way to see a directory's contents. I've noticed that not all Linux distributions support this command, but there's probably a workaround/install for each distro out there.
Example:
user@user-XPS-15-9560:/$ ll
total 188
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ./
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ../
drwxr-xr-x 2 root root 4096 Jan 22 15:13 bin/
drwxr-xr-x 4 root root 12288 Jan 29 11:35 boot/
drwxr-xr-x 2 root root 4096 Sep 3 18:14 cdrom/
drwxr-xr-x 20 root root 4440 Feb 5 08:43 dev/
drwxr-xr-x 153 root root 12288 Feb 2 15:17 etc/
drwxr-xr-x 4 root root 4096 Sep 3 18:15 home/
...
The biggest advantage for me is that it's quick and really intuitive to use.
UPDATE: what I didn't know was that on Ubuntu it's a pre-configured alias. You can easily set it yourself by executing alias ll="ls -la"
on the command line, or by adding this entry in your .bashrc config file:
sudo nano ~/.bashrc
...add line described above and save file by pressing Ctrl+X and Y...
source ~/.bashrc
I'm a Ubuntu 16.04 user myself and I find that the ll
command is by far the easiest way to see a directory's contents. I've noticed that not all Linux distributions support this command, but there's probably a workaround/install for each distro out there.
Example:
user@user-XPS-15-9560:/$ ll
total 188
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ./
drwxr-xr-x 27 root root 4096 Jan 26 09:13 ../
drwxr-xr-x 2 root root 4096 Jan 22 15:13 bin/
drwxr-xr-x 4 root root 12288 Jan 29 11:35 boot/
drwxr-xr-x 2 root root 4096 Sep 3 18:14 cdrom/
drwxr-xr-x 20 root root 4440 Feb 5 08:43 dev/
drwxr-xr-x 153 root root 12288 Feb 2 15:17 etc/
drwxr-xr-x 4 root root 4096 Sep 3 18:15 home/
...
The biggest advantage for me is that it's quick and really intuitive to use.
UPDATE: what I didn't know was that on Ubuntu it's a pre-configured alias. You can easily set it yourself by executing alias ll="ls -la"
on the command line, or by adding this entry in your .bashrc config file:
sudo nano ~/.bashrc
...add line described above and save file by pressing Ctrl+X and Y...
source ~/.bashrc
edited May 8 '18 at 8:58
answered Feb 5 '18 at 11:46
MatteusMatteus
578
578
add a comment |
add a comment |
you can use ls -sh in linux you can do sort also
you need to go to dir where you want to check the size of files
add a comment |
you can use ls -sh in linux you can do sort also
you need to go to dir where you want to check the size of files
add a comment |
you can use ls -sh in linux you can do sort also
you need to go to dir where you want to check the size of files
you can use ls -sh in linux you can do sort also
you need to go to dir where you want to check the size of files
answered Mar 17 '17 at 16:32
Prem SPrem S
18218
18218
add a comment |
add a comment |
If you are using it in a script, use stat
.
stat -c %s filename
That will give you size in bytes. See man stat
for more output format options.
add a comment |
If you are using it in a script, use stat
.
stat -c %s filename
That will give you size in bytes. See man stat
for more output format options.
add a comment |
If you are using it in a script, use stat
.
stat -c %s filename
That will give you size in bytes. See man stat
for more output format options.
If you are using it in a script, use stat
.
stat -c %s filename
That will give you size in bytes. See man stat
for more output format options.
answered Nov 20 '18 at 3:39
Bruno BronoskyBruno Bronosky
34k47781
34k47781
add a comment |
add a comment |
go to specific directory then run below command
# du -sh *
4.0K 1
4.0K anadb.sh --> Shell file
4.0K db.sh/ --> shell file
24K backup4/ --> Directory
8.0K backup6/ --> Directory
1.9G backup.sql.gz --> sql file
add a comment |
go to specific directory then run below command
# du -sh *
4.0K 1
4.0K anadb.sh --> Shell file
4.0K db.sh/ --> shell file
24K backup4/ --> Directory
8.0K backup6/ --> Directory
1.9G backup.sql.gz --> sql file
add a comment |
go to specific directory then run below command
# du -sh *
4.0K 1
4.0K anadb.sh --> Shell file
4.0K db.sh/ --> shell file
24K backup4/ --> Directory
8.0K backup6/ --> Directory
1.9G backup.sql.gz --> sql file
go to specific directory then run below command
# du -sh *
4.0K 1
4.0K anadb.sh --> Shell file
4.0K db.sh/ --> shell file
24K backup4/ --> Directory
8.0K backup6/ --> Directory
1.9G backup.sql.gz --> sql file
edited Jan 7 at 7:28
answered Jan 7 at 7:23


sachin_ursachin_ur
312111
312111
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11720079%2fhow-can-i-see-the-size-of-files-and-directories-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown