Skip to content

Create files#

Now we're going to finally create some files which we'll pretend represent our friends out in the real world.

There are a lot of ways to create a file:

  • An application you run might generate files
  • You might use a text editor to create a new file and put something in it
  • You can download a file
  • You can copy a file from elsewhere

And so on. Let's use the "text editor" option because that will allow us to knock down two bottles with one stone: nano jeff.txt.

Note

I'm going to switch to a screenshot here so I can show you the results I get.

nano jeff.txt

nano jeff.txt

This is the nano editor. It ships with Ubuntu and quite user friendly. We can type into this window and add contents to the file. Maybe type this (but type anything you like, really):

1
Jeff is my friend. He lives at Jeff Street, Jeffville, US. He's 24.

Now type this key combination: Ctrl+O

This triggers the "Write Out" command, which you can see along the bottom. It means, "Write what I've typed to the file, on my file system, so that the work I've done is saved." You'll be asked what the filename is, and it should already say jeff.txt because we provided that when we typed nano jeff.txt. Press Enter

Now type Ctrl+X to leave nano. We can now see we have our first file (friend?) if we do: ls -lh

1
2
3
4
michael@develop:~/friends$ nano jeff.txt
michael@develop:~/friends$ ls -lh
total 4.0K
-rw-rw-r-- 1 michael michael 68 Mar 18 09:30 jeff.txt

A friend! We have a new file/friend called jeff.txt and it's owned by us (me: michael), is 68 in size (68 bytes) and was created on March 18th at 09:30.

We can now move around the file system and create files.