Learning Basic Commands
Summary
This tutorial introduces you to essential Linux command line commands that every Ubuntu user should know. You'll learn how to navigate directories, create files and folders, and perform basic file operations using the terminal.
These commands form the foundation of working with Linux systems and will help you become comfortable with the command line interface.
Key Vocabulary
Prerequisites
- Ubuntu Linux system
- Terminal application open
- Basic understanding of computer files and folders
Step-by-Step Instructions
Check Current Directory
Display the current working directory path.
pwd
Create a Practice Directory
Create a new directory called 'practice' to work in.
mkdir practice
List Directory Contents
Display the contents of the current directory.
ls
Change to Practice Directory
Navigate into the practice directory.
cd practice
Create a Text File
Create an empty text file named 'myfile.txt'.
touch myfile.txt
List Files in Practice Directory
Check the contents of the practice directory.
ls
Edit File with Nano
Open the text file in the Nano text editor.
nano myfile.txt
Edit the File
Type something, then press Ctrl+O (save), Ctrl+X (exit)
Display File Contents
View the contents of the text file.
cat myfile.txt
List Files with Details
Show detailed information about files including permissions and sizes.
ls -la
Create a Subfolder
Create a subdirectory within the practice folder.
mkdir subfolder
Navigate to Subfolder
Change to the subfolder directory.
cd subfolder
Create File in Subfolder
Create another text file in the subfolder.
touch test.txt
Go Back to Parent Directory
Navigate back to the practice directory.
cd ..
List Subfolder Contents
Check what files are in the subfolder.
ls subfolder
Return to Home Directory
Go back to your home directory.
cd ..
Remove Practice Directory
Delete the entire practice directory and its contents.
rm -r practice
Verify Cleanup
Confirm the practice directory has been removed.
ls
Common Issues & Solutions
Solution: Ensure you're typing the command correctly. Linux commands are case-sensitive.
Solution: Some commands require administrator privileges. Use 'sudo' before the command if needed.
Solution: Check your current directory with 'pwd' and ensure the file/directory exists with 'ls'.
Solution: Make sure Nano is installed with 'sudo apt install nano'.
Conclusion
Congratulations! You've learned the essential Linux commands for navigating and managing files. These commands are the building blocks for working with Linux systems.
Key commands you learned:
pwd- Show current directoryls- List directory contentscd- Change directorymkdir- Create directorytouch- Create empty filenano- Edit text filescat- Display file contentsrm -r- Remove directories and contents
Practice these commands regularly to become comfortable with the Linux command line. Remember to use man command to get help for any command!