Terminal 101: Mastering the Basics of Command Line Magic
2 min readAug 7, 2023
Welcome to Terminal 101, where we’ll learn simple steps to unlock the power of your computer’s command line.
1. ls
- Lists directory contents.
- Tip: Use
ls -l
for a long format listing with detailed information. Think ofls
as your room's window. A quick peek and you'll know if it's messy or not!
2. rmdir
- Removes empty directories.
- Tip: We use rm mostly.
3. cd
cd
is your teleport spell. Navigates between directories.- Tip: Typing
cd ~
quickly takes you to your home directory.
4. mkdir
- Creates a new directory.
5. cat
- Shows what’s inside a file.
- Tip: Concatenate two files using
cat: file1.txt file2.txt > combined.txt
.
6. man
- Accesses the command’s manual.
- Tip: Navigate with arrow keys or
q
to quit the man page.
7. less
- Views large files page by page.
8. touch
- Creates new files.
9. rm
- Deletes files or directories.
- Tip: To force to delete whether directory or not:
rm -rf
10. echo
- Display a message on the terminal.
- Tip: — echo “Hello, World!” > file.txt — This will save “Hello, World!” in a file named file.txt without displaying it on the terminal. If file.txt already exists, this command will overwrite its contents. To append the text to the file instead of overwriting, use >>: — echo “Another line” >> file.txt -
Here's a little exercise for you
1. Navigate to your home directory:
cd ~
2. Make a directory called "Frankfurt":
mkdir Frankfurt
3. Move into `Frankfurt`:
cd Frankfurt
4. List the directory contents:
ls
5. Make a text called "halloo":
touch halloo.text
6. Make a text called "gutenTag":
touch gutenTag.text
7. Overwrite both files in one command:
echo "Hallooooo" > halloo.text; echo "Guten taggg" > gutenTag.text
8. Concatenate two files using cat:
cat halloo.text gutenTag.text > combined.text
9. List the directory contents (again):
ls
At this point, you should see the files
"halloo.text", "gutenTag.text", and "combined.text" listed.
10. Move out of `Frankfurt`:
cd ..
11. Delete `Frankfurt`:
rm -rf Frankfurt