The example commands below are an 'Introductory Course' to working on
command line. Please, scroll down for macOS / Linux Terminal commands.
Some Windows Command Prompt Commands
Command |
Explanation |
Although the example commands below are written with uppercase letters,
you can also write them with lowercase letters. |
|
D: |
Select drive D. |
CD \ |
Change to the root directory in the current drive. |
CD .. |
Change to the parent directory of the current directory. |
CD myfiles |
Change to the subdirectory (subfolder) named myfiles. |
COPY testfiles1\somefile.txt |
Copy file somefile.txt from the subdirectory named testfiles1
to the current directory. |
COPY \testfiles1\somefile.txt |
Copy file somefile.txt from the directory named testfiles1
to the current directory. testfiles1 is now a directory in
the root of the current drive. |
COPY \testfiles1\*.txt |
Copy all files which have the name extension .txt from the directory
testfiles1 to the current directory. |
COPY goodtext.txt bettertext.txt |
Copy a file named goodtext.txt to file named bettertext.txt in the current directory. |
DEL useless.tmp |
Delete the file named useless.tmp in the current directory. |
DIR |
Display a list of all files and subdirectories in the current directory. |
DIR *.txt |
Display a list of files that have the file name extension .txt
in the current directory. |
DIR s* |
Display a list of files whose name begins with letter s
in the current directory. |
DIR *sum* |
Display a list of files that have the word sum in their name
in the current directory. |
MD newfiles |
Create (make) a subdirectory named newfiles into the current directory. |
REN test.txt test.old |
Rename a file named test.txt to test.old in the current directory. |
TYPE sometext.txt |
Display the contents of the file named sometext.txt |
HELP | MORE |
Display a list of all Command Prompt commands. When | MORE is added
to the command, the list is shown one page at a time and with the Space key
you get the next page. |
HELP dir |
Display information of the DIR command. |
TAB key |
With the tabulation key you can reduce typing. For example, if you first
type letter S and then hit the TAB key, the system shows a file name if the
current directory contains a file whose name starts with letter S. |
Arrow Up / Arrow Down keys |
With these keys you can scroll commands that have been given earlier in
the Command Prompt window. For example, if you compile and run programs in the Command Prompt
window, you do not always need to retype the necessary commands. |
Some macOS / UNIX / Linux Terminal Commands
Command |
Explanation |
On macOS / UNIX / Linux uppercase and lowercase letters are not
interchangeable in file names. |
|
cd .. |
Change to the parent directory of the current directory. |
cd myfiles |
Change to the subdirectory (subfolder) named myfiles. |
cd ~ |
Change to the home directory of current user. |
cp testfiles1/somefile.txt . |
Copy file somefile.txt from the subdirectory named testfiles1
to the current directory using the same file name. The dot/full stop .
is very important. |
cp ~/Downloads/somefile.txt . |
Copy file somefile.txt from the directory named Downloads
to the current directory. Downloads is now a subdirectory in
the home directory of the user. The dot/full stop .
is very important. |
cp goodtext.txt bettertext.txt |
Copy a file named goodtext.txt to file named bettertext.txt in the current directory. |
rm useless.tmp |
Delete (remove) the file named useless.tmp in the current directory. |
ls |
Display a list of all files and subdirectories in the current directory. |
ls -l |
Display a list of all files with more information. |
ls *.txt |
Display a list of files that have the file name extension .txt
in the current directory. |
ls E* |
Display a list of files whose name begins with uppercase E
in the current directory. |
ls *sum* |
Display a list of files that have the word sum in their name
in the current directory. |
mkdir newfiles |
Create (make) a subdirectory named newfiles into the current directory. |
mv test.txt test.old |
Rename a file named test.txt to test.old in the current directory. |
cat sometext.txt |
Display the contents of the file named sometext.txt |
man cat |
Display manual pages of the cat command. You can advance to the next
page with the Space key, and quit with the Q key. |
TAB key |
With the tabulation key you can reduce typing. For example, if you first
type letter S and then hit the TAB key, the system shows a file name if the
current directory contains a file whose name starts with uppercase S. |
Arrow Up / Arrow Down keys |
With these keys you can scroll commands that have been given earlier in
the Terminal window. For example, if you compile and run programs in Terminal
window, you do not always need to retype the necessary commands. |