You can also have a number of different Terminal windows open if that helps your workflow. Simply use. If you have material in your scroll buffer you want to find, use. You can also search for material by highlighting a passage, entering. The shell interprets command lines you enter, runs programs you ask for, and generally coordinates what happens between you and the Unix operating system.
Other available shells include the Bourne shell sh , the C shell csh , the Bourne-Again shell bash , and the Z Shell zsh. To change the shell that Terminal uses, see Section 4. For a beginner, differences between shells are slight. If you plan to work with Unix a lot, though, you should learn more about your shell and its special commands.
See Section 1. When the system is ready to run a command, the shell outputs a prompt to tell you that you can enter a command. For example, the complete prompt might look like this: The prompt can be customized, though, so your own shell prompt may be different. Try logging out of Mac OS X. Entering a command line at the shell prompt tells the computer what to do. Each command line includes the name of a Unix program.
When you press Return, the shell interprets your command line and executes the program. The first word that you type at a shell prompt is always a Unix command or program name. Like most things in Unix, program names are case sensitive; if the program name is lowercase and most are , you must type it in lowercase. Some simple command lines have just one word, which is the program name. For more information, see Section 1.
An example single-word command is date. Entering the command date displays the current date and time:. As you type a command line, the system simply collects your keyboard input. Another simple command is who. The who program can also tell you which account is currently using the Terminal application, in case you have multiple user accounts on your Mac.
The command line for this is who am i. Arguments are explained in Section 1.
For example:. The command used to delete, or remove, files in Terminal is rm. So, for example, if you wanted to remove a file in your Documents folder named "oldfile. As it stands, that will delete the file without further intervention from you. If you want to confirm the file to be deleted, use -i as in rm -i oldfile. To delete all the files and sub-folders in a directory named "oldfolder", the command is rm -R oldfolder and to confirm each file should be deleted, rm -iR oldfolder.
You can download CleanMyMac here. And if you need to delete files to save space, use an app like CleanMyMac X to do it. Ivan Exploring latest tech trends. Apple obsessed. CleanMyMac X. Your Mac. As good as new. English English. MacPaw uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy.
Click here to learn more. You can also press clear at any point to wipe all the history and have a clean screen. Always remember to type pwd before writing any commands to make sure you know where you are. If I want to move somewhere else, I will use the cd command — Change Directory. Type these commands, and press enter after each one. First, I moved to the Music folder.
Introduction to the Mac OS X Command Line - Treehouse Blog
The terminal will understand a directory regardless of case, so I can write music or Music. As you can see, it says NolBook: I printed out my current location to make sure, then listed the contents. How do I go back? In the terminal, one dot. By typing cd.. Right now would be a good time to practice moving between directories. If you try to move into a directory that has a space, you may encounter an issue. For example, in my Music folder, there was a directory called Audio Music Apps. However, if I try to simply type that..
Learning Unix for Mac OS X, Second Edition by Dave Taylor, Brian Jepson
There are two ways to remedy this. If you press tab , the Terminal will do this for you! Simply type cd A and press tab and the shell will automatically assume what you want to type.
Congratulations, you created a directory! I can also see this through Finder.
You can do this with the touch command. I imagine it as Merlin tapping a wand and creating something out of thin air. You can ls to see it, or check in Finder that you have created a valid. You can create any sort of file, but it likely only makes sense to create text based files through terminal. We used touch to create an empty file, but we can even create a file on the fly with some content using echo.
Now I have a plain text file called hello. I can check this by opening it from Finder, but I can also see the contents through Terminal with the cat command. At this point, I would recommend creating some more files and directories and moving between them to get more familiarized with the commands. I can choose to delete all the files of a certain filetype with a wildcard. For example, if I saved many. We can also copy and paste files through the command line with the cp Copy command.
Simply type cp followed by the source file you want to copy and destination place you want to copy it to. Now I can copy my test. To copy an entire directory, use the -R option. As long as the first command is successful, the subsequent one will run. You can change permissions with the chmod Change Mode command. The term sudo stands for Super User Do. You can precede a command with sudo to run the command as administrator, as long as you have the admin password.
How to use the Terminal command line in macOS
You can also switch to the administrator user. At times you will need to be logged in as admin to move between restricted directories. You can achieve a secure connection via the command line with ssh Secure SHell. Your console will most likely look something like this:. You can exit the server and return to your own computer with the exit command. I can do this with the dig DNS Lookup command.
If I forget something, I can also check the help guide for the command line with man Manual. You may have heard of programs such as Vim or Emacs. These are Terminal-based text editors. Both of these programs have a bit of a learning curve.
What is the command line?
Most if not all Macs and Linux-based computers come with a program installed called Nano , which is a very simple text editor. Now I can check the contents of index. I might consider making a Windows tutorial, which would be almost the same just with a few commands and screenshots changed, and a basic Bash script tutorial. I'm Tania. I turn down every ad, affiliate, and sponsor request I get.