PDA

View Full Version : Unix vs Linux Commands.. ?




fab5freddy
Jul 8, 2007, 10:01 AM
i am currently learning Linux commands, and was wondering if they are the same as unix / darwin commmands ? so i could use them in Terminal ?

thanks!



antibact1
Jul 8, 2007, 10:28 AM
Depends on the command. In most cases they are very similar. Check the man pages to be sure behaviour is the same.

jsw
Jul 8, 2007, 10:31 AM
Also be sure you're using the same shell (bash, csh, etc.), as that will affect a number of things as well.

I agree with antibact1 - most commands work the same way.

savar
Jul 8, 2007, 10:59 AM
i am currently learning Linux commands, and was wondering if they are the same as unix / darwin commmands ? so i could use them in Terminal ?

thanks!

Most of the "commands" are actually just programs. When you type "ls", for example, you're running a program which figures out your current directory, then goes to the filesystem and prints out all the file names.

So by tradition most of the commands are the same because people building the different variants of unix and linux didn't want to re-learn a bunch of new commands.

Having said that, there are places where the new designers thought they could do it slightly better, and this is where most of the differences between these OSes arise from. The most evil consequence of this is finding that commands are named identically on two different systems, but actually behave slightly differently.

To offer one random example: on my Mac (and most linux also) I can use the "-R" flag in grep to search recursively, but on my Solaris server at work grep doesn't support this flag.

The bright side of things is that since most of this stuff is open source, if you find yourself missing a command that you learned/used somewhere else, you can try to find the source code and compile it yourself.

fab5freddy
Jul 8, 2007, 10:59 AM
ok, then what is the best shell for Mac OS X ?

antibact1
Jul 8, 2007, 11:50 AM
There isn't really a best shell per-se, just different ones. The default OS X shell is bash, but also available is csh, ksh, tcsh and zsh. Common on Linux is bash, so you may want to stick with that if you are doing any shell programming.

Keep in mind, unless you are writing shell programs, the particular shell you are using isn't to have any effect on the program (ie. ls is ls regardless of the shell). With that said, things such as output redirection vary depending on the shell.

mkrishnan
Jul 8, 2007, 12:11 PM
Keep in mind, unless you are writing shell programs, the particular shell you are using isn't to have any effect on the program (ie. ls is ls regardless of the shell).

Even then, isn't it fairly easy to define the shell at the beginning of the script, using a line like:

#!/bin/bash

And also good practice?

I also think it's best to stick with bash, though... it doesn't seem like it's quite so common for OS X users to switch around between shells as it is in other *nix environments.

antibact1
Jul 8, 2007, 12:23 PM
Even then, isn't it fairly easy to define the shell at the beginning of the script, using a line like:

#!/bin/bash

And also good practice?

I also think it's best to stick with bash, though... it doesn't seem like it's quite so common for OS X users to switch around between shells as it is in other *nix environments.

Using #!/bin/bash is definitely a good practice. A lot of people use #!/bin/sh which is commonly a symlink to the default shell, so there is no way to know what you're getting.

fab5freddy
Jul 8, 2007, 12:44 PM
ok, i'm a but lost here. Terminal has not been mentioned at all ??

cube
Jul 8, 2007, 12:52 PM
Terminal runs a shell. You define the default shell in the user account.

fab5freddy
Jul 8, 2007, 01:00 PM
ok, so what should i choose in Terminal prefs ?

zimv20
Jul 8, 2007, 01:17 PM
A lot of people use #!/bin/sh which is commonly a symlink to the default shell, so there is no way to know what you're getting.
/bin/sh is the Bourne shell. no ambiguity there.

cube
Jul 8, 2007, 01:26 PM
ok, so what should i choose in Terminal prefs ?

Scripting is different from interactive use regarding what you find more practical, so it's a personal choice.

Personally, I can't stand the normal Unix shell syntaxes, so I prefer scsh for any nontrivial scripts, but I just use bash or tcsh interactively.

