PDA

View Full Version : [ubuntu] ./ is this necessary?



degarb
February 14th, 2010, 08:43 PM
I love ubuntu's philosophy of helping and making the OS easy to use. Running the computer should be about results, not sophistication of verbose.

I must borrow wife ubuntu laptop, since my desktop is xp pro. Been using dos since early 80s really, and on my machines since 88. Now, I am reading the handbook, about 12 pages a day, trying to memorise things like "rm" since the original 4 decade old terminal design, still in use today, was for pros, not the average Joe, and so never made remove and rm work the same, which would obviate some of the memorisation.

I am posting to point out ./ really means steep learning curve starts here. Since, as I am comprehending it to really mean, is you cannot simply type a program name in the directory you are browsing, unless it is in the path. This is some old limitation of some old design, that should have been fixed long ago. Why? Don't people question these things?

degarb
February 14th, 2010, 08:47 PM
I am also grappling with -l I cannot tell if they mean dash one or dash L. -h for kb and mb, what does h stand for and how do i remember this?

Any mnemonics that other use might help speed mine and others uptake for these terminal commands.

MooPi
February 14th, 2010, 08:49 PM
You would be incorrect in your assumption. If the program is located in /usr/bin, it can be accessed by simply typing the name of the application in terminal. Example: typing
firefox in terminal will start my browser.

da burger
February 14th, 2010, 08:54 PM
Most of this stuff has a reason. "-l" tends to be the letter standing for something like long or list. "-h" stands for human readable so it comes in kb and mb rather than other weird measures.

Regarding ./ this is so the terminal knows where to look for the command. If it is an installed command that will work from anywhere you just use the word on it's own as the command. If you use "./" you are telling it to look in the current working directory. So if I had an executable on my desktop called "test" I would navigate to /home/angus/Desktop and run ./test. But the terminal converts a single dot to the current working directory so it reads as /home/angus/Desktop/test. Hope that helps just a little. If you don't understand something I said just ask.

Angus.

falconindy
February 14th, 2010, 08:56 PM
Running the computer should be about results, not sophistication of verbose.
But this is exactly the case. Notice how system commands try to be short, for example:

rm instead of 'remove' or 'delete'
mv instead of 'move'
cp instead of 'cp'

Options to programs follow the same logic:
-r instead of '--recursive'
-f instead of '--force'

and so on... If you ever find yourself confused about an option flag, use 'man <command>'.

./ is a valid identifier idiom meaning search the current directory that I'm in, and don't search the $PATH, which is the default behavior.

Personally, I've always worked with the mantra that learning the 'why' is more important than just learning the 'how'.

bruno9779
February 14th, 2010, 08:57 PM
As moopi says, you can just write the name of any program in your $PATH


echo $PATH

will show you which folder does that include.

./ is to run any other program. This is very useful in some instances:

eg 1: I have firefox 3.0 and 3.5 installed. 3.5 is default.
as to say, if i write firefox in the terminal, it will open 3.5
Now, if I want or need to run 3.0 i would simply do:


./path-to-FF-3.0/firefox

eg 2: You can run your scripts or programs from any directory by specifying the path to the script. Most often you need to run a command in a different directory that the one it is stored in


It may not be very intuitive at first, but when you get to know bash a bit more, you'll see that most things make a lot of sense

lyall
February 14th, 2010, 09:48 PM
there at a lot of things are carried over for the old day of AT&T Unix
it was made long before the days of DOS

good luck and have fun learning

degarb
February 14th, 2010, 09:49 PM
But this is exactly the case. Notice how system commands try to be short, for example:

rm instead of 'remove' or 'delete'
mv instead of 'move'
cp instead of 'cp'

Options to programs follow the same logic:
-r instead of '--recursive'
-f instead of '--force'

and so on... If you ever find yourself confused about an option flag, use 'man <command>'.

./ is a valid identifier idiom meaning search the current directory that I'm in, and don't search the $PATH, which is the default behavior.

Personally, I've always worked with the mantra that learning the 'why' is more important than just learning the 'how'.


but, why cant you just type remove instead of rm? And are we sure typing filename, wouldn't run a program of a dir I am browsing, if not in path? ./ just seems unnecessary, other than preserving legacy, while just another thing to put a learning curve between a new user and mastery. In windows, it looks locally, then in path variable if not in browsed folder. The windows way is the natural way, so I never thought once about it.

