Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-24-2016, 10:12 AM   #1
LQ Newbie
Registered: Feb 2004
Posts: 12

Rep: Reputation: 0
Command to List All folders Contained in a Specific Partition

Hi everyone,

I've been experimenting with Linux for some time however I still consider myself to be a newbie... I seem to spend far more time in Google than in the terminal!

I've been trying to set up a headless --Ubuntu Server 14.04.3 LTS--. (Non-Production) machine to act as the host for multiple VirtualBox VMs. I intend to set up the server using the concepts described in LHammonds Excellent Guide How to Install and Configure an Ubuntu Server 14.04.1 LTS

The partitioning scheme in his example is as follows:
(Note: The partition sizes shown are my proposed initial settings with lots of unallocated space for future expansion.)

/boot = 0.25 GB (Outside LVM)
/root = 2.75 GB
/swap = 64.00 GB (double the 32GB of RAM)
/home = 300.00 GB (I'm assuming the default location of the VirtualBox VMs will be somewhere under the /home directory)
/tmp = 1.00 GB
/usr = 2.50 GB
/var = 2.00 GB
/srv = 100.00 GB (This will contain the files stored in the Samba share)
/opt = 1.00 GB (This will contain specific software added but may not be utilized at all)
/bak = 500.00 GB (Temp location of LVM Snapshots)

(7TB Unallocated for future expansion)

I'm in the process of installing and configuring the Lab Server and would like to get to know/understand the file structure.

Is there a command that will list all of the folders contained in each of the above INDIVIDUAL partitions?

This will serve two purposes...
a) It will help me ensure the partition that ultimately contains the VM.vmdk files is allocated sufficient disk space.
b) It will help me understand the Linux file structure.

Also, any constructive comments re the proposed partitioning scheme would be welcomed. I would be particularly interested in comments on the /tmp and /bak partition sizes... are they ridiculous or are they reasonable considering the server will only be a host for a max of 10 VMs (I plan to keep a few Operating System ISOs for creating the VMs in the /srv partition.

Please note... I know this system is a complete over-kill for it's intended use... I'm using this structure to to help me learn.

Thank you all (in anticipation for your replies)
Old 02-24-2016, 10:28 AM   #2
Senior Member
Registered: Oct 2003
Posts: 2,474

Rep: Reputation: 189Reputation: 189
$ sudo ls -la <partition mount point>
for a complete listing of the contents of any partition. Entries that start with a "d" are directories. You need to run with sudo because some files or directories in certain locations will not have read access for non-admin users. That will not give a listing of subdirectories however. If you need that you can use the find command:
sudo find <partition mount point> -type d

Last edited by kilgoretrout; 02-24-2016 at 10:51 AM.
Old 02-24-2016, 10:35 AM   #3
Registered: Jan 2012
Location: South Africa
Posts: 481

Rep: Reputation: 179Reputation: 179
Hi there,

To list all of the folders contained in each of the above INDIVIDUAL partitions, I'd suggest you use the "find" command.

Something like this should do:

for partition in /boot /root /swap /home /tmp /usr /var  /srv /opt /bak
    find $partition -xdev -type d -print
To learn about the file system structure, have a look at the Filesystem Hierarchy Standard, available at

Regarding the default location for VMs, yes it us under your home directory. This is a configurable preference, though, so you can keep them anywhere you want. It might make more sense to put this in a more obvious filesystem if its own if that's the main purpose of this server.

Regarding partition sizes, you probably want quite a bit more space in /usr.

Swap space is not in a mounted file system. I hope you never need that much swap space ;-) A single large swap space makes sense if you intend allocating more memory to VMs than your server has, and don't create any swap partitions in the VMs themselves. Alternately you can allocate swap space to each VM in a virtual disk, and keep allocated memory below what you physically have, in which case the host should never swap, and you can keep this much smaller.

Good luck!

Old 02-24-2016, 10:42 AM   #4
Registered: Jan 2012
Location: South Africa
Posts: 481

Rep: Reputation: 179Reputation: 179
Hi again,

Some additional info, after reading kilgoretrout's reply, as I might have misunderstood the requirement ;-)

"ls -a" will list all files & directories in a particular directory. Adding "--recursive" will also list the contents of subdirectories.

My "find" command on the other hand is recursive by default. The "-xdev" option stops it from traversing into filesystems other than the one containing the requested directory. For example, "find / -xdev" will not find files in /usr if that is a separate filesystem. The "-type d" option lists only directories, and not files or other objects (devices, fifos, etc).
Old 02-24-2016, 10:55 AM   #5
Senior Member
Registered: Oct 2003
Posts: 2,474

Rep: Reputation: 189Reputation: 189
I think cliffordw and I have been cross-posting not catching each others edits. The methods are essentially the same but you do need to run with sudo otherwise files and directories that have root only read permissions will not be listed.
Old 02-24-2016, 08:32 PM   #6
LQ Newbie
Registered: Feb 2004
Posts: 12

Original Poster
Rep: Reputation: 0

kilgoretrout & cliffordw... Thank you both very much for your replies, and a special thank you to cliffordw for the extra detail.

Very helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Add up folder sizes in list contained in text file AntBla Linux - Newbie 4 08-09-2014 09:37 AM
Is there any way to scrub specific folders only? dewon73 Linux - Security 1 05-24-2014 12:21 PM
[SOLVED] Get Partition list one Liner Command Fracker Linux - Newbie 8 07-11-2012 12:09 AM
Mount storage partition folders to home folders skykooler Linux - Newbie 4 10-07-2010 11:56 PM
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 05:35 PM

All times are GMT -5. The time now is 08:12 PM.

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