Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There are three common command styles: traditional (no dash: c), unix (single dash: -c) and GNU (double dash and long name: --create) and tar supports all three, it is well documented on its man page, and that's where you should look to know which commands support which styles.
Honestly I don't know, I think it has to do with how much the tool has been developed and improved. If you call that improvement.
Maybe also the option parsing tools changed and the tools which use them, or started to now use them, get this change as part of that library. I was never a very big user of the getopt stuff, but I know it's there and probably would use it if I was writing something more complex than I normally do.
I've always typed "tar -xvf" and I had a colleague who shouted that you don't need it if they saw someone doing it. He's correct, but my fingers are "trained" over like 30 years' time.
Maybe experiment? Or view the man pages? That is if you care too. Personally it doesn't fuss me that I use the dash. I suppose if it mandated that I not use the dash, then it would irk me a bit. I'd adapt.
I've always typed "tar -xvf" and I had a colleague who shouted that you don't need it if they saw someone doing it. He's correct, but my fingers are "trained" over like 30 years' time.
Maybe experiment? Or view the man pages? That is if you care too. Personally it doesn't fuss me that I use the dash. I suppose if it mandated that I not use the dash, then it would irk me a bit. I'd adapt.
That was an intolerant or uninformed colleague. Point him to the man pages as well, and let him know your way works too.
As has already been stated, use the man pages. Some (most) commands require the - but some don't and others use it differently. Once you get familiar with each command the usage becomes second nature.
I had a friend that I assisted in switching from windows to linux and he taught me the difference between "ps -aux" and "ps aux" since he read the man page and I, as a creature of habit, had been using it the same as I started many years before. Since then I more often refer to the man pages for usage info.
The - was introduced to distinguish between an option and a filename. No filename starts with a - character. (Well, it could start with a - character, but don't do it!)
The tar program cannot be started without an option, so the developer let it simply pick all the letters from the first argument; a - is not required.
The leading - was added later, to make it compatible with the other programs.
So you can say
tar cf file.tar .
or
tar -cf file.tar .
or
tar -c -f file.tar .
The ps program does not take a filename, so on BSD-Unix the developer let it simply pick the letters from the first argument; a - is not required.
The leading - was added later for compatibility on BSD-Unix.
However, the SysV-Unix had different implementation of the ps program, with the - options.
There are conflicting option letters, for example the e option or the u option.
The GNU/Linux ps wants to be compatible with both BSD and SysV; the solution:
options without a leading - are interpreted the BSD way,
options with a leading - are interpreted the SysV way.
ps e
ps -e
ps u
ps -u user
So in Linux you must do
ps aux
ps -ef
otherwise it might interpret it the wrong way and even issue a warning.
Unfortunately, there's some inconsistency owing to historical baggage (mostly due to BSD vs SYSV differences dating back to the early days), and then there's additional conventions like: -word (X11 long-options) and --word (GNU long-options).
Some developers are a law unto themselves and may ignore all or part of these well established conventions, so you can never assume the correct way to specify options. I'm afraid it's all a bit of a mess at this point.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.