I am supposing that if the Ubuntu community wanted to create a T2, the Terminal V2, with a better protocol, the linux community as whole would have a cow, an understatement. I also suppose this isn't a priority. But pointing out some weakness in what i am learning, which could be fixed or explained, allows me to better accept and learn what I am being taught.

mhh91
February 14th, 2010, 09:57 PM
I don't see a necessity in changing BASH commands,they've been around for a long time,a lot of people got used to them the way they are

and by the way,rm is more practical than typing "remove"

degarb
February 14th, 2010, 10:00 PM
can grep apple *.txt

or is this built into nautalist?

A way to turn off regex? or go to regex light with maybe 5 commands? [Personally, I find regex--too powerful (as in you must wade through tons of crap I would never be interested in to find out a simple everyday task), too many flavors, too hard to do simple things, too expensive are the tools that create regex expression for us. I know most users cannot use it to do even simple things without a college course, and would be hard pressed to recall anything of regex 3 years after said course. ]

falconindy
February 14th, 2010, 10:03 PM
~~The Linux directory system is a messy desk of a genius-- designed in a time where the system ruled the user, and not the user ruling the system. Seriously, consult your elders on this one.
...As if to imply that the file system structure of another OS (which I won't name) has a more logical and sane structure which *never* changes release to release and offered absolute freedom.

The *nix filesystem hierarchy is a godsend.

degarb
February 14th, 2010, 10:15 PM
and by the way,rm is more practical than typing "remove"

For experienced user, yes; for new user, no. Why not just have a policy for both, since a a modern day system op need not be a professional in a home or small business desktop environment? rm may be too obvious for a good example. Anyway, I see if I type rmv file.txt; the bash says "rmv not found but 16 similar found" , but doesn't list those 16 similar.

garyed
February 14th, 2010, 10:18 PM
but, why cant you just type remove instead of rm? And are we sure typing filename, wouldn't run a program of a dir I am browsing, if not in path? ./ just seems unnecessary, other than preserving legacy, .....

Being an old DOS buff myself I understand where you're coming from but if you started with Linux first you might think DOS was doing it wrong.
DOS seems more intuitive searching the current directory without being told & also it doesn't worry about case either. There are things xcopy can do that cp can't but that doesn't make it better, only different. When I first started with Linux someone on this forum told me "if you liked DOS then you'll love Linux" & they were right. It just takes some getting used to.

marlene1950
February 14th, 2010, 10:21 PM
Sorry I am not answering the question that was asked, but I am trying to join the forum but can't find anywhere to start a thread. Can you please help me

Thanks

Marlene

oldos2er
February 14th, 2010, 10:34 PM
If you don't like the way the shell behaves by default, change it; bash is extremely configurable. See http://www.devshed.com/c/a/BrainDump/Executing-Commands-with-bash/

degarb
February 14th, 2010, 10:35 PM
Sorry I am not answering the question that was asked, but I am trying to join the forum but can't find anywhere to start a thread. Can you please help me

Thanks

Marlene

No problem. http://ubuntuforums.org/forumdisplay.php?f=326 there should be a new thread button on left.

I am hoping the forum have proper alt text and non java/scripting ways of things.

degarb
February 14th, 2010, 10:39 PM
If you don't like the way the shell behaves by default, change it; bash is extremely configurable. See http://www.devshed.com/c/a/BrainDump/Executing-Commands-with-bash/
I can't get beyond the ad on this page. Intriguing.,

dullard
February 14th, 2010, 10:43 PM
Being an old DOS buff myself I understand where you're coming from but if you started with Linux first you might think DOS was doing it wrong.

+1

I agree that the syntax is weird at first but you should accept a few challenges when trying a completely different OS. MS-DOS was awful for me when I jumped from AmigaDOS but it became second nature after a while. If anything, in my own experience, the need for dos has declined each time I've switched platforms - but that's laziness on my part I suppose ;o)

oldos2er
February 14th, 2010, 10:47 PM
I can't get beyond the ad on this page. Intriguing.,

I use Noscript and adblock, and recommend them highly.

degarb
February 14th, 2010, 11:48 PM
In windows, if you set attribute read only, you cannot delete the file unless attribute removed. I set permission of a jpg to read only and deleting was instantaneous with nautilist and the delete key, to trash bin.

degarb
February 14th, 2010, 11:54 PM
I use Noscript and adblock, and recommend them highly.


I know when I turn off scripting, the page will be displayed. I bet the author of the page doesn't know his page is hijacked by the ad. The page is worthless to most people, since you cant close the ad that papers over the page.

