I want to learn Unix

Posted:
in macOS edited January 2014
I want to learn some Unix commands so that I can take full advantage of OS X. I'm really into computers and have done some coding (mostly on windows using Visual Basic and C+) I would really like to learn some stuff for the Mac. I want to be able to use the terminal, Are there any books out there that would help me at all? Thanks for your input.
«1

Comments

  • Reply 1 of 28
    Awesome! But best of all, your best resource for learning *nix is the internet, namely google. There's all kinds of gold, I don't know where to start!



    Maybe start with bash scripting? It easy, fun, very flexible and powerful. Type 'bash scripting' into google. BTW, while TCSH is the default shell with 10.x, 10.3 will be bash (by default, that is), at long last.



    Edit: In fact, search these forums for bash scripting, so as to save us all the trouble of repeating ourselves.
  • Reply 2 of 28
    There's a nice O'Reilley book: Unix Power Tools.
  • Reply 3 of 28
    scottscott Posts: 7,431member
    People think I'm being mean when I say this but I'm not.



    RTFM.



    Read the man pages. If you want to be good at Unix you have to learn how to read the man pages.



    >man csh

    >man ls

    >man sed

    >man grep

    >man rm

    >man pwd

    >man cd

    >man chown

    >man everything





    read the man pages before you ask a question.
  • Reply 4 of 28
    Quote:

    Originally posted by Scott

    >man everything





    Code:


    [mgaiman@Archy:~][1]%man everything

    No manual entry for everything







    just had to check to make sure
  • Reply 5 of 28
    I disagree with Scott's homoerotic suggestions. I find (admittedly, particular) man pages somewhat confusing and unclear. I like to see practical examples, besides which manning everything in /bin /usr/bin /sbin etc would take (IMHO) far too long.



    Man's great and all, and comes in handy, but I don't think it's the way for a n00b to get to know Unix in any detail.
  • Reply 6 of 28
    lucaluca Posts: 3,833member
    I have used the terminal a bit myself, mainly for forcing the deletion of problematic files and also for altering my hosts file with Pico. I have some experience (not a lot, mind you) and I find all the man pages very confusing. I haven't seen one that I understand yet. It's just techno-speak. I think it's better suited to someone who knows ther terminal quite well and just can't always remember all the additional commands (I don't remember what they're called, they are tacked on to the end of a normal command, like ls -v or sudo rm -r).
  • Reply 7 of 28
    OReilly do whole range of OS X flavour Unix related books. Check them out - they are the best.



    You could also install the developer tools - they come with a lot of documentation, some of which is Unix specific.
  • Reply 8 of 28
    Quote:

    Originally posted by Luca Rescigno

    (I don't remember what they're called, they are tacked on to the end of a normal command, like ls -v or sudo rm -r).



    they're called arguments (args), or sometimes `options'.



    Theres a couple of things you should know when getting started on the unix underpinnings. First, just about everything you do in Terminal (or another terminal emulator) is first being parsed by the 'shell'. There are several shells available on your computer (and more on the internet), but by default your shell is 'tcsh' (as leet pointed out). ANother thing you should know about the command line (sometimes called the "CLI" or command line interface), is that when you type in a command (like 'man everything'), the shell reads that, and then searches your PATH for the command. Your PATH is an "environment variable". All posix-compliant systems (unixes, and unix-like system, including OSX), have a set of keys with values associated with them, called the environment. You can view the full environment of (case sensitive) keys and values with the 'set' command. The PATH variable (key), has a value which is a number of paths, separated by colons, where programs tend to reside. If you type 'echo $PATH' you can see just what your PATH's value is. The shell searches through each of those paths for the `man' command, then starts that program, with whatever args you write after it. So, if you want to find out exactly what you can do on the cli, you can look at your PATH, then investigate each of those folders for commands.



    So, if you PATH equals '/bin:/sbin:/usr/bin:/usr/sbin' then you would look in the /bin, /sbin, /usr/bin and /usr/sbin folders. The majority of commands won't be immediately useful, and most will probably be too advanced or complicated for a beginner, but those are basically your options from the cli. You can usually man each of them (as Scott pointed out with some examples), but you may find that some (or many) of the commands do not have man pages; most do though.



    You should take the time to learn about your shell (tcsh), ls, cd, pwd, cp, mv, and rm and some of the others that Scott mentioned to get started. 'ls' shows you the contents of a folder (without args it shows the current directory's contents). 'cd' changes the current directory. 'pwd' prints the full path of the current directory. 'cp' copies a file (or a number of files) to somewhere. 'mv' renames, or moves, a file. 'rm' removes one or more files. You can type 'man <command name>' (replacing <command name> as appropriate) to get a lot of information about the commands. Man pages are a bit taunting to a beginner, but they have a lot of information. They usually mention the name of the command, the synopsis shows how to run the command, and the description section usually explains what each of the args means. Many man pages also have a 'See Also' section near the bottom of their man page, pointing to related information.



    I think the toughest part of the man page to overcome is understanding the synopsis, the section where they show examples of how to run the command. The often have bracketed words, and words in angle brackets, and elipses, and other things which aren't supposed to be used literally. Brackets ([, ]) mean that the stuff is optional. Angle brackets (<, >), mean its required. Elipses usually mean that the preceeding item can be repeated. For example, in my man page for 'ls' the synopsis looks like this:

    ls [OPTION]... [FILE]...

    This means that OPTIONs and FILEs are optional. The ls command is valid without any args. Options tend to be in a dash-letter format (like -a, -r, -x). The FILE part means, replace with the name of a file. So you can do 'ls myDocumentName'. One of the options for ls is '-l', so you can do 'ls -l', or even 'ls -l myDocumentName'. Some commands allow you to add two options together, with only one dash, like this 'ls -lS'. Not all commands allow you to do that though.



    If you have any questions, feel free to ask.
  • Reply 9 of 28
    pbg4 dudepbg4 dude Posts: 1,611member
    To find out all of the shell's settings, use the env (environment) command. This will give you your path, home directory, and a whole bunch of settings that will become useful as you learn more about *nix.



    Another cool thing if you are doing any C/C++ coding is the unix standard libraries all have man pages. So you can type

    man scanf

    and get information on what header file needs to be imported, etc.



    As far as books are concerned there are tons out there. I was in Borders last weekend, and counted a few OS X - Unix specific books. There were also tons of generic Unix books out there as well but you can save yourself cash by searching out Unix primers on the internet.



    Here's a place to start -> http://www.agecon.ucdavis.edu/unix_doc/tutor.html
  • Reply 10 of 28
    Quote:

    Originally posted by thuh Freak

    I think the toughest part of the man page to overcome is understanding the synopsis, the section where they show examples of how to run the command.



    IMO, the biggest problem of most man pages is the absence of any real examples. What you call 'examples' is just the specification, which is typically very hard to read.



    For this reason, I mentioned the 'UNIX Power Tools' book earlier in this thread. It's also a part of the O'Reilly Unix CD Bookshelf. It's very handy as a reference book. The chapters are organized by tasks you want to do. E.g. 'Part IV: Looking Inside Files' contains chapters like

    'Chapter 27: Searching Through Files' and here you find information about grep and similar tools.
  • Reply 11 of 28
    It should be noted that with Panther the default shell is being switched from TCSH to BASH.
  • Reply 12 of 28
    Unix for Dummies is a great book, but not Mac specific.



    Unix for Mac OS X though is most likely the best book I've read for someone wanting to move from Aqua to messing with the terminal. It is by Matisse Enzer and published by Peachpit Press.
  • Reply 13 of 28
    Quote:

    Originally posted by Brad

    It should be noted that with Panther the default shell is being switched from TCSH to BASH.



    Scoundrels, what were they thinking??? They might have well as changed it to Korn! <sigh> one more thing I'll have to change after install...
  • Reply 14 of 28
    Quote:

    Originally posted by Chealion

    Unix for Dummies is a great book, but not Mac specific.



    Unix for Mac OS X though is most likely the best book I've read for someone wanting to move from Aqua to messing with the terminal. It is by Matisse Enzer and published by Peachpit Press.




    I've got that one. I must say it's a pretty good book!
  • Reply 15 of 28
    Thanks everyone for your great advice. I'm gonna check the net and see if I can find some stuff to get me started and pick up a book later. Thanks again!
  • Reply 16 of 28
    By the way, what do ya'll use Unix for? Just wondering what some of the basic functions and stuff like that is.
  • Reply 17 of 28
    Quote:

    Originally posted by DMBand0026

    By the way, what do ya'll use Unix for? Just wondering what some of the basic functions and stuff like that is.



    It's not what do you use Unix for, its what DON'T you use unix for! I find unix platforms are very reliable for development, and you can get all sorts of cool services up and running for free, like mail servers, proxy servers, web servers, ssh servers etc etc etc... I just find it much more flexible for all the cool geeky things one might want to do.



    And that's where Mac OS X shines, after playing with the source code for the new, hot Application X you can just fire up Microsoft Werd hehe and read some crappy documents that your Uni/workplace sent you
  • Reply 18 of 28
    scottscott Posts: 7,431member
    Quote:

    Originally posted by 1337_5L4Xx0R

    I disagree with Scott's homoerotic suggestions. I find (admittedly, particular) man pages somewhat confusing and unclear. ...



    I couldn't disagree with you more. Just yesterday I was trying to learn how to manage the batch ques in VMS. Yea that's right, VMS. So I read the help pages. Tried to do it on my own. Learned as much as I could. So when I went to another user to get the answer I knew just a tad bit more than nothing. So when he provided the answer I was able to fit it in with what I read in the help pages and as such I know more than if I hadn't read them.





    The man pages are not easy but reading them is always a good idea.
  • Reply 19 of 28
    HMUG (Huntsville Macintosh User Group) has the man pages on the web.



    http://www.hmug.org/man/



    I find that is easier to browse different commands then going to /usr/bin, entering ls, and using man to figure out what this "qdiv" is.
  • Reply 20 of 28
    Quote:

    Originally posted by DMBand0026

    By the way, what do ya'll use Unix for? Just wondering what some of the basic functions and stuff like that is.



    I use for ssh to a linux server, to move from around the file system in a snap, for copying, renaming, compressing, editing HTML and PHP files with vim in a few second without having to wait any app to launch.

    It's very fast and when you get used to it you can realise that GUI and CLI are two different things, each one has pro and cons.

    One more thing, type this in Terminal:



    telenet towel.blinkenlights.nl
Sign In or Register to comment.