In this section we will explore the basic shell commands that enable us to navigate a filesystem and examine some of the commands that we can use to interact with files.
If you’re already familiar with most standard
bash built-ins and standard GNU/linux utilities, feel free to skip this section.
You’ve probably interacted with a filesystem before through GUI software such as
We can perform the same actions that we do through such GUI software through command line utilities.
In our in-browser shell we support a number of commands that are either the same as, or at least very similar to, standard GNU/linux utilities.
For your convinience, all the shells you see below are connected to the same disk. Changes you make to the filesystem on one shell will be visible to all shells in this page.
For starters the command
ls can list directory contents. Try it out below.
To see a full list of options and other features provided by
ls -h or
For now, note the entries that you see when calling
ls. We’ll revisit what they are and what they mean later.
To create directories we can use
To create files we can use
touch (there’s also a few other ways which we’ll discuss later).
mkdir newdir to create a directory named
touch newfile to create a file named
To verify that the files you expected exist, try running
Entering a directory
To enter a directory use the
cd newdir to navigate inside the directory you just created.
To go back out to the directory you were initially in use
cd .. which allows you to move up the file tree by a level.
Gather information about a file
To get information about the details of a file, we can use either the
file or the
stat newfile and
stat will tell us if a file is a regular file or a directory!
Input content into a file
To input content, we can use a trick called output redirection.
In our shell, you can either use the syntax
command > file to save the output of
command >> file to append the output of
To test this out, we can use the command
cat will output the contents of all files passed in as arguments, but if we call it with no arguments it will read from stdin.
Let’s input some content into the file we created earlier.
To do this run
cat > newfile.
Note that redirecting output does not work correctly on mobile.
To create/edit files on mobile use
cat will read from stdin forever, close stdin with
ctrl + d when you are done.
Note that lines are only actually sent to stdin when you press
Also try appending some data with
cat >> newfile.
Once you finish, run
cat newfile to print the contents of
Note that if we run
stat now we’ll see that the filesize has increased.
We’ve also implemented a
GUI editor to make it easier to edit text.
Use the command
edit [filename] to invoke it.
Note that unlike piping the output of
cat (the output redirection trick we did earlier),
edit is not a real utlity used to edit files.
Deleting files and directories
To delete files and directories we’ll use the command
ls afterwards to confirm that the files have been deleted.
rm newdir didn’t work did it?
rm prevents you from deleting directories unless you pass the
-r (recursive) flag to prevent you from accidentally deleting entire projects when you only meant to delete a specific file. Try again with
rm -r newdir.