1 | 2 | Current Level: 3 | 4 | 5 | 6 | 7
touch Commandtouch to Create a FileFrom your terminal, run the following command:
touch my_file.txt
Check your directory:
ls
→ You should now see my_file.txt listed.
Open your GUI file explorer and navigate to the same directory. Does my_file.txt appear?
Run the long listing version of ls:
ls -l
Note the file size of my_file.txt. What do you notice?
To avoid confusion later in the lesson, remove the file:
rm my_file.txt
Confirm the file was deleted:
ls
Files often use a two-part name separated by a dot. Examples:
thesis.txt
picture.png
config.cfg
report.pdf
The part after the dot is called the file extension. It suggests what kind of data the file contains.
This is only a convention — the computer doesn’t enforce it. For example, renaming an image as song.mp3 won’t convert it into audio.
touch instead of a text editor to create a file?