Preliminaries: Linux File Structure and Commands
Look at file organization in Linux and some basic CLI commands.
We'll cover the following
In previous exercises, we collected data from the user input and printed an output to the screen. In this chapter, we'll write some programs to accomplish the following tasks:
Read from and write to files
Read data from internet resources
Send emails over the internet
Before we learn to do all that, let's brush up on some file organization basics and basic Linux commands that would be helpful for observing the changes to the file structure made by our Ruby code—directly in the command-line interface (CLI).
File structure
A root directory is a directory under which all the other directories and paths are organized. The root directory on Linux is represented by
/
.A file path is a file's location in our system. File paths can be specified in two different ways:
Absolute:Â Absolute paths start from a root directory. For example,
/usercode/main.rb
is a path that specifies that the filemain.rb
is present in theusercode
directory under the root/
.Relative: Relative paths start at the current directory (the directory in which the user is currently working). For example,
files/example.txt
specifies that within the current directory there is a folderfiles
that contains the fileexample.txt
.
Get hands-on with 1400+ tech skills courses.