Directory Terminal Commands [SOLVED]

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Oskar1224
Level 5
Level 5
Posts: 693
Joined: Thu Mar 04, 2021 11:55 am
Location: Quebec, Canada

Directory Terminal Commands [SOLVED]

Post by Oskar1224 »

I do have a 12 pages document listing most or all? Terminal commands but honestly I’m lost in there and mostly since I’m a beginner I’m afraid to use commands I don’t really know anything about them. What I want to know is which command will give me a list of programs and their size installed on each of my HDD.

The easy one I know is: lsblk and gives me a list of my HDD
sda = 223GB
sda1 = 28GB
sda2 = 195GB
sdb1 = 149GB
sdc1 = 79GB

But what I want to know is a command(s) to give me a list of programs installed on each HDD including the size of each program like in Windows explorer where you can see all your HDD and programs installed on them.

Thank you
Last edited by LockBot on Wed Feb 08, 2023 11:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Nicolas
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Directory Terminal Commands

Post by Cosmo. »

My times with Windows is far away, but I cannot remember having seen in Windows Explorer a listing of all programs and their sizes.

In Linux programs get stored on a number of places; so you would have to add the needed spaces by your own. Open Synaptic and select an installed package. Now look into the properties -> installed files and see yourself, how the files are distributed in the file system.
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Directory Terminal Commands

Post by mikeflan »

Oskar1224
Level 5
Level 5
Posts: 693
Joined: Thu Mar 04, 2021 11:55 am
Location: Quebec, Canada

Re: Directory Terminal Commands

Post by Oskar1224 »

The Synaptic Package Manager is a good program but you must know which program you want to find details. As I mentioned I have 3 hard disks and when I’m in the Terminal the command

lsblk gives me the list of my disks but which command will give me the contents of one of my disks?

Searching I found many Linux Terminal commands like, pwd, ls, ls –la, cd but I found none for a directory list. Perhaps in Linux this doesn’t exist?
Nicolas
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Directory Terminal Commands

Post by mikeflan »

I found none for a directory list.
Your original post does not ask for this, and I suspect you are not asking for it now:

Code: Select all

find -type d
Nikolai5
Level 4
Level 4
Posts: 309
Joined: Thu Dec 23, 2021 5:25 pm
Location: Northern England

Re: Directory Terminal Commands

Post by Nikolai5 »

Oskar1224 wrote: Mon Aug 08, 2022 10:19 am The Synaptic Package Manager is a good program but you must know which program you want to find details. As I mentioned I have 3 hard disks and when I’m in the Terminal the command

lsblk gives me the list of my disks but which command will give me the contents of one of my disks?

Searching I found many Linux Terminal commands like, pwd, ls, ls –la, cd but I found none for a directory list. Perhaps in Linux this doesn’t exist?
Linux programs are or should be installed within / (The main file system).
So the drive that contains your installation of Linux will be the drive that contains all the installations of programs / applications.
You don't need to know the name of the program in Synaptic, you can filter to show all installed.

Your other drives will be mounted, but applications shouldn't be directly installed to them, they won't be if you installed through apt anyway. Unless you have mounted /usr from another drive and set that up during installation.

I think perhaps we don't understand what results you actually want. Can you give us an example of the information that you want to see? E.g.
Program Name | Install Location | File Size
Is that it?
User avatar
AndyMH
Level 21
Level 21
Posts: 13748
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Directory Terminal Commands

Post by AndyMH »

Want a list of all manually installed packages:

Code: Select all

comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
Doesn't tell you where they are, most executables go in /usr/bin.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Oskar1224
Level 5
Level 5
Posts: 693
Joined: Thu Mar 04, 2021 11:55 am
Location: Quebec, Canada

Re: Directory Terminal Commands

Post by Oskar1224 »

Mikeflan: the code “find –type –d” looks promising and I have to investigate further

Nicolai5: with the info you provided the Synaptic Package Manager now looks very promising and I will have to work on it to learn more about the Synaptic..

AndyMH: sorry but I don’t understand the results of the code you provided

Perhaps what I’m looking for is not available in Linux but as I mentioned what I want is a command or commands which will let me know the contents of programs/files on a HDD.

So the command “cd” which I found in the web is good but they don’t include the parameters. If I type in the Terminals cd what is the parameter to go to my lets say HDD? For example

cd/dev/sda1 (means I want to change my current directory to sda1). What is the proper code?

Then assuming now I’m at my sda1 HDD what will be the command to give me the contents of this disk (files name and size)?

Thank you all
Nicolas
User avatar
AndyMH
Level 21
Level 21
Posts: 13748
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Directory Terminal Commands

Post by AndyMH »

Oskar1224 wrote: Tue Aug 09, 2022 2:51 pm AndyMH: sorry but I don’t understand the results of the code you provided
It gives you a list of all the packages you have manually installed, e.g. using software manager.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
spamegg
Level 14
Level 14
Posts: 5098
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Directory Terminal Commands

Post by spamegg »

Hello Oskar
You asked
cd/dev/sda1 (means I want to change my current directory to sda1). What is the proper code?
I think you have a common confusion that many people have coming from Windows.
On Windows, the name of the drive/device (for example C:\) is also the name of the directory.
That's why you were trying to use cd on a device.
On Linux, a device (such as /dev/sda1) is DIFFERENT than a directory (such as /home/spam).

