Terminal Command Line Flashcards
How to know where a Terminal window is at?
At the top of the window it shows the location
Is it possible to have multiple terminal windows/tabs opened?
Yes, sure! It works like a browser. You can merge windows so that they get gathered together under the form of tabs under one single window.
Is it possible to restaure multiple windows so that you can get back where you left off?
Sure. It can:
Window > Save Windows as Group…
To reopen:
Window > Open Window Group > Select Group name
It will restaure windows with their location on screen and their repository where you left off
How to clear all the previous commands and get back to an empty screen?
clear + return
Is it possible to save all the commands and results from a terminal window?
yes, just like on other softwares: cmd + S.
It will save as a text file.
Is it possible to use copy and paste in Terminal?
Sure yes!
What does ~ lecorre$ mean when starting a Terminal window?
It is the location where the Terminal is at. By default it goes to the User root
- The tilde (~) means base user’s directory (the Home)
- It is followed by the name of the current user.
- The $ : The dollar sign prompt (or a prompt ending with a dollar sign) means that UNIX is now ready to interpret and execute your commands as typed in from your keyboard.
What’s the shortcut to initiate previously typed commands without having to retype them?
Just use the up arrow ↑
If you went back to much you can use the same trick with down arrow ↓
How to access the history of commands?
history + return
How to change directory
cd + name of directory
Stands for “change directory”
How to know where you are at?
- The title of the Terminal Window
- the directory always shows at teh left of the command invite (at the left of the dollar sign)
What is the difference between relative and absolute paths?
A path is a list of components (directory or file names) separated by a slash (/).
An absolute path starts from the root directory and works its way down: /A/B/file.
A relative path starts from some contextually-determined parent directory and works its way down from there: A/B/file.
In a terminal context, the default parent directory for a relative path is the present working directory, which you can print using the pwd command.
A path is how you refer to a file or directory. A path like /A/B/file is a concise description of how to find a file:
- start at the system root directory /,
- move to the A directory,
- next move to the B directory,
- and end with file.
Is there a shortcut for:
cd /Users/username/Documents
Yes:
cd ~/Documents/
On Mac OS, just as on all UNIX systems, the tilde (~) stands for current user directory
What’s the shortcut to get back to user’s root directory?
just type cd and return without anything else:
cd + return
How to get back one step up in folder hierarchy? Like let’s say from User/Documents to User/
cd .. + return
You can also combine this in one command if you already know which other folder you want to target. Like from Documents if you want to access Pictures, you can type:
cd ../Pictures
Which literally means “get back one directory above and enter Pictures”