1

I've been using linux for quite some time now and I have a question burning in my head. I'll use the mount command as an example.

When you see the manpages of mount it says that you use the command like this: mount $type $drive $dir where $drive is the drive you want to mount $type is that drive's type and $dir is the directory where you will mount it.

As far as what to put in $drive and $dir variables, it's pretty easy to tell. Now in the $type variable you can't just put whatever you like, because the system won't understand it. You have to use premade words like vfat, ext3, auto etc.

And here is my question: for every command that requires this kind of premade words to fill in a variable space, how do I know what options do I have? Where can I see a list of all the options I have for this kind of variables?

And mount is just one command, there are countless others like this one witch require a word from a set of premade words to work. As far as I can tell there is no such list in the manpages or in some obvious website.

2
  • 2
    Use the manual command to get information: man mount. Commented Jan 28, 2016 at 16:36
  • Please edit this question to change witch to which and consider wrapping all variables in backticks for inline code formatting. Commented Nov 18, 2021 at 7:08

3 Answers 3

3

There's no general way, especially for extensible programs like mount.

For mount, the -t foo option tells mount to run a mount.foo command. This depends on what you have installed. For example, I can use the following options for mount:

ceph  cifs  fuse  fuse.ceph  lowntfs-3g  nfs  nfs4  ntfs  ntfs-3g

Why? Because I have the following helpers for mount installed:

$ ls /sbin/mount.*
/sbin/mount.ceph       /sbin/mount.cifs        /sbin/mount.fuse
/sbin/mount.fuse.ceph  /sbin/mount.lowntfs-3g  /sbin/mount.nfs
/sbin/mount.nfs4       /sbin/mount.ntfs        /sbin/mount.ntfs-3g

In general, though, there's no way to know what you can run for a given command, especially if it can make use of external programs like mount does.

1
  • I didn't know that there is such a thing like extensible programs! Now a lot more make sense. It's kinda sad that there isn't a huge database in the internet with everything that everyone has ever put out there! Commented Jan 29, 2016 at 12:59
2

Usually you have two options:

  1. One is to study the source for each command you want to know which probably would not be a good idea (actually it is if you want to know the inner workings, but you know, time-wise ;)) since it take countless hours.

  2. The second and more viable option is to study the manual either using man or info which could give you detailed explanation of all the options and parameters.

2
  • 4
    I would definitely reorder the two options so that man and info are listed first. They are the best and easiest places to start Commented Jan 28, 2016 at 17:07
  • 1
    In my experiance, man and info don't give you the list of parameters. But what you said about the code is gold! So to clarify i use the whereis command to find the piece of code that is executed and then I just open the file with some file reader like emacs or vim or something else? Commented Jan 29, 2016 at 12:57
1

As far as I can tell there is no such list in the manpages (…).

Even in the very special case of mount (muru explaines why) actually the manpage helps a lot:

-t, --types fstype
  The argument following the -t is used to indicate the filesystem type.
  The filesystem types which are currently  supported depend on the running
  kernel. See /proc/filesystems and /lib/modules/$(uname -r)/kernel/fs for
  a complete list of the filesystems. The most common are ext2, ext3, ext4,
  xfs, btrfs, vfat, sysfs, proc, nfs and cifs.

It doesn't only list the most common arguments, but also points to /proc/filesystems (which is a file, so we'll use cat) and /lib/modules/$(uname -r)/kernel/fs (which is a directory, so we'll use ls). Combined this provides you the full list of arguments usable on your specific system.

Normally, man and/or info either contain the full list of possible arguments to an option or (like in your example) point you to other sources where you get this information. To search for an option in an extensive manpage the search function comes in handy, just type e.g. /--types, hit Enter to search for the first occurence and N to go through the following ones.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.