Skip to content
Add sections on Prompt and Common Commands authored by Ronald Record's avatar Ronald Record
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
1. [Mac OS](#mac-os) 1. [Mac OS](#mac-os)
1. [Linux](#linux) 1. [Linux](#linux)
1. [Microsoft Windows](#microsoft-windows) 1. [Microsoft Windows](#microsoft-windows)
1. [Accessing another system with the Command Line](#accessing-another-system-with-the-command-line) 1. [The Command Line Prompt](#the-command-line-prompt)
1. [Getting started with basic commands](#getting-started-with-basic-commands) 1. [Getting started with basic commands](#getting-started-with-basic-commands)
1. [Moving files](#moving-files) 1. [Moving files](#moving-files)
1. [Copying files and folders](#copying-files-and-folders) 1. [Copying files and folders](#copying-files-and-folders)
...@@ -18,14 +18,16 @@ ...@@ -18,14 +18,16 @@
1. [Changing the current working directory](#changing-the-current-working-directory) 1. [Changing the current working directory](#changing-the-current-working-directory)
1. [Making a new folder](#making-a-new-folder) 1. [Making a new folder](#making-a-new-folder)
1. [Getting help for a command](#getting-help-for-a-command) 1. [Getting help for a command](#getting-help-for-a-command)
1. [Common Commands](#common-commands)
1. [Running scripts](#running-scripts) 1. [Running scripts](#running-scripts)
1. [Accessing another system with the Command Line](#accessing-another-system-with-the-command-line)
1. [Permissions and ownership](#permissions-and-ownership) 1. [Permissions and ownership](#permissions-and-ownership)
## What is the Command Line ## What is the Command Line
The command line or command-line interface, is a text-based application for The command line or command-line interface, is a text-based application for
viewing, handling, and manipulating files on your computer. Other names for viewing, handling, and manipulating files on your computer. Other names for
the command line are: cmd, CLI, prompt, console or terminal. the command line are: cmd, CLI, prompt, shell prompt, console, or terminal.
A command line interface (CLI) processes commands to a computer program in the A command line interface (CLI) processes commands to a computer program in the
form of lines of text. The program which handles the interface is called a command form of lines of text. The program which handles the interface is called a command
...@@ -326,30 +328,41 @@ Click on “Accessories” and you’ll find the Command Prompt shortcut. ...@@ -326,30 +328,41 @@ Click on “Accessories” and you’ll find the Command Prompt shortcut.
Right click on the shortcut and press “Run as Administrator”. Right click on the shortcut and press “Run as Administrator”.
## Accessing another system with the Command Line ## The Command Line Prompt
After opening a terminal window as described in the previous section,
you should see a white or black window that is waiting for your commands.
The window will display a character or string called the command line prompt,
aka 'shell prompt', or 'prompt' for short. It prompts you to input something there.
Often it is not possible or inconvenient to access another system directly. If you're on a Mac or Linux, you probably see a $ as the prompt
If remote access has been enabled, one method to do this is through the Secure
Shell (SSH), which lets you securely control and modify remote systems over
the network.
You can do this by typing in `ssh username@host_server` On Windows, you probably see a > as the prompt
where username is the account name of your account on the remote system, and
host_server is the remote host.
If you have a password to access your account on the server, SSH will The command line prompt is often configured to display the username, system name,
prompt you to enter that in. current working directory, or other useful information but will usually end with
either a $ sign, > symbol, or the &hash; symbol when logged in as the root user.
For example, my prompt right now on my Mac is:
If it’s your first time accessing that particular system, your computer may also `doctorwhen@Ronnies-Mac-Pro:~/src/MirrorCommandLine$`
ask you if it can remember the authenticity key — type in ‘yes’ or the corresponding
phrase so that your computer doesn’t ask you this every time.
After successfully logging in to the remote system via SSH, you are presented with At the prompt you can type a command which will be interpreted by the shell your
a command line prompt and commands you type in the terminal window at that prompt login session is configured to use. I use the Bash shell. There are many shells,
will be interpreted as commands to execute on the remote system. Exit the SSH each offering its own value and all with similar but slightly different syntax,
session by logging out, usually by typing the command `exit`. After exiting the built-ins, functions, and features.
SSH session, commands issued at the command line prompt in your terminal window
will be interpreted as commands to execute on the local system. For example, to display your username, type the following command at the prompt
followed by <Return>
Mac OS or Linux:
`$ whoami`
Windows:
`> whoami`
The `whoami` command should return your username followed by another shell
prompt waiting for input.
## Getting started with basic commands ## Getting started with basic commands
...@@ -469,6 +482,48 @@ Often commands will display their usage when invoked with the '-h' or '-u' or ...@@ -469,6 +482,48 @@ Often commands will display their usage when invoked with the '-h' or '-u' or
-help' or '--help' option. The exact option to use for help varies from command -help' or '--help' option. The exact option to use for help varies from command
to command. to command.
### Common Commands
Here is a summary of some useful commands:
<table border="0">
<tr>
<th style="text-align: center">Command (Windows)</th>
<th style="text-align: center">Command (Mac OS / Linux)</th>
<th style="text-align: center">Description</th>
<th style="text-align: center">Example</th>
</tr>
<tr>
<td>exit</td><td>exit</td><td>close the window</td><td><strong>exit</strong></td>
</tr>
<tr>
<td>cd</td><td>cd</td><td>change directory</td><td><strong>cd test</strong></td>
</tr>
<tr>
<td>cd</td><td>pwd</td><td>show the current directory</td><td><strong>cd</strong> (Windows) or <strong>pwd</strong> (Mac OS / Linux)</td>
</tr>
<tr>
<td>dir</td><td>ls</td><td>list directories/files</td><td><strong>ls</strong></td>
</tr>
<tr>
<td>copy</td><td>cp</td><td>copy file</td><td><strong>cp test/test.txt stage/test.txt</strong></td>
</tr>
<tr>
<td>move</td><td>mv</td><td>move file</td><td><strong>mv test/test.txt stage/test.txt</strong></td>
</tr>
<tr>
<td>mkdir</td><td>mkdir</td><td>create a new directory</td><td><strong>mkdir test</strong></td>
</tr>
<tr>
<td>rmdir (or del)</td><td>rm</td><td>delete a file</td><td><strong>rm test/test.txt</strong></td>
</tr>
<tr>
<td>rmdir /S</td><td>rm -r</td><td>delete a directory</td><td><strong>rm -r test</strong></td>
</tr>
<tr>
<td>[CMD] /?</td><td>man [CMD]</td><td>get help for a command</td><td><strong>cd /?</strong> (Windows) or <strong>man cd</strong> (Mac OS / Linux)</td>
</tr>
</table>
## Running scripts ## Running scripts
To run a Python script, e.g. to run the script example.py, execute the command: To run a Python script, e.g. to run the script example.py, execute the command:
...@@ -490,6 +545,31 @@ it can be executed and interpreted by Bash with the command: ...@@ -490,6 +545,31 @@ it can be executed and interpreted by Bash with the command:
`./example.sh` `./example.sh`
## Accessing another system with the Command Line
Often it is not possible or inconvenient to access another system directly.
If remote access has been enabled, one method to do this is through the Secure
Shell (SSH), which lets you securely control and modify remote systems over
the network.
You can do this by typing in `ssh username@host_server`
where username is the account name of your account on the remote system, and
host_server is the remote host.
If you have a password to access your account on the server, SSH will
prompt you to enter that in.
If it’s your first time accessing that particular system, your computer may also
ask you if it can remember the authenticity key — type in ‘yes’ or the corresponding
phrase so that your computer doesn’t ask you this every time.
After successfully logging in to the remote system via SSH, you are presented with
a command line prompt and commands you type in the terminal window at that prompt
will be interpreted as commands to execute on the remote system. Exit the SSH
session by logging out, usually by typing the command `exit`. After exiting the
SSH session, commands issued at the command line prompt in your terminal window
will be interpreted as commands to execute on the local system.
## Permissions and ownership ## Permissions and ownership
In Unix and Linux systems there is are the concepts of 'permission' and 'ownership'. In Unix and Linux systems there is are the concepts of 'permission' and 'ownership'.
Every file and directory has a set of permissions and ownership associated with it. Every file and directory has a set of permissions and ownership associated with it.
... ...
......