jwbrase
February 15th, 2010, 12:14 AM
I am posting to point out ./ really means steep learning curve starts here. Since, as I am comprehending it to really mean, is you cannot simply type a program name in the directory you are browsing, unless it is in the path. This is some old limitation of some old design, that should have been fixed long ago. Why? Don't people question these things?

It's not so much a limitation of an old design as it is a philosophical point. The way I've heard it explained is that there are certain mistakes that are easier to make if the working directory is searched without the user specifically telling the shell to search the working directory. I personally don't feel that given my usage habits, I'm likely to make those mistakes, but it *is* configurable.

There are also certain possible security holes it can open up, but I personally find the risk minimal.


but, why cant you just type remove instead of rm?

You can, if you configure things for it. But I think part of the assumption is that if you're bothering to use the command line instead of the GUI, you're already going for speed rather than easy rememberability.

In any case: you can get things set up the way you want as follows:

check to see that "remove" isn't already assigned to anything:


which remove

add "remove" as an alias for "rm" in .bashrc (assuming you're using bash as your shell):


echo 'alias remove="rm"' >> .bashrc

add ./ to your $PATH in .bashrc


echo 'PATH=".:$PATH"' >> .bashrc

Tell bash to reload itself in any open terminal windows so that the settings take effect:


exec bash

Check that path is set properly (it should begin with ".:")


echo $PATH

Check that 'remove="rm"' shows up in the list of aliases:


alias


...As if to imply that the file system structure of another OS (which I won't name) has a more logical and sane structure which *never* changes release to release and offered absolute freedom.

The *nix filesystem hierarchy is a godsend.

For servers and massively multiuser systems, probably. For single user machines (such as laptops or family machines where the family shares one account), and probably also for multiuser systems where one user dominates the use of the machine, I prefer the Windows/DOS system. It gives the user more personal control of the hierarchy, and doesn't separate components of programs from each other. (Of course, more control is also more opportunity to shoot oneself in the foot).

jwbrase
February 15th, 2010, 12:30 AM
In windows, if you set attribute read only, you cannot delete the file unless attribute removed. I set permission of a jpg to read only and deleting was instantaneous with nautilist and the delete key, to trash bin.

Yeah. That is a bit problematic. In fact I just managed to create a read-only file owned by root and send it to the trash bin with a non-root nautilus instance.

Then again, I seem to recall that permissions on deleting and creating files are a matter of the read-write permissions of the folder they're in. So I think if you made a read-only folder, and put a file in it, you would be unable to remove the file.

(Just checked, it works)

jflaker
February 15th, 2010, 12:39 AM
I love ubuntu's philosophy of helping and making the OS easy to use. Running the computer should be about results, not sophistication of verbose.

I must borrow wife ubuntu laptop, since my desktop is xp pro. Been using dos since early 80s really, and on my machines since 88. Now, I am reading the handbook, about 12 pages a day, trying to memorise things like "rm" since the original 4 decade old terminal design, still in use today, was for pros, not the average Joe, and so never made remove and rm work the same, which would obviate some of the memorisation.

I am posting to point out ./ really means steep learning curve starts here. Since, as I am comprehending it to really mean, is you cannot simply type a program name in the directory you are browsing, unless it is in the path. This is some old limitation of some old design, that should have been fixed long ago. Why? Don't people question these things?

Ya know...at one time, someone had to have asked that question when windows came out and hardcore computer users moved from a Unix or even VMS systems....Why is it this way instead of That way?

The biggest complaint from people coming from Windows is why isn't it more like Windows...well....It isn't, it will never be.

HOWEVER....you are welcome to create a few commands that do what you are accustomed to. I like that things are different. It reminds me why I moved away from windows in the first place

Muzer
February 15th, 2010, 12:57 AM
./ is a security feature. Consider the following scenario:

Some ******* placed a file called "ls" in a tarball and made it executable - it contains the following line:


rm -rf ~

(remove, recursing into any subdirectories, forcing delete on any write-protected files, the user's home directory)

You have downloaded that tarball, and cd into its directory. Now you want to see what files are in it, so you type ls. So, bash searches in the PATH, not searching in the current directory, and lists the directory as normal.

Now, suppose bash just ran the file in the current directory instead, for the benefit of people who have come from DOS. It would execute the bogus ls in the current directory, and you would no longer have any of your personal files. This can of course be done easily on DOS/Windows (with dir instead of ls), and is one of the many, many fundamental flaws these OSes have.




If you still don't like ./, you can edit ~/.bashrc and add this line:

PATH=.:$PATH

...but don't say I didn't warn you if something along these lines happens!

oldos2er
February 15th, 2010, 01:01 AM
I know when I turn off scripting, the page will be displayed.

Indeed.

There are many sites explaining bash; I picked that one because it specifically addressed the "./" issue. But, to answer your original question, no, it is only the default action; it is not necessary.

Muzer
February 15th, 2010, 01:03 AM
Most UNIX distros in the early 90s (according to some old documents I've read; I've never actually used anything that early) had the PATH set up as I described in my previous post, but this was changed to its current behaviour due to the security problem I described.

oldos2er
February 15th, 2010, 01:04 AM
In windows


http://linux.oneandoneis2.org/LNW.htm

jwbrase
February 15th, 2010, 01:26 AM
./ is a security feature. Consider the following scenario:

Some ******* placed a file called "ls" in a tarball and made it executable - it contains the following line:


rm -rf ~

(remove, recursing into any subdirectories, forcing delete on any write-protected files, the user's home directory)

You have downloaded that tarball, and cd into its directory. Now you want to see what files are in it, so you type ls. So, bash searches in the PATH, not searching in the current directory, and lists the directory as normal.

Now, suppose bash just ran the file in the current directory instead, for the benefit of people who have come from DOS. It would execute the bogus ls in the current directory, and you would no longer have any of your personal files. This can of course be done easily on DOS/Windows (with dir instead of ls), and is one of the many, many fundamental flaws these OSes have.

That is a risk, but honestly not a very big one. I'd hardly say it's a fundamental flaw. Which isn't to say that Windows and DOS don't *have* fundamental flaws. This just isn't one of them.



If you still don't like ./, you can edit ~/.bashrc and add this line:

PATH=.:$PATH

That should be
PATH=".:$PATH"

Muzer
February 15th, 2010, 01:36 AM
That is a risk, but honestly not a very big one. I'd hardly say it's a fundamental flaw. Which isn't to say that Windows and DOS don't *have* fundamental flaws. This just isn't one of them.


That should be
PATH=".:$PATH"
I meant fundamental in the sense that it can't really be prevented without a major rethink - as opposed to one that can just be patched up.

And you only need the quotes if your $PATH has a space or something in it, and I doubt that is likely...

jwbrase
February 15th, 2010, 01:44 AM
And you only need the quotes if your $PATH has a space or something in it, and I doubt that is likely...

Better safe than sorry.

semi_fiction
February 15th, 2010, 01:46 AM
These bash commands are the heart of the functionality of Ubuntu and Linux in general. If it ain't broke...

mmmichael
February 15th, 2010, 01:58 AM
This is kind of like a football player joining a basketball team and asking, "Is all this dribbling necessary? Can't we just kick the ball? Why should I learn your plays when I know some perfectly good ones?"
Linux and Windows were developed for different purposes and with different presuppositions. There is no reason to expect that they should behave the same way.

Muzer
February 15th, 2010, 02:05 AM
It actually makes sense why they both evolved like they did too - Unix comes from the time when teletypewriters were used to input commands, so the command names were made short - as with command output so as not to waste paper and ink. DOS, on the other hand, was designed for keyboard and screen, so command names are long but easier to remember, and output is more verbose by default (which actually makes it a lot harder to parse; combined with the lack of command-line tools to do so, this is just one reason why DOS command-line is so much more limited).


The reason why most distros nowadays try to avoid too many nonstandard command aliases (like remove for rm in your example), is that when people want to move onto a different distribution the learning curve will be a lot steeper since not only have all the distro-specific commands changed, the ones that are supposed to be standard have different names too. Some distros are still guilty of this though, which is why I try to avoid learning shortcut aliases even if they are available by default (it's too much like hard work adding them back manually to each new distro :p)

degarb
February 15th, 2010, 05:03 PM
combined with the lack of command-line tools to do so, this is just one reason why DOS command-line is so much more limited).



I really respect your contribution. I was racking my brain trying to think of a way for a security concern, but was comming up blank.


Warning, the following is off the thread topic. But interesting.


I suspect the quoted line is totally false, and is a line I have heard over and over. The reason is because dos has been around as a major platform since the 80's with a wider base than unix. Yes, out of the box dos is more limited, but download a few million 5k com helpers and I suspect you dwarf linux in command line power. It is like someone loading Ubuntu and thinking it infinitely more limited than Windows because they haven't discovered the snaptic package manager (especially with univeral turned on.).

I have written the following dos routines in bat format: books on cd rippers, dos mp3 stream rippers, dos weather trackers, dos call waiting disconnect, dos backup routines, and a windows scheduler replacement program. And other's. I did this by finding helpers like Clay dos. Never more than 20k com/exe files, most probably left over, forgotten helpers from the 1980s.

Ultimately, I went from the dos bat to autohotkey for my missing freeware home writes. Autohotkey easy/helpful/extremely powerful is the Ubuntu of the programming world. Infact, the programs I write in AHK are smaller, faster, and more functional at 200k than most at 5 megs. Also, there is little any user must memorize to program in it. Though the more you know, the faster and more powerful you become. But since you can do so much, the memorization comes with doing, and not the doing after the memorization. ex. my latest http://www.autohotkey.net/~degarb/ahkpod/ http://www.autohotkey.net/~degarb/brakedir/

degarb
February 15th, 2010, 05:16 PM
This is kind of like a football player joining a basketball team and asking, "Is all this dribbling necessary? Can't we just kick the ball? Why should I learn your plays when I know some perfectly good ones?"
Linux and Windows were developed for different purposes and with different presuppositions. There is no reason to expect that they should behave the same way.

Football and basketball are games, where challenges make it fun.

An OS is a tool, no different than a handsaw--only more complex. A responsible company needs to adapt their design for ergonomics and innovation. There is such a thing called advancements in a design.

If you just like Linux as a toy or game, that is fine. But think of it the other way, the perspective changes. I see a huge improvement of Ubuntu over other linux distributions. If you view an OS as a game, simplification can take the fun out of things and you will lament any change to the old rules; if viewed as a tool, it is progress.

mmmichael
February 16th, 2010, 03:43 AM
Football and basketball are games, where challenges make it fun.

An OS is a tool, no different than a handsaw--only more complex. A responsible company needs to adapt their design for ergonomics and innovation. There is such a thing called advancements in a design.

If you just like Linux as a toy or game, that is fine. But think of it the other way, the perspective changes. I see a huge improvement of Ubuntu over other linux distributions. If you view an OS as a game, simplification can take the fun out of things and you will lament any change to the old rules; if viewed as a tool, it is progress.

I didn't mean to imply that Linux is a game. I was making an analogy. If I say that "Windows is to Linux as apples are to oranges", I am not saying that an operating system is something you eat.

My point was that making Linux easier for people who are used to DOS is not necessarily the best measure of progress for Linux. Linux doesn't need to be Windows. There are already people selling Windows.

The history of Linux is all about progress and innovation. New tools are being introduced and old ones adapted all the time. I don't think there's much lamentation of changes going on, I think most Linux users appreciate the fact that we are free to experiment and adapt.

sisco311
February 16th, 2010, 04:05 AM
I am posting to point out ./ really means steep learning curve starts here. Since, as I am comprehending it to really mean, is you cannot simply type a program name in the directory you are browsing, unless it is in the path. This is some old limitation of some old design, that should have been fixed long ago. Why? Don't people question these things?

Not adding the current working directory to the PATH is a sane & safe default setting. However, bash (or any other shell) is very flexible & highly customizable; it's very easy to add the current working directory to the PATH variable (personally I would add it at the end of the it ;)).

So, I don't really understand your question. It's a default setting. If you don't like it, change it. It's simple. Isn't it? Or did I miss something?

I do remember how hard it was for me to learn c/c++ after some years of coding in Pascal. Learning Java was relatively easy, but python was a major PITA for me, I don't even want to talk about functional & logical programming languages... find, awk, grep, sed were first intimidating, but interesting tools...

What I learnt is that the syntax doesn't matter, if you understand the basic paradigms of a programming language, shell, OS or whatever... is easy to master it.

If you know what a folder is in Windows than you have a basic concept about what is a directory in Unix/Linux; the same applies to delete - remove - rm , taskbar - panel - doc, dir - ls, file permissions, batch - shell scripting, filesystems, kernel, firewall & so on.

degarb
February 16th, 2010, 04:12 AM
The history of Linux is all about progress and innovation. New tools are being introduced and old ones adapted all the time. I don't think there's much lamentation of changes going on, I think most Linux users appreciate the fact that we are free to experiment and adapt.

I think this is probably more true of Ubuntu users, than in some other distros on Linux.

Just got to be careful that the mantra applies (l. is not w.) and not guarding against change that would be a functional improvement. Once a person gets used to anything, they become blind to it. [ Odd saying, but a lot of truth in it. I just might make that my signature.]

Thus as Ubuntu has a huge newbie base, there are more observations of issues that experienced users might be blind.