LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2011, 08:00 AM   #1
joham34
Member
 
Registered: Oct 2009
Location: Greece
Distribution: ubuntu 18.04
Posts: 89

Rep: Reputation: 4
how can I see properties of a directory using command line?


Hi everybody
I am struggling to learn the command line, and am stuck to the following
In my directory ~/Music , I have many music archives , total about 0,8 Gbyte .
Yet , changing to this directory ) and giving ls -dlh , I get

ioannis@ioannis-laptop:~/Music$ ls -ldh
drwxr-xr-x 4 ioannis ioannis 4.0K 2011-03-04 14:55


So, only 4 k size and no info about the number of the files in the dir
Any hint would be very appreciable

Last edited by joham34; 03-04-2011 at 08:10 AM.
 
Old 03-04-2011, 08:04 AM   #2
vitorsgoncalves
Member
 
Registered: Mar 2010
Posts: 96

Rep: Reputation: 18
try ls -l
 
Old 03-04-2011, 08:08 AM   #3
truboy
Member
 
Registered: Oct 2010
Location: Switzerland
Posts: 84

Rep: Reputation: 9
Quote:
Originally Posted by joham34 View Post
... and giving ls -dlh ...
Quote:
Originally Posted by vitorsgoncalves View Post
try ls -l
That's what he did !

To get the size of the directory :
Code:
du -sh directory/
 
Old 03-04-2011, 08:15 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
To the kernel, a directory is a file, containing a table of filenames and inode numbers. So the size given is the size of this file.

The "-d" option you used with the "ls" command tells the ls command that you want to look at the properties of the directory itself. You would use "-ld" to check the ownership and permissions of a directory. You could use 'ls -d */' to display a listing of just directories.

Last edited by jschiwal; 03-04-2011 at 08:16 AM.
 
1 members found this post helpful.
Old 03-04-2011, 08:49 AM   #5
truboy
Member
 
Registered: Oct 2010
Location: Switzerland
Posts: 84

Rep: Reputation: 9
Quote:
Originally Posted by jschiwal View Post
To the kernel, a directory is a file, containing a table of filenames and inode numbers. So the size given is the size of this file.
Then would the size of a directory containing billions and billions of files/directories be more than the usual 4ko ?
 
Old 03-04-2011, 09:16 AM   #6
mikey99
Member
 
Registered: Nov 2008
Location: UK
Distribution: RHEL, Fedora
Posts: 68

Rep: Reputation: 12
Quote:
Originally Posted by truboy View Post
Then would the size of a directory containing billions and billions of files/directories be more than the usual 4ko ?
Of course. Try this...

mkdir test
touch test/filename{1..1000}
ls -ld test

A directory is a file containing filename to inode mappings. Lots of files means a large directory file.
 
2 members found this post helpful.
Old 03-04-2011, 10:35 AM   #7
joham34
Member
 
Registered: Oct 2009
Location: Greece
Distribution: ubuntu 18.04
Posts: 89

Original Poster
Rep: Reputation: 4
THank you for you replies. I have read about du command but thought I did something wrong with ls command . To be honest I would expect a command to get the usual infos about a dir (including size and number of files) through the command line. It is done easily through GUI just by right clicking.
I am charmed about the beauty and power of the command line anyway
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command line 'last directory' button? CQ1ST Linux - Newbie 6 08-09-2010 03:28 PM
Passing directory name as a command line argument adilwaheed Linux - Newbie 4 03-12-2009 03:01 PM
how do I specify the current directory on the command line powerpleb Linux - Newbie 3 06-11-2008 05:28 AM
Opening a directory in command line Yash Pal Linux - Newbie 8 07-27-2007 03:45 AM
share a samba directory with the command line Mugatu Linux - Software 2 01-08-2004 01:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration