How to work with command line on a mac? The following is similar to DOS or command line utilities or commands on Windows PS.
- Start Terminal
- click search icon (glass magnifier) and Type terminal to get into terminal
- Quit Terminal
- Command+ q or click on red close button on the window
- Run a command
- Type an valid command, for example ls command print directory listing, find . ‘string’ search for all files in current and subdirectories searching for ‘string’
- Quit a command
- Control + Z lets you quit to stop a command. It is similar to break on windows.
- Quit a help screen
- Press Q alone lets you exit a help screen. For example you want to quit in the middle of help grep. Hit Q when you have found what you were looking for
Working with Nano
Nano is small text editor available on mac. You can edit files directly inside terminal without using an windows program. Here is a quick tutorial.
- Start Nano
- type “nano” or type “nano filename” to open a particular text file in nano editor.
- Close Nano
- Control+x, to close nono. This will ask you if you want to save you changes. Hit N if you dont want to save any changes
A simple tutorial using Nano
Goal: Create a text file called, myfile.txt and your name and phone number in it and save it. Then we will load the file to see if the contents are there.
1. Type nano myfile.txt
This will open nano text editor. No file will be created yet.
2. Start writing text. Writing anything you want
3. Control+O to write files to the disk
4. Control+x to quit
The following are some of the commands display on the main windows. Notice that all commands are preceded by control key. Control + letter will execute that command. The commands changes in each windows, depending on what is displayed on the screen.
Control + X = Quit
Control + V = Navigate to Next page (contents must exist in next page)
Control + Y = Navigate to previous page
Control + K = Cut text. It will not cut text over multiple lines though.
Control + U = Past the cutted text. Uncut text.
Control + O = Write file to the disk (same as save file).