The Linux file system
The Linux file system is just like any other but without the GUI
When you are using a graphical user interface (GUI) such as Windows or MacOS, you can use tools that give you an overview of your files in the form of a hierarchical tree. Each node in the tree is either a single file, or a directory (folder) containing files or other directories. At any moment, you can see the contents of one particular directory known as the current directory.
The Linux file system works in exactly the same way, but when you are using the command line you can't see the overall structure as you can with a GUI. You therefore need to maintain a mental picture of the structure of the file system, and where you are in it at any particular moment - i.e. you need to know your current directory at all times.
When you first log into a Linux system, your current directory is set to your home directory by default. Usually, that is not where you need to be working, and you need some commands to orient yourself in the file system, and to move around in it. Some basic commands are shown below - notice that everything following a hash symbol is treated as a comment.
1 2 3 4 5 6
Figure 1 shows the result of executing the command
someone's home directory. Notice that the starting directory is represented
by a dot. In Linux commands, the dot represents the current directory. Here
it contains one ordinary file called mysql.sh and a further
directory called project_18 which contains two .sql files. public_html*
is also a directory, but it contains no files. In the output from the
command, there is no way to distinguish it from an ordinary file.
There are two ways to refer to a file when you are using the Linux command line. The first is to use the full path to identify the file. For example, if you home directory is /home/myhome, you could refer to the first file in the project_1 directory from Figure 1 with the path /home/myhome/project_1/schema.sql. This is known as an absolute reference.
This is often inconvenient because of the amount of typing required. Alternatively, you can refer to a file in relation to your current directory. If that is you home directory, you could use project_1/schema.sql. If you change your current directory to project_1, then you can refer to the same file just with its name, schema.sql. This is known as a relative reference.