Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > For Terminal noob's

For Terminal noob's
Thread Tools
macaddict0001
Mac Elite
Join Date: Jun 2004
Location: Edmonton, AB
Status: Offline
Reply With Quote
Nov 15, 2004, 12:50 AM
 
I thought we could start a thread with various command prompts for newbie Terminal users who want to learn more. So I'll start...

service --list
list commands that aren't password protected
sudo service --list
list commands that are password protected

add man to most commands to see explanations of the command

sudo stands for super user do which gives you root priviliges

root is the core of the system.

mods please make this a stickie

I'm tired of typing despite knowing more commands I'll update this post soon.
     
PBG4 User
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Nov 15, 2004, 09:45 AM
 
ls -- list files. Use with -a to list hidden files.
rm -- remove file. See man page for all the important switches.

A reminder, never use 'rm -rf /' unless you like shiny clean hard drives with no data on them.

top -- show running processes along with how much RAM & CPU are being used. Program order by RAM or CPU usage can be done by adding switches. Again, check out the man page.

kill -- used to kill running processes. Has a big brother named killall.

chmod -- change file/dir privileges.
chown -- change file/dir ownership.

mkdir -- make a new directory

open programname -- Opens GUI applications from the command line.

tar -- create .tar files. Check the man pages for proper switches.


A tip while reading man pages. At the end, you may see other man pages referenced. Here's an example; pthread(3)

To get to this man page, type 'man 3 pthread' on the command line.
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
macaddict0001  (op)
Mac Elite
Join Date: Jun 2004
Location: Edmonton, AB
Status: Offline
Reply With Quote
Nov 15, 2004, 04:33 PM
 
pmset
power management settings

login
login to another users acount via the terminal to change settings etc.

time
set the time

ssh
use ssh to remotely login to another computer on the network
     
wataru
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Nov 15, 2004, 09:57 PM
 
Originally posted by PBG4 User:
open programname -- Opens GUI applications from the command line.
It's not just for GUI apps. It works with anything, including files, folders, and URLs. Run "open -a [application] [file]" to open [file] in [application].
     
PBG4 User
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Nov 16, 2004, 09:24 AM
 