fab5freddy
Jul 8, 2007, 01:49 PM
this is a little off the topic, but how much unix / linux do you have to know to get a job as a server administrator ?

cube
Jul 8, 2007, 01:53 PM
Besides some little place which is amateurish about this issue, they will require years of experience as a Unix/Linux administrator (not developer).

mkrishnan
Jul 8, 2007, 02:10 PM
ok, so what should i choose in Terminal prefs ?

Terminal prefs just controls the way the window looks -- how many lines, is it transparent, what is the default font / color / size, does the cursor blink, etceranda. It has nothing really to do with any of this. If you decide to stick with bash, you don't do anything. You're already in bash. If you decide you want to change the default shell, this tutorial explains that and a wealth of other things:

http://www.macdevcenter.com/pub/a/mac/2005/05/20/terminal1.html

So it's a good place to start. :)

fab5freddy
Jul 8, 2007, 02:10 PM
Hi cube, just curious, do you work in the IT field ?
seems like you know a bit about this stuff.....

cube
Jul 8, 2007, 02:23 PM
Terminal prefs just controls the way the window looks -- how many lines, is it transparent, what is the default font / color / size, does the cursor blink, etceranda. It has nothing really to do with any of this.

The preferences in the Terminal allow you to override the default shell.

mkrishnan
Jul 8, 2007, 02:24 PM
The preferences in the Terminal allow you to override the default shell.

Eeep, you're right! I'd forgotten that was there!

cube
Jul 8, 2007, 02:48 PM
About how people start: sometimes developers get part-time admin duties in some small place, there are also interships, or maybe you could get even a junior position.

Getting a PC with OpenSolaris or Solaris Express and this (http://www.sun.com/training/certification/solaris/scsa.xml) would help.

Or also this (https://www.redhat.com/training/rhce/courses/).

But the courses are not cheap. Maybe you should look in Amazon for certification guides.

SC68Cal
Jul 8, 2007, 03:40 PM
You can't be serious.

mkrishnan
Jul 8, 2007, 04:57 PM
You can't be serious.

I think that's the place to start to become a sysadmin... not the place to start to just use Terminal. ;) :eek:

My response had (hopefully clearly) been more about how to get started using terminal commands in OS X. I don't think that tutorial will make anyone ready to be a sysadmin. :D

sfisher
Jul 8, 2007, 05:23 PM
Using #!/bin/bash is definitely a good practice. A lot of people use #!/bin/sh which is commonly a symlink to the default shell, so there is no way to know what you're getting.

/bin/sh either gives you the traditional bourne shell or the bourne again shell (bash). Bash is backwards compatible with sh. I have never seen a system that gives you anything else.

SC68Cal
Jul 8, 2007, 05:27 PM
My response had (hopefully clearly) been more about how to get started using terminal commands in OS X. I don't think that tutorial will make anyone ready to be a sysadmin. :D

True, I make no argument that my post was actually worth the storage in the database. :P

fab5freddy
Jul 9, 2007, 04:38 AM
hi SC68Cal, just wanted to ask you about what skills you need to get a job as a system adminstrator / server administrator ?

what should i learn first Windows Servers or Linux / Unix Servers ?

casperghst42
Jul 9, 2007, 07:28 AM
i am currently learning Linux commands, and was wondering if they are the same as unix / darwin commmands ? so i could use them in Terminal ?
thanks!

OSX is Unix (posix), and Linux is actually GNU/Linux. Commands on GNU/Linux can normally do what a Unix command can do, but because GNU had to reimplement many of the commands (license issues), then also sometimes have added an option or two which does not exist on Unix. I normally write my scripts on OSX and then move them to GNU/Linux as I then know that they should work, the other way around gives me too much gray hair.

Casper

Fairly
Jul 10, 2007, 05:08 AM
OSX is Unix (posix), and Linux is actually GNU/Linux.
Thanks for clearing that up. :D