Unix vs Linux Commands.. ?

Discussion in 'Mac Programming' started by fab5freddy, Jul 8, 2007.

  1. macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #1
    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!
     
  2. macrumors 6502

    Joined:
    Jun 1, 2006
    #2
    Depends on the command. In most cases they are very similar. Check the man pages to be sure behaviour is the same.
     
  3. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #3
    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.
     
  4. macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #4
    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.
     
  5. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #5
    ok, then what is the best shell for Mac OS X ?
     
  6. macrumors 6502

    Joined:
    Jun 1, 2006
    #6
    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.
     
  7. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #7
    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.
     
  8. macrumors 6502

    Joined:
    Jun 1, 2006
    #8
    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.
     
  9. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #9
    ok, i'm a but lost here. Terminal has not been mentioned at all ??
     
  10. macrumors G3

    Joined:
    May 10, 2004
    #10
    Terminal runs a shell. You define the default shell in the user account.
     
  11. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #11
    ok, so what should i choose in Terminal prefs ?
     
  12. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #12
    /bin/sh is the Bourne shell. no ambiguity there.
     
  13. macrumors G3

    Joined:
    May 10, 2004
    #13
    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.
     
  14. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #14
    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 ?
     
  15. macrumors G3

    Joined:
    May 10, 2004
    #15
    Besides some little place which is amateurish about this issue, they will require years of experience as a Unix/Linux administrator (not developer).
     
  16. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #16
    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. :)
     
  17. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #17
    Hi cube, just curious, do you work in the IT field ?
    seems like you know a bit about this stuff.....
     
  18. macrumors G3

    Joined:
    May 10, 2004
    #18
    The preferences in the Terminal allow you to override the default shell.
     
  19. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #19
    Eeep, you're right! I'd forgotten that was there!
     
  20. macrumors G3

    Joined:
    May 10, 2004
    #20
    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 would help.

    Or also this.

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

    Joined:
    Feb 23, 2006
    #21
    You can't be serious.
     
  22. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #22
    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
     
  23. macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Albuquerque, NM USA
    #23
    /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.
     
  24. macrumors 68000

    Joined:
    Feb 23, 2006
    #24
    True, I make no argument that my post was actually worth the storage in the database. :p
     
  25. thread starter macrumors 65816

    fab5freddy

    Joined:
    Jan 21, 2007
    Location:
    Heaven or Hell
    #25
    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 ?
     

Share This Page