Terminal commands....

Discussion in 'Mac Help/Tips' started by frescies, Apr 14, 2003.

  1. frescies macrumors regular

    Joined:
    Dec 9, 2002
    Location:
    Los Angeles, CA
    #1
    Hey everyone!

    I want to start messing around in the the command line terminal of OS X (still looking at all hands on unix options). Where can I find a bonified list of commands for the terminal?

    Yours truly,
    David
     
  2. mnkeybsness macrumors 68030

    mnkeybsness

    Joined:
    Jun 25, 2001
    Location:
    Moneyapolis, Minnesota
    #2
    click this link it's a tutorial from my CSci1901 course at the university of minnesota...it gives some basics to get you started navigating around.

    another nice command to look at is top it tells you what's running and how much of your resources it takes

    another sometimes necessary (use with caution) is kill # where the # is the process ID number found by doing a top command
     
  3. PB180 macrumors newbie

    Joined:
    Jan 7, 2002
    #3
    Other good options...

    Check out OSXFAQ - They have a daily OS X Unix tip (note, some tips only work in 10.2). These is a good mixture of fun and useful commands and mini-tutorials.

    It's at http://www.osxfaq.com/tips/unix-tricks/

    Besides that, there's nothing more useful than learning some regular expressions... I really enjoyed "Mastering Regular Expressions" by Friedl (O'Reilly Press).

    Also, ctrl-x ctrl-d (type both in succession) will bring up a big list of all available commands. Be sure to maximize your terminal window before doing this so you can easily see the commands.

    Have fun playing with the terminal!
     
  4. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #4
    I wouldn't recommend top (too confusing) or kill (too dangerous) as the starting point for beginners.

    I suggest you start with the free Terminal Basics guide by Neal Parikh (click here to download the pdf).

    To learn about most commands, you can type "man xxxx", where xxxx is the name of the command (e.g., man ls), to display the man page (Unix manual) for that command. The man command displays a screenful at a time. Press the space bar for the next screenful or letter 'q' (my favorite letter of the alphabet!) to quit early.

    There are way too many commands to imagine learning them all by reading man pages, so you'll want to start with commonly used commands. I'd recommend these "safe" ones first, just to get your feet wet: cal cd date echo expr file ls man printenv. Then you can start playing with files and directories with these: cat cp cut grep head less mkdir more mv rm rmdir sort tail uniq and learn about users and processes too: finger id ps time top users who. None of these commands are Mac OS X specific; they apply to any version of Unix (actually, I'm not sure about top). When you are ready, you can delve into Unix editors like emacs and vi; for these, a beginners book would be handy.

    (If somebody else at MacRumors could suggest some good commands specific to Darwin, as opposed to Unix in general, that are good to learn first, I'd appreciate it.)

    For your convenience (or horror), here's the list of standard shell commands:

    a2p ab ac accept accton aclocal aclocal-1.6 addftinfo addr aexml afmtodit alias alloc am-eject amd amd2ldif amd2sun amq apachectl appleping appletalk appletviewer apply apropos apxs ar arch arp as asa asr at at_cho_prn atlookup atos atprint atq atrm atstatus autoconf autodiskmount autoheader automake automake-1.6 automount automount2amd autoreconf autoscan autoupdate awk b2m badsect banner basename bash bashbug batch bc bg biff bindkey bison bless blued bootparamd bpwhoami break breaksw bridget bsdmake builtins bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep bzip2 bzip2recover bzless bzmore c++ c++3 c++filt c++filt2 c++filt3 c2ph c_rehash cal calendar cancel cap_mkdb captoinfo case cat catman cc cd certtool chdir checkgid checknr chflags chfn chgrp chmod chown chpass chroot chsh ci cksum clear clri cmp cmpdylib co col colcrt collection/ colrm column comm compileHelp complete compress config configd continue cp cpio cpp cpp3 cron crontab cscope csh ctags ctl-amd ctl-hlfsd cups-config cupsaddsmb cupsd curl curl-config cut cvs cvs-diff-branch cvs-make-branch cvs-merge-branch cvs-revert cvs-view-diffs cvsbug date dbmmanage dc dd default defaults dev_mkdb df diff diff3 diffpp diffstat dig dirname dirs disable disktool diskutil ditto dmesg dnsquery domainname dprofpp du dump dumpfs dynamic_pager eaytest ebrowse echo echotc ed editmap edquota egrep else emacs emacs-21.1 emacsclient enable end endif endsw enscript env eqn error etags eval ex exec exit expand expn expr extcheck false fastboot fasthalt fdisk fetchmail fg fgrep file filetest find find2perl finger fix-amd-map fixPrecomps fixmount fixrmtab flex flex++ fmt fold foreach formail fpr from fs_usage fsck fsck_hfs fsck_msdos fsinfo fsplit fstat ftp ftpstuff/ g++ g++2 g++3 gatherheaderdoc gcc gcc2 gcc3 gcc_select gcov gcov3 gdb genstrings getopt glibtool glibtoolize glob gm4 gnumake gnutar goto gprof grep grep-changelog grn grodvi groff grog grolbp grolj4 grops grotty groups gunzip gzcat gzexe gzip h2ph h2xs halt hashstat hdid hdiutil head headerdoc2html heap hexdump history hlfsd host hostinfo hostname hoststat hpftodit htdigest htpasswd httpd hup hwmond id ident idlj if ifconfig ifnames indent indxbib inetd info infocmp infokey infotocap init install install-info install_name_tool installer ioalloccount ioclasscount iodbc-config ioreg iostat ip6 ip6config ipconfig ipfw irb irpd jam jar jarsigner java java-rmi.cgi javac javaconfig javadoc javah javap javatool jdb jikes jobs join jot kdestroy kdump kextcache kextload kextstat kextunload keytool kgmon kill killall kinit klist kpasswd kswitch ktrace lam last lastcomm latency ld ldapadd ldapcompare ldapdelete ldapmodify ldapmodrdn ldappasswd ldapsearch ldapwhoami leaks leave less lessecho lesskey lex lex++ libtool limit lipo lkbib ln locate lock lockfile log logger login logname logout logresolve look lookbib lookupd lorder lostaltmail lp lpadmin lpc lpinfo lpmove lpoptions lppasswd lpq lpr lprm lpstat ls ls-F lsbom lsof m4 mDNSResponder mach_init machine mail mailq mailstat mailstats make make_printerdef make_smbcodepage make_unicodemap makedbm makeinfo makemap malloc_history man manpath md md5 merge mesg mig mk-amd-map mkafmmap mkbom mkdep mkdir mkfifo mkfile mklocale mknod mkpassdb mkservdb mkslapdconf mkstr mktemp mmroff more mount mount_afp mount_cd9660 mount_cddafs mount_devfs mount_fdesc mount_ftp mount_hfs mount_msdos mount_nfs mount_smbfs mount_synthfs mount_udf mount_volfs mount_webdav mountd msgs mtree mv named named-bootconf natd native2ascii nbdst ndc ndp neqn netinfod netstat newaliases newfs newfs_hfs newfs_msdos nfsd nfsiod nfsstat nibindd nibtool nice nicl nidomain nidump nifind nigrep niload nireport niutil nm nmbd nmblookup nmedit nohup nologin notify nroff nslookup nsupdate ntp-genkeys ntp-wait ntpd ntpdate ntpdc ntpq ntptimeset ntptrace nvram ocs od odbctest onintr open opendiff openssl osacompile osalang osascript otool over package pagesize pagestuff passwd paste patch pawd pax pbcopy pbpaste pbxbuild pcscd pcsctest pcsctool pdisk pdump pear pearize periodic perl perl5.6.0 perlbug perlcc perldoc pfbtops php-config phpextdist phpize phptar pic pico ping ping6 pl pl2pm plutil pmap_dump pmap_set pmset pod2html pod2latex pod2man pod2text pod2usage podchecker podselect policytool popd portmap post-grohtml pppd pr praliases pre-grohtml printenv printf procmail projectInfo ps pstat pstruct purgestat pushd pwd pwd_mkdb pydoc python python2.2 quot quota quotacheck quotaoff quotaon racoon racoonctl ranlib rarpd rcp rcs rcs-checkin rcs2log rcsclean rcsdiff rcsmerge rcz rdump reboot redo_prebinding refer rehash reject renice repeat repquota reset restore rev revnetgroup rlog rlogin rm rmdir rmic rmid rmiregistry rmt rotatelogs route routed rpcclient rpcgen rpcinfo rrestore rs rsh rsync rtadvd rtsol rtsold ruby ruptime rwho rwhod s2p sample sc_usage sched scp screen screencapture script scselect scutil sdiff sed segedit sendmail serialver service set setenv setkey setregion settc setty sftp sh shar shift shlock showmount shutdown size slapadd slapcat slapindex slappasswd slattach sleep sliceprint slogin slp_reg slpd smbcacls smbclient smbcontrol smbd smbpasswd smb spool smbstatus smbtar smbutil snork/ soelim softwareupdate sort source splain split spray ssh ssh-add ssh-agent ssh-keygen ssh-keyscan sshd states stdethers stdhosts stop strings strip stty su sudo sum suspend sw_vers swat switch sync sysctl syslogd system_profiler tack tail talk tar tbl tclsh tclsh8.3 tcopy tcpdchk tcpdmatch tcpdump tcsh tee telltc telnet test testparm testprns texi2dvi texi2html texindex tfmtodit tftp tic tickadj tiff2icns tiffutil tim time timed timedc timutil tnameserv toe top tops touch tput tr traceroute traceroute6 troff trpt true tset tsort tty tunefs ud ul umask umount unalias uname uncomplete uncompress unexpand unhash unifdef uniq units unlimit unset unsetenv unvis unzip update update_prebinding uptime users uudecode uuencode uuidgen vacation vers_string vgrind vi view vipw vis visudo vm_stat vmmap vsdbutil w wait wait4amd wait4amd2die wall wc what whatis where whereis which while who whoami whois window wire-test write xargs xinetd xstr yacc yes ypbind ypcat ypinit.sh ypmatch yppoll yppush ypset ypwhich ypxfr zcat zcmp zdiff zdump zforce zgrep zic zip zmore znew zprint zsh zsh-4.0.4
     
  5. janey macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #5
    doctor q...:p
    check out learning unix for mac os x from O'Reilly.
    it's a great intro to unix.
     
  6. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #6
    Doctor Q:

    I believe that top is BSD only. System V doesn't have it.

    That list was shocking and 99.9 percent of that won't be used by most people, let alone new users. :D

    I wouldn't suggest starting vi or emacs unless you know how to get out of it. Control-x, control-c will exit emacs. Is it escape key, :q for vi? I don't use it because I can never remember the escape combinations.

    I think when I started UNIX, man, more, and grep were my best friends. Soon afterwards, ps. bc, and awk were added.
     
  7. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #7
    In vi, you can use :q! (that's colon q exclamation) to get you out of vi without saving the file. If you want to save any changes and exit, use :wq (colon w q).

    : = start a command
    w = write file back to disk
    q = quit
    ! = ok to quit without saving
     
  8. iTarzan macrumors newbie

    Joined:
    Apr 1, 2003
    #8
    In vi you can just hold shift and hit z twice

    ~
    ~
    ~
    ~
    shift+zz

    Learn Emacs though, its better :cool:
     
  9. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #9
    List of terminal commands available under mac os x:

    Open terminal
    type in
    ls /bin
    ls /sbin
    ls /usr/bin
    ls /usr/sbin

    To figure out what the command does, type in man <command>
    If that does not work, try
    <command> --help

    for example
    man ls
    ls --help
    will tell you about the ls command.

    I also recommend Learning Unix for Mac OS X by O'Reilly if you do not know anything about Unix. Once you get the hang of it, and start to like it, then you want to move on to fink.sourceforge.net and install up to 30,000 other applications that run on unix machines. This is also a good place to get applications that use Apple's cool X11 for Mac os X. Forget Civilization, you can run Freeciv. Get rid of Diablo's bloat, when you can run angband in a terminal windows (hehe).

    Lastly, emacs vs vi... If you already know one, don't even try to learn the other. It is easier to convert faiths than it is to change text editors. I like vi, particularly when I want to edit some text configuration file or quick and dirty make up a new web page. I am from the camp that says "emacs would be a great operating system if only it had a decent text editor" a reference to all the gizzilion other things that emacs can do. (like play games, act as an instant messenger client)
     
  10. conceptdev macrumors regular

    Joined:
    Nov 17, 2002
    #10
    Here is my list of favourties.

    1.

    grep! grep is the coolest thing ever! you can search anything with it and you can pipe output from other commands to it. For example lets say you have a huge folder with copious amounts of files in it but you are only looking for a few with common names (or one for that matter) simply type:

    ls | grep insertyoursearchtermhere

    One of the more bizarre grep usages I have seen is people grepping the Linux kernels for swears in the notation. There is some really fun stuff in there.

    2.

    | pipe the output of any command to another command!

    3.

    pico - it is the best damn text editor for the terminal ever. I know I sound like a total newb for saying that but I don't care I have been proudly using it for about a decade now. Its so bloody simple its genius. Great for simple editing of conf files and such.

    4.

    hydra - ok its a not a terminal app but its open source and great for php, xml and the like which you will play with once the CLI is yours. Plus your friends can play to!

    BTW I think kill -9 and TOP are a great way to learn. Sure you break stuff but then you have to fix it :)
     
  11. funkywhat2 macrumors 6502a

    funkywhat2

    Joined:
    Jul 14, 2002
    #11
    Just go in, type "info", then hir <return> and type "h", then hit return. Take a few hours and go through it. It worked well for me.
     

Share This Page