Computer Terminal Basics
A beginner-friendly tutorial on using terminal commands:
1. Opening the Terminal:
- On macOS, you can find the Terminal app in the "Utilities" folder within the "Applications" directory.
-
On Linux, you can typically access the terminal by searching for
"Terminal" in your application launcher or pressing
Ctrl + Alt + T
. - On Windows, you can use the Command Prompt or PowerShell.
2. Basic Commands:
-
pwd
: Print Working Directory - Shows you the current directory you're in. -
ls
(macOS/Linux) ordir
(Windows): List the contents of the current directory. -
cd [directory]
: Change Directory - Move to a different directory. For example,cd Documents
moves into the "Documents" directory. -
mkdir [directory_name]
: Make Directory - Create a new directory. touch [file_name]
: Create a new empty file.rm [file_name]
: Remove - Delete a file.-
rm -r [directory_name]
: Remove recursively - Delete a directory and all its contents.
3. Navigating Directories:
-
Use
cd
to change directories. You can specify an absolute path (cd /path/to/directory
) or a relative path (cd directory
). - Use
cd ..
to move up one directory. - Use
cd ~
to go to your home directory.
4. File Manipulation:
-
Use
mv [old_file_name] [new_file_name]
to rename a file or move it to a different location. -
Use
cp [source_file] [destination_file]
to copy a file. -
Use
cat [file_name]
to display the contents of a text file. -
Use
less [file_name]
to view a file one page at a time.
5. Working with Text Files:
-
Use
nano [file_name]
orvim [file_name]
to edit text files in the terminal. -
Use
grep [search_term] [file_name]
to search for a specific term in a file.
6. Other Useful Commands:
clear
: Clears the terminal screen.-
history
: Displays a list of recently used commands. -
man [command]
: Displays the manual page for a command, providing information on its usage and options.
7. Learning Resources:
- Online Tutorials: Websites like Codecademy, Udemy, and freeCodeCamp offer tutorials on using terminal commands.
- YouTube: Video tutorials on terminal basics are available on channels like Traversy Media and The Net Ninja.
- Documentation: Refer to the documentation for your operating system or shell for more advanced commands and usage examples.
8. Practice:
- Experiment with different commands and options in a safe environment.
- Create directories, move files, edit text files, and explore the capabilities of the terminal.
With practice and persistence, you'll become more comfortable and proficient in using terminal commands. Don't hesitate to ask questions and seek help when needed!