Introduction to Basic Commands
What is the Command Line?
The command line is a text-based interface used to interact with the computer's operating system. It allows users to execute commands by typing them and receiving text-based feedback. This powerful tool is often used for system administration, file manipulation, and running scripts or programs.
Opening the Command Line
To begin using the command line, you need to open the terminal application on your computer.
- Windows: Search for "cmd" or "Command Prompt" in the Start menu.
- MacOS: Open "Terminal" from the Applications > Utilities folder.
- Linux: Open "Terminal" from your application menu or use the shortcut Ctrl + Alt + T.
Basic Commands
Here are some fundamental commands that every beginner should know:
1. Displaying the Current Directory:
Use the pwd command to print the working directory (current directory) you are in.
pwd
2. Listing Files and Directories:
The ls command is used to list the files and directories in the current directory.
ls
3. Changing Directories:
Use the cd command to change the current directory. For example, to move into a directory named "folder1":
cd folder1
4. Creating a Directory:
The mkdir command is used to create a new directory. For example, to create a directory named "new_folder":
mkdir new_folder
5. Creating a File:
Use the touch command to create an empty file. For example, to create a file named "new_file.txt":
touch new_file.txt
6. Deleting a File:
The rm command is used to delete a file. For example, to delete "file1.txt":
rm file1.txt
7. Deleting a Directory:
To delete an empty directory, use the rmdir command. For example, to remove "folder1":
rmdir folder1
To delete a non-empty directory and all its contents, use the rm -r command:
rm -r folder2
Conclusion
These basic commands will help you get started with using the command line. As you become more comfortable, you can explore more advanced commands and techniques to enhance your productivity and efficiency in managing files and directories.