Command reference and Practice
Command Reference
| Command | Description |
|---|---|
pwd |
Prints the current working directory |
ls |
Lists the contents of a directory |
cd |
Changes the current working directory |
man |
Shows the manual page for the specified program |
mkdir |
Makes directories |
nano |
Opens the nano command-line editor |
vim |
Opens the vim command-line editor |
mv |
Moves or renames files and directories |
cp |
Copies files and directories |
rm |
PERMANENTLY deletes files and directories |
Practice
Tip: If you get stuck, use
man <command>or--helpto explore command options.
Exercise 1
1) Open a terminal and make a directory on your Desktop called "practice1"
2) Change your directory to practice1, and print your directory.
3) Create a file called test1.txt in the practice1 containing the text "This is super important!" using vim or nano
solution
ato enter insert modeThis is super important!escto exit insert mode:wq+enterto write and quit
4) Create another file called test2.txt with the text "This is not important" in the practice1 folder.
solution
ato enter insert modeThis is not importantescto exit insert mode:wq+enterto write and quit
5) Without changing directories, make a different folder on your desktop called practice2, and copy both of your text files into that folder.
6) Now change directories into practice2, and rename test1.txt to a file called .hidden.
7) List all of the files in this folder, and show their permissions
solution
7) Switch back to practice1 using the shortcut for "previous working directory"
8) In a single command, move the entire practice2 directory into practice1
9) move back to your desktop using the notation for "parent directory"
10) remove the practice1 directory, and show the files thar are being removed.
Continue to Week 2