View Drive Contents in A Terminal
View Drive Contents in A Terminal
(OP)
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:
G:
dir
What is the Linux equivalent?
TIA
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:
G:
dir
What is the Linux equivalent?
TIA
RE: View Drive Contents in A Terminal
The brief :
- mount it : mount device_name mount_point
- list it : ls mount_point
- un-mount it : umount mount_point
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 mount command, the other details will be taken from the fstab file.So a typical session for me is something like this :
CODE --> command line
Generally, mounting is a huge subject, but fortunately it can be learned just little by little, on need. See man mount. Just two frequent things to note here :
- With async the writes are not performed immediately, only on umount. ( This was typically used for floppy disks, but be warned anyway : explicit umount is important. )
- umount 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 ).
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
RE: View Drive Contents in A Terminal
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")
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
RE: View Drive Contents in A Terminal
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?
RE: View Drive Contents in A Terminal
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.
RE: View Drive Contents in A Terminal
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
RE: View Drive Contents in A Terminal
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"?
RE: View Drive Contents in A Terminal
1st partition of 2nd 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 1st, b for the 2nd and so on. So hda is the 1st IDE drive, hdb the 2nd 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 1st IDE drive's 1st partition, hda2 the 1st IDE drive's 2nd partition, and similarly for hdb1, hdb2, ... and similarly are sda1, sda2, ... sdb1, sdb2, ...
Feherke.
feherke.ga