Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Drive Contents in A Terminal 1

Status
Not open for further replies.

AbidingDude

Programmer
Oct 7, 2012
74
0
0
US
Hello, so I'm relatively new to Ubuntu or Linux in general. I have computer skills but they're all Windows based. I'm comfortable doing things from the command prompt, so I'm trying to learn terminal commands in Ubuntu.

I get that Linux doesn't use drive letters. That's fine. Physical devices become abstracted to files. But how do I switch to these devices?

If I plugged in a USB drive in Windows, and wanted to see the contents, suppose it were assigned the drive letter 'G'. I would of course type:

[tt]G:
dir[/tt]

What is the Linux equivalent?
TIA
 
Hi

The brief :
[ul]
[li]mount it : [tt]mount [green]device_name[/green] [green]mount_point[/green][/tt][/li]
[li]list it : [tt]ls [green]mount_point[/green][/tt][/li]
[li]un-mount it : [tt]umount [green]mount_point[/green][/tt][/li]
[/ul]

For convenience you can add a line to your /etc/fstab file specifying the device name and mount point as you prefer, together with the file system on the USB ( or whatever you are mounting ). After that you can specify only the mount point for the [tt]mount[/tt] command, the other details will be taken from the fstab file.

So a typical session for me is something like this :
Code:
[blue]master #[/blue] grep usb /etc/fstab 
/dev/sdb1       /mnt/usb        vfat    user,users,noauto       0       0

[blue]master #[/blue] mount /mnt/usb

[blue]master #[/blue] ls -l /mnt/usb
-r-xr-xr-x 1 master master 225 Jan  4 1980 AUTORUN.INF

[blue]master #[/blue] umount /mnt/usb

Generally, mounting is a huge subject, but fortunately it can be learned just little by little, on need. See [tt]man mount[/tt]. Just two frequent things to note here :
[ul]
[li]With [tt]async[/tt] the writes are not performed immediately, only on [tt]umount[/tt]. ( This was typically used for floppy disks, but be warned anyway : explicit [tt]umount[/tt] is important. )[/li]
[li][tt]umount[/tt] can not be performed while the file system is in use. So you have to stop processes that opened files on the device ( or even just changed directory to it ).[/li]
[/ul]

There are ( were ? ) some tools to simplify this for newbies, like automount and supermount, but I never installed such thing, so can not provide further information on them.

Feherke.
feherke.ga
 
What is the Linux equivalent?

ls (short for list)

ls -l will show the list in a similar format to the dir command

ls -lh will show the sizes in KB/MB etc (-h = "human readable")



But how do I switch to these devices?
Exactly the same way as in DOS only with the device name or the mount point name instead of the drive letter.

eg:
cd /[NAME]/folder/

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks, but I'm still a little lost. I'm still unfamiliar with a lot of the operating system terminology. What is a "mount point"?

I'm trying to make my way through the 'mount' man pages, but it's not as helpful as I hoped. I need to learn more lingo.

Also, for the parameter listing, you had:
mount device_name mount_point

Do I invent a "device name" to give it or is it something I need to reference?
 
I'll do my best from Unix.
Access is through filesystems. Your windows (or DOS) equivalent drive would generally have several filesystems created on it. You can see those filesystems by using the command l or ls from the root of the drive. Under those file systems there will be directories, most of which can be used as mount points if you wish to use them and don't mind losing temporarily what was there before the new divice took their place.

In my unix stuff I generate a /cd0, a /fd0, and a /temp directories in the root filesystem. (mkdir cd0)(mkdir fd0)(mkdir temp)
because I have a cd available (discovered and linked at bootup) I can use it by:
mount /dev/cd0 /cd0. I also have a floppy /dev/fd0 although it may have several other ways of being identified and mounted. You can see the possibilities by viewing:
ls /dev/fd*.
the /dev/cd0 is the device driver for the cd and the /cd0 is the mount point. At the completion of the mount command doing a l or ls /cd0 will show the contents of the CD.

You have a change directory the same way you operate in command prompt with windows.
To do the equivalent of cd \ to get to the root of C: you would do cd / to get to the root of the Linux drive. to get to the CD would be cd /cd0. For the temp directory
cd /temp. To copy from the CD to the /temp directory would be cp /cd0/filename /temp.
deleting would be rm /whereitis/filename.
Unmounting can be by device name or the mount poing.


Ed Fair
Give the wrong symptoms, get the wrong solutions.
 
Many modern Linux distros will automatically mount removable media when inserted

this is usually /media/<name of device> but can vary

mount without any parameters should give you a list of all the currently mounted devices.




A Maintenance contract is essential, not a Luxury.
Do things on the cheap & it will cost you dear
 
IPGuru said:
Many modern Linux distros will automatically mount removable media when inserted

this is usually /media/<name of device> but can vary

mount without any parameters should give you a list of all the currently mounted devices.

That seems to be the case with me. I went to that, and successfully listed the files on the device.

So I just tried plugging in a couple things. I plugged in an external USB CD drive and USB flash drive. I went to /media and saw the folder populated with the devices I plugged in. Cool.
Then I ran "mount" with no parameters to see the list that pops up. The line pertaining to my USB flash drive said:
/dev/sdb1 on /media/DOC_BACKUP type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks)

I have no idea what the stuff in parentheses is, but I somewhat get the first part of the line. I know that "dev" is short for "device", right? But I'm curious as to why there are apparently two references to it. If I access my files through /media/<whatever>, what is "sdb1"?
 
Hi

AbidingDude said:
what is "sdb1"?
1[sup]st[/sup] partition of 2[sup]nd[/sup] SATA drive.

In /dev/ you may find hd* files for each IDE drive and sd* files for each SATA drive.
As there may be multiple drives, each get an alphabet letter starting from a for the 1[sup]st[/sup], b for the 2[sup]nd[/sup] and so on. So hda is the 1[sup]st[/sup] IDE drive, hdb the 2[sup]nd[/sup] IDE drive, and similarly are sda, sdb, ...
As each drive may be partitioned, beside the files pointing to the drives, there are also files for each partition on them, marked with integer numbers starting from 1. So hda1 is the 1[sup]st[/sup] IDE drive's 1[sup]st[/sup] partition, hda2 the 1[sup]st[/sup] IDE drive's 2[sup]nd[/sup] partition, and similarly for hdb1, hdb2, ... and similarly are sda1, sda2, ... sdb1, sdb2, ...


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top