Command line for average users?

theman5725

macrumors 6502
Original poster
Aug 2, 2006
388
0
I always read stuff about how terminal and command line interfaces are so powerful, but what exactly can they do so good? Is there any point to using Terminal if you are just an average user? I've just been wondering this.
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
41
Andover, MA
I agree that an average user has little need for Terminal and probably would be fine if it were deleted from their Mac.

However, it's indispensable to me. I use it for development, for getting to files Finder won't show me, for Unix command-line tools, etc. I can make aliases that are real ones (as opposed to the almost useless ones Finder makes). I can search for files and things in files better than Spotlight allows.

There are ways in Finder to do many of the things Terminal can do, but Terminal does most of them better.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
25
Right side of wrong
what was that command that told you the last uptimes that you had and whether the computer crashed or was shutdown? i think it did like the last 15 shutdowns.

thanks in advance
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
25
Right side of wrong
twoodcc said:
what was that command that told you the last uptimes that you had and whether the computer crashed or was shutdown? i think it did like the last 15 shutdowns.

thanks in advance
come on, i know somebody knows that command.

i know it has a "|" in it, and "last"

but that's all i can remember
 

savar

macrumors 68000
Jun 6, 2003
1,952
0
District of Columbia
Phil9579 said:
I always read stuff about how terminal and command line interfaces are so powerful, but what exactly can they do so good? Is there any point to using Terminal if you are just an average user? I've just been wondering this.
For an average user, probably not.

The terminal is really useful for a few kinds of cases:
1) Accessing a computer remotely. If you have to access a computer over the internet, using a command line is much faster than using Remote Desktop or one of those technologies.
2) Doing ad-hoc data processing. A lot of times I find myself needing to do some obscure operations to manipulate text files. It is very convenient to do things like global search and replace, merge files, sort, etc. from the command line in a single command (actually multiple commands piped together).
3) Performing low-level tasks. You can see processes from the command line that are not visible in the Dock. You can suspend or quit these processes much more effectively than you can with cmd-opt-esc. You can also delete files that are not easily deleted by finder.

I'm sure other people find lots of uses for it, but I think most people who do like command lines are developers.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,410
10,573
UK
jsw said:
I can make aliases that are real ones (as opposed to the almost useless ones Finder makes). I can search for files and things in files better than Spotlight allows.
What's the command for making aliases in terminal? it sounds like it might come in useful. :)
 

apfhex

macrumors 68030
Aug 8, 2006
2,670
4
Northern California
savar said:
You can see processes from the command line that are not visible in the Dock. You can suspend or quit these processes much more effectively than you can with cmd-opt-esc.
Activity Monitor.app is equally as useful for this particular thing though. I guess it's a matter of preference (I'm not a CLI junkie, I like to use GUIs when available).

If you, meaning the "average user", doesn't know what use the Terminal is, then chances are you don't need it.
 

iJawn108

macrumors 65816
Apr 15, 2006
1,197
0
Netstat is pretty handy(IMO)

SYNTAX

netstat [-a] [-n] [-v]

netstat [-g | -m | -p | -s | -f address_family ] [-n] [-P protocol]

netstat [ -i ] [ -I interface ] [ interval ]

netstat -r [-a] [-n] [-v ]

netstat -M [-n] [-s ]

netstat -D [ -I interface ]

-a Show the state of all sockets and all routing table entries; normally, sockets used by server processes are not shown and only interface, host, network, and default routes are shown.
-n Show network addresses as numbers. netstat normally displays addresses as symbols. This option may be used with any of the display formats.
-v Verbose. Show additional information for the sockets and the routing table.
-g Show the multicast group memberships for all interfaces.
-m Show the STREAMS statistics.
-p Show the address resolution (ARP) tables.
-s Show per-protocol statistics. When used with the -M option, show multicast routing statistics instead.
-i Show the state of the interfaces that are used for TCP/IP traffic.
-r Show the routing tables.
-M Show the multicast routing tables. When used with the -s option, show multicast routing statistics instead.
-d Show the state of all interfaces that are under Dynamic Host Configuration Protocol (DHCP) control.
-D Show the status of DHCP configured interfaces.
-f address_family imit statistics or address control block reports to those of the specified address_family, which can be one of:
inet For the AF_INET address family
unix For the AF_UNIX address family

-P protocol Limit display of statistics or state of all sockets to those applicable to protocol.
- I interface Show the state of a particular interface. interface can be any valid interface such as ie0 or
le0.
 

relimw

macrumors 6502a
May 6, 2004
611
0
SC
'top' is useful too. For instance from my G4 mini right now:

Code:
Processes:  58 total, 3 running, 55 sleeping... 178 threads            21:03:15
Load Avg:  1.52, 1.55, 1.52     CPU usage:  91.1% user, 8.9% sys, 0.0% idle
SharedLibs: num =  195, resident = 43.2M code, 4.82M data, 7.46M LinkEdit
MemRegions: num =  7606, resident =  240M + 11.1M private,  104M shared
PhysMem:  88.7M wired,  241M active,  647M inactive,  978M used, 46.0M free
VM: 4.34G +  131M   49801(0) pageins, 200(0) pageouts

  PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
  784 top          7.8%  0:01.10   1    18    22   704K   408K  1.12M  26.9M 
  780 mdimport     0.0%  0:00.55   4    62    55  1.03M  4.57M  3.24M  40.3M
  587 seamonkey-  13.6%  2:16:13  10   168  1067   147M- 42.0M   149M   561M 
  554 bash         0.0%  0:00.08   1    14    17   232K   856K   892K  27.2M
  553 login        0.0%  0:00.01   1    16    36   140K   424K   552K  26.9M
  514 Terminal     0.7%  0:47.52   5   156   199  3.21M  11.8M  8.98M   128M
  510 Keynote      0.4%  5:55.22   4   108   358  15.1M  31.0M  44.2M   171M
  285 AppleSpell   0.0%  0:00.16   1    34    36   716K  2.33M  1.86M  37.7M
 

theman5725

macrumors 6502
Original poster
Aug 2, 2006
388
0
apfhex said:
Activity Monitor.app is equally as useful for this particular thing though. I guess it's a matter of preference (I'm not a CLI junkie, I like to use GUIs when available).

If you, meaning the "average user", doesn't know what use the Terminal is, then chances are you don't need it.
Not exactly the average user, more like somebody who isnt a delevoper/programmer. I always thought command lines were for things like that.
 

hayduke

macrumors 65816
Mar 8, 2005
1,177
2
is a state of mind.
I guess the Terminal might not be useful for "average" (or below-average ;)) users, but here are some simple examples of things you can do:

1) If you have a folder of mixed filetypes (*.jpg, *.doc, *.txt, etc.) you can easily move all of the *.jpg files into a new folder. This might be a pain to do with the mouse.

2) If you want to move a file (or group of files) from one folder to another that is deeply buried you can do this pretty easily within the terminal. Admittedly, this isn't too tough in the Finder either.

3) I use it frequently to sftp or scp files from one computer to another. Presumably, at some point, Apple will finally introduce proper FTP navigation in the Finder (sheesh!).

4) You can also do things like download a lot of images of a webpage. The curl function lets you grab all of the *.jpgs on a webpage, which is handy if your family just posted the latest vacation pics and you want a copy of all of them.

5) I also use it a lot for programming, but this is probably not considered an "average" use.

6) I find the grep function really useful for finding tid-bits of text within a directory containing lots of text files. For example, if I had a bunch of family letters I could "grep" for "Las Vegas" to find any documents that contain the term "Las Vegas." You can basically do this with spotlight now, but I still haven't fully adapted to using Spotlight.

Those are just a few things off the top of my head.
 

whooleytoo

macrumors 604
Aug 2, 2002
6,563
631
Cork, Ireland.
hayduke said:
1) If you have a folder of mixed filetypes (*.jpg, *.doc, *.txt, etc.) you can easily move all of the *.jpg files into a new folder. This might be a pain to do with the mouse.
This has always been possible by sorting by kind, and it's even easier now with Spotlight in the Finder.
 

Josh

macrumors 68000
Mar 4, 2004
1,640
1
State College, PA
You can use FTP via the terminal to upload/download files to a webserver without downloading and/or paying for an application that does it.

You can also use SSH to log on to other computers and run commands (but if you needed to do this, this is probably something you'd already know).

Compiling and writing programs is another.

The terminal is mostly for geeks and nerds.

Mom and pop don't have much use for it at all :)
 

whooleytoo

macrumors 604
Aug 2, 2002
6,563
631
Cork, Ireland.
The terminal is very useful for automating repetitive tasks. You can do so to a similar extent with Applescript, but in my experience it's not as pervasive and not much easier either.
 

acidity

macrumors regular
Sep 7, 2006
115
0
OK.

What is the keyboard shortcut to start a terminal windows in Mac OS X? I am a keyboard guy and dosnt like to mouse click everytime terminal to open a terminal. Is this possible in Mac or we have to do some extra key bindind...if yes then how :)
 

whooleytoo

macrumors 604
Aug 2, 2002
6,563
631
Cork, Ireland.
acidity said:
OK.

What is the keyboard shortcut to start a terminal windows in Mac OS X? I am a keyboard guy and dosnt like to mouse click everytime terminal to open a terminal. Is this possible in Mac or we have to do some extra key bindind...if yes then how :)
If using 10.4, Spotlight might be the easiest way to go.

Command-Space to start searching, type "Term", then hit Command-Return to launch it. In practice, it doesn't take much longer than a single keystroke, with the benefit you don't have to manually create a binding for every such app.