Originally posted by wataru:
It's not just for GUI apps. It works with anything, including files, folders, and URLs. Run "open -a [application] [file]" to open [file] in [application].
Thanks for the clarification. I did not know that! (That's why I love these threads!)
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
Paul McCann
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Nov 17, 2004, 12:00 AM
 
To open the application you need the "-a"

open -a clock

open -a terminal

( case is irrelevant ). To open a finder window at the current working directory use

open .

(note the "."). Opening url's etc is what the "open" without the "-a" is all about.

open http://www.macnn.com

open afp://machinename.adelaide.edu.au

and so forth.

open fred.pdf

will open whatever you've set pdf's to open with.

Cheers,
Paul
     
jamil5454
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status: Offline
Reply With Quote
Nov 19, 2004, 12:22 AM
 
'ps" also lists running processes
"vi [filename]" is used to edit/create text files
"cd [directory]" changes directories
"mkdir [directory]" makes specified directory
"chmod [options] [file or directory]" changes various permissions of specified file/directory
"ln [options] [filename] [filename]" makes hard or soft symbolic links to files
"touch [options] [filename]" changes file access/modification dates/times
"file [filename]" describes what type of file a specified file is
"df" gives you information on mounted filesystems
"whoami" tells you who you're logged in as
"finger user@domain" retrieves user information from the system owning that user (finger daemon needs to be running)

these are off the top of my head, surely I'll think of more. Wow. I just realized how much UNIX shelling is necessary just for normal operation/use of Linux. For noobs, OS X is great. Being random is fun.

-Pressing TAB while typing a filename completes the filename up to the point it can. For instance, if you have two files in the same directory, hello.txt and hello1.txt, typing "vi h" and pressing TAB will make the system beep and complete your comman up to "vi hello". Next, just type a "1" and press TAB again. The shell should comlete the filename completely, because there is no other file beginning with "hello1".

Fortunately, for those Linux users out there, most common Linux commands work under OS X, pretty much exactly like Linux. As a former Linux user, I felt at home when I first opened the Terminal. Reading any good UNIX or Linux book should get you acquainted with the Termianl. Then you will come to realize that some things are faster and easier to do in the terminal, such as ftp (at least without third party help).
( Last edited by jamil5454; Nov 19, 2004 at 12:32 AM. )
     
PBG4 User
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Nov 19, 2004, 10:23 AM
 
jamil5454,

Just want to add to your TAB information that in order to use this feature, you must follow the file/directory's case in order for TAB to autocomplete even though OS X's native file system is case insensitive.

For example if the filename is FileName, typing file then hitting the TAB key would yield just a beep, no autocomplete. You would need to type File (or just F) for the TAB autocomplete option to work.


[edit]

You're evil, telling noobs to use vi as a text editor. You could've pointed them to pico you know (I know I know, vi is available with every *NIX distro).
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
MrCaN
Forum Regular
Join Date: Jan 2004
Location: Lawrence, KS
Status: Offline
Reply With Quote
Nov 19, 2004, 06:13 PM
 
I have a nagging question about terminal that I would like to ask here. Ok when I telnet into a unix system and try to use pine or talk or pico I get the following error:
I don't know anything about your "xterm-color" terminal.

Now I can use vi, but it tells me:
xterm-color: Unknown terminal type
Visual needs addressible cursor or upline capability


any insights how to fix this problem.
Mr. CaN
     
Paul McCann
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Nov 19, 2004, 11:38 PM
 
any insights how to fix this problem.
Sure: just change your TERM environment variable on the remote machine. For example, if you're using tcsh on the remote box add the line

setenv TERM vt100

to the file .login on the remote machine (create the file in your home directory if it doesn't already exist). If you're using some other shell add the appropriate translation of the above to one of the startup files: with bash, for example, it should be

export TERM=vt100

(vt100 is far from the only thing that'll work, but it almost certainly *will* work without giving you any grief). You can test this modification withing your current login session by entering

source .login

(or whatever the file that you edited is called), and then running the editor again. It'll then be applied automatically for future logins.

Cheers,
Paul
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 22, 2004, 03:33 PM
 
Some notes on the above items:

-Pressing TAB while typing a filename completes the filename up to the point it can. For instance, if you have two files in the same directory, hello.txt and hello1.txt, typing "vi h" and pressing TAB will make the system beep and complete your comman up to "vi hello". Next, just type a "1" and press TAB again. The shell should comlete the filename completely, because there is no other file beginning with "hello1".
You can also press tab a second time (after the beep) and it'll give you a list of the items that match the text you entered ("hello.txt" and "hello1.txt" in the above example).

A reminder, never use 'rm -rf /' unless you like shiny clean hard drives with no data on them.
I think the actual command to be wary of is 'sudo rm -rf /'. (A normal administrative user doesn't have the ability to remove the root folder.)

And some of my own:
  • who - Shows who's currently logged into your system (note that it will almost always show at least two users, your account for the GUI login, and your account for the terminal login.)
  • grep - Allows you to search for a text string. This is very useful when combined with any listing of text. For example, "cat myfile.txt | grep hello" will show all lines in the myfile.txt file with the word "hello" in them.
Scott Genevish
scott AT genevish DOT org
     
wataru
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status: Offline
Reply With Quote
Nov 24, 2004, 12:08 PM
 
Originally posted by Paul McCann:
To open the application you need the "-a"
Not if you specify the exact path of the application. For instance, open /Applications/Preview.app
     
Paul McCann
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Nov 24, 2004, 09:36 PM
 
Originally posted by wataru:
Not if you specify the exact path of the application. For instance, open /Applications/Preview.app
Errr, yeeeeeees: I guess this could conceivably be useful if you had several versions of a particular application. But otherwise I'll stick to "open -a console" over "open -a /Applications/Utilities/Console.app"! OK, to be honest I'd be entering

conso[followed by a tab]

to open that application, but that's another story. In any case you're right: you don't *have* to use the "-a", but it's a nice timesaver.

Cheers,
Paul
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:05 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,