On Linux, DEVICES get MOUNTED as directories. But devices and directories "look the same" (they are written in a similar way with forward slashes) because of the Linux "everything is a file" philosophy.
So... things that start with /dev like /dev/sda1 etc. are devices and not directories, you cannot "go into" them to see your files.
For that you need to use cd on the mount points.
lsblk gives me the list of my disks but which command will give me the contents of one of my disks?
This is great, because lsblk will show you WHICH DEVICE is mounted at which MOUNT LOCATION:

Code: Select all

 ➜ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 465,8G  0 disk 
└─sda1        8:1    0 465,8G  0 part /media/spam/SAMSUNG850EVO
sdb           8:16   0 238,5G  0 disk 
└─sdb1        8:17   0 238,5G  0 part 
sdc           8:32   0 476,9G  0 disk 
└─sdc1        8:33   0 476,9G  0 part /media/spam/CrucialMX100
nvme0n1     259:0    0 465,8G  0 disk 
└─nvme0n1p1 259:1    0 465,8G  0 part /
As you see I have 4 devices, 3 of which are mounted. So, if I want to see the files on my /dev/sdc1 device, I would use:

Code: Select all

cd /media/spam/CrucialMX100
Oskar1224
Level 5
Level 5
Posts: 693
Joined: Thu Mar 04, 2021 11:55 am
Location: Quebec, Canada

Re: Directory Terminal Commands

Post by Oskar1224 »

Thank you spamegg, your explanation is excellent to make me better understand the Linux files system. So I have to change my thinking about finding files in Linux and along with your example I will also spend more time to understand the Synaptics Package which now looks like a better alternative.
Nicolas
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Directory Terminal Commands [SOLVED]

Post by mikeflan »

cd/dev/sda1 (means I want to change my current directory to sda1). What is the proper code?
Put a space between 'cd' and the directory or mount point. So like:

Code: Select all

cd ~/Documents
what I want is a command or commands which will let me know the contents of programs/files on a HDD.
After you get to the directory that contains your file, to view the file you do:

Code: Select all

xed filename
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Directory Terminal Commands [SOLVED]

Post by Cosmo. »

There is an easier method to quickly view the content of files: Mark the file in the file manager and press the space bar. This is true for Cinnamon, I don't know if it works for Mate or XFCE.
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Directory Terminal Commands [SOLVED]

Post by Termy »

You sound like the target audience for LSPKG. Just know that the installed size is literally the Installed-Size value shared by the control files in the Debian packages themselves, but it's nice for getting a general idea. It's strictly for Debian packages, not Flatpaks, Snaps, AppImages, or any of that stuff; for that, you'd need something with a wider reach.

BTW, ...

Code: Select all

find –type –d
...is invalid, because -d is the short-form flag for -depth, leaving -type without an argument. What you want is:

Code: Select all

find -type d
Sorry if that was already stated.

In Windows, you assign filesystems drive letters; to me, that's akin to the act of mounting a filesystem in Linux. In Linux, when you mount a filesystem, you essentially overlay that filesystem's contents over an existing directory, which is known as a mountpoint. The pre-existing directory's contents doesn't get deleted, BTW; it'll all be there when you unmount the filesystem from that mountpoint.

I know some of that has been explained already, but perhaps a reword might help understanding.

Also, '/dev/sda' is your first storage device, but '/dev/sda1' is the first partition on the storage device. Not all storage devices are given the 'sd' format, such as floppy disks (who even uses those?!), optical drives, and NVMe SSDs. These are essentially representations of those devices — hence being in '/dev'. In Linux, we say "everything is a file", because pretty much everything is essentially a file or represented in that way, allowing for some awesome results.

Regarding the command-line, it's important you understand that spacing is important. Spaces separate commands, arguments, flags, strings, etc. That being said, you don't always require specifically one whitespace — you can, for example, often use a Tab (Literal Tab: Ctrl + V, Tab) to separate two fields, although I don't recommend it.

Another thing which might help you is to know that there are programs (IE: ls), flags/options (IE: --help), arguments (IE, the 'd' in: -type d), expressions, etc. To begin with, you don't have to go too far down the rabbit hole to understand all this, but you should at least learn what a flag/option and an argument is.

The words flag and option tend to be used synonymously. In man pages, you'll see flags shown as options (typically, under the OPTIONS section). This is the same MS-DOS and IIRC, Powershell. In MS-DOS, for example, you could enter dir /C (shows numbers like 1,000,000); granted, I'm not sure you'd call /C a flag, since it doesn't look like one. However, there's a GNU standard, to which some developers don't adhere (IE: those of find); this standard states that you have long-form and short-form flags which look like --zoinks and -z, respectively. The idea is that these flags should do the same thing, affording convenience and potentially clarity. Often, although not always, the letters for the short form flags can be concatenated (stuck together), but not all programs support this (such as LSPKG).

Then you have arguments and fields. Technically, both flags and options are also arguments and fields, but it's a bit on the vague side to call them arguments and fields, so for specificity we tend to say flags or options.

My back's getting sore now, so I'll leave it at that. :lol:
I'm also Terminalforlife on GitHub.
Oskar1224
Level 5
Level 5
Posts: 693
Joined: Thu Mar 04, 2021 11:55 am
Location: Quebec, Canada

Re: Directory Terminal Commands [SOLVED]

Post by Oskar1224 »

It reminds me back in the 80’s when I was learning DOS it was hell with primitive PC’s and no Internet. Now I’m in the same stage with Linux but with better PC’s and the Internet which is a global library of everything. With the info I have now its only time and I will get there.

Thanks to all
Nicolas
Locked

Return to “Beginner Questions”