User Tools

Site Tools


chapter_2_-_the_linux_operating_system:the_linux_filesystem

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

chapter_2_-_the_linux_operating_system:the_linux_filesystem [2013/01/25 13:45]
cellbiol
chapter_2_-_the_linux_operating_system:the_linux_filesystem [2013/10/16 14:57] (current)
cellbiol
Line 1: Line 1:
 +~~NOCACHE~~
 ===== 2-2: The Linux Filesystem ===== ===== 2-2: The Linux Filesystem =====
  
 On approaching Linux systems for the first time, it is essential to understand how files and directories are organized in a Linux system and how to refer to a particular file or directory in order to perform actions. In order to refer to file or directory we need to know it's relative or absolute path in the filesystem. On approaching Linux systems for the first time, it is essential to understand how files and directories are organized in a Linux system and how to refer to a particular file or directory in order to perform actions. In order to refer to file or directory we need to know it's relative or absolute path in the filesystem.
  
-==== The Linux root directory ​and absolute paths ====+==== The Linux root directory ====
  
 Everything in the Linux filesystem is included within a top directory (you can think of a directory just as a folder that contains other folders or files) that is called the Root directory. Everything in the Linux filesystem is included within a top directory (you can think of a directory just as a folder that contains other folders or files) that is called the Root directory.
  
-== Table 2-1: Subdirectories of the root directory in Linux systems ==+== Table 2-2-1: Subdirectories of the root directory in Linux systems ==
 //Source: [[http://​tldp.org/​LDP/​intro-linux/​html/​sect_03_01.html|This page]] of [[http://​tldp.org/​|The Linux Documentation Project]]// //Source: [[http://​tldp.org/​LDP/​intro-linux/​html/​sect_03_01.html|This page]] of [[http://​tldp.org/​|The Linux Documentation Project]]//
 <​html>​ <​html>​
Line 240: Line 241:
 ></​TABLE>​ ></​TABLE>​
 </​html>​ </​html>​
 +
 +==== Absolute paths ====
  
 For path purposes, the root directory is indicated with a slash. The absolute path of the root directory is For path purposes, the root directory is indicated with a slash. The absolute path of the root directory is
Line 250: Line 253:
  
 where the slash indicates the root folder. where the slash indicates the root folder.
 +
 +==== The Linux Shell - Using the Terminal ====
  
 Let's start using a Linux shell to explore the filesystem. In Ubuntu, a Terminal window can be opened with the following keyboard shortcut: Let's start using a Linux shell to explore the filesystem. In Ubuntu, a Terminal window can be opened with the following keyboard shortcut:
Line 259: Line 264:
 Or, in Gnome: Applications menu -> Accessories -> Terminal Or, in Gnome: Applications menu -> Accessories -> Terminal
  
-== Figure 2-2: Linux Terminal to access the Shell ==+== Figure 2-2-1: Linux Terminal to access the Shell ==
 {{ :​chapter_2_-_the_linux_operating_system:​ubuntu_shell_screenshot.png?​nolink |}} {{ :​chapter_2_-_the_linux_operating_system:​ubuntu_shell_screenshot.png?​nolink |}}
  
 When we open the Terminal, we see a line that ends with a dollar sign $. This line is called "**the prompt**",​ this is where we can type commands to interact with the computer. When we open the Terminal, we see a line that ends with a dollar sign $. This line is called "**the prompt**",​ this is where we can type commands to interact with the computer.
 +
 +==== Typing Shell Commands - The pwd Present Working Directory command====
  
 As a first command, let us type "​pwd":​ As a first command, let us type "​pwd":​
Line 270: Line 277:
 and press the enter key and press the enter key
  
-== Figure 2-3: Issuing a shell command ==+== Figure 2-2-2: Issuing a shell command ==
 {{:​chapter_2_-_the_linux_operating_system:​shell_pwd_screenshot.png?​nolink|}} {{:​chapter_2_-_the_linux_operating_system:​shell_pwd_screenshot.png?​nolink|}}
  
-pwd stands for "​__P__resent __W__orking __D__irectory"​ and returns the absolute path of the current directory, the folder in which we are virtually currently located within the file system, as show in figure 2.3. In this case, we are in the user "​andrea"​ home directory. In Linux, every user is assigned a home folder within the+pwd stands for "​__P__resent __W__orking __D__irectory"​ and returns the absolute path of the current directory, the folder in which we are virtually currently located within the file system, as show in figure 2-2-2. In this case, we are in the user "​andrea"​ home directory. In Linux, every user is assigned a home folder within the
  
 ''/​home''​ ''/​home''​
Line 280: Line 287:
  
 ''/​home/​andrea''​ ''/​home/​andrea''​
 +
 +==== Absolute Path Anatomy ====
  
 In this absolute path of the "​andrea"​ folder, as in all absolute paths, the first slash indicates the root folder, while the subsequent slashes in the path are just separators to delimitate the directories names. In this absolute path of the "​andrea"​ folder, as in all absolute paths, the first slash indicates the root folder, while the subsequent slashes in the path are just separators to delimitate the directories names.
  
-== Figure 2-4: The meaning of the slashes in an absolute path ==+== Figure 2-2-3: The meaning of the slashes in an absolute path ==
 {{ :​chapter_2_-_the_linux_operating_system:​slashes_in_absolute_paths.png?​nolink |}} {{ :​chapter_2_-_the_linux_operating_system:​slashes_in_absolute_paths.png?​nolink |}}
  
 When a user opens a terminal window, either locally or from a remote location (by connecting to the server by SSH, this will be discussed later on in this chapter), the default location within the file system is his home directory /​home/​username. When a user opens a terminal window, either locally or from a remote location (by connecting to the server by SSH, this will be discussed later on in this chapter), the default location within the file system is his home directory /​home/​username.
  
 +==== The ls shell command to list directory contents ====
 Let's have a look to the contents of the Linux root directory by using the "​ls"​ (__L__i__S__t) command. The "​ls"​ command can take as an optional argument the name of the directory of which we wish to list the contents. So if we wish to list the contents of the Root directory we can type: Let's have a look to the contents of the Linux root directory by using the "​ls"​ (__L__i__S__t) command. The "​ls"​ command can take as an optional argument the name of the directory of which we wish to list the contents. So if we wish to list the contents of the Root directory we can type:
  
Line 293: Line 303:
  
 Without arguments, it will list the contents of the present working directory, the one we "are in" when issuing the command. Without arguments, it will list the contents of the present working directory, the one we "are in" when issuing the command.
-== Figure 2-4: Listing the contents of the Root directory with the ls command ==+== Figure ​2-2-4: Listing the contents of the Root directory with the ls command ==
 {{ :​chapter_2_-_the_linux_operating_system:​listing_the_root_directory_contents.png?​nolink |}} {{ :​chapter_2_-_the_linux_operating_system:​listing_the_root_directory_contents.png?​nolink |}}
  
 You can check that the listed directories and files are the same we can look at with the graphical user interface on the same machine. In the graphical user interface, the Root folder is called "File System"​. You can check that the listed directories and files are the same we can look at with the graphical user interface on the same machine. In the graphical user interface, the Root folder is called "File System"​.
  
-== Figure 2-5: Listing the contents of the Root directory with the Ubuntu graphical interface ==+== Figure ​2-2-5: Listing the contents of the Root directory with the Ubuntu graphical interface ==
  
 {{ :​chapter_2_-_the_linux_operating_system:​graphical_root_directory_contents.png?​nolink |}} {{ :​chapter_2_-_the_linux_operating_system:​graphical_root_directory_contents.png?​nolink |}}
Line 311: Line 321:
  
 Actually the configuration files for Apache and PHP will only be present on the machine after we have installed a LAMP server (__L__inux, __A__pache, __P__HP, __M__ySql server). Actually the configuration files for Apache and PHP will only be present on the machine after we have installed a LAMP server (__L__inux, __A__pache, __P__HP, __M__ySql server).
 +
 +==== The cd shell command to change directory ====
  
 Let us introduce the Change Directory "​cd"​ command, that allows us to change our present working directory by moving around in the file system. If called with no argument, the cd command will return us to our default directory, our home directory. Let us introduce the Change Directory "​cd"​ command, that allows us to change our present working directory by moving around in the file system. If called with no argument, the cd command will return us to our default directory, our home directory.
Line 333: Line 345:
 to reflect our new current directory location. to reflect our new current directory location.
  
-== Figure 2-6: A shell session == +== Figure ​2-2-6: A shell session == 
-{{ :​chapter_2_-_the_linux_operating_system:​shell_session1.png?​nolink ​|}}+{{ :​chapter_2_-_the_linux_operating_system:​shell_session1.png |}}
  
 Please note, in the listing of the /etc content, the apache2 folder. As already mentioned before, this is the directory that contains all the apache web server configuration files. We will spend some time discussing those files and the apache configuration later in this chapter. Please note, in the listing of the /etc content, the apache2 folder. As already mentioned before, this is the directory that contains all the apache web server configuration files. We will spend some time discussing those files and the apache configuration later in this chapter.
Line 344: Line 356:
 A relative path is the position of a file/​directory with respect to our present working directory. Relative paths never start with a slash. Let us consider the example situation in the next figure. ​ A relative path is the position of a file/​directory with respect to our present working directory. Relative paths never start with a slash. Let us consider the example situation in the next figure. ​
  
-== Figure 2-7: sample linux filesystem ==+== Figure ​2-2-7: sample linux filesystem ==
  
 {{ :​chapter_2_-_the_linux_operating_system:​linux_filesystem_example.png?​direct |}} {{ :​chapter_2_-_the_linux_operating_system:​linux_filesystem_example.png?​direct |}}
Line 395: Line 407:
 So we now know how to use the "​cd"​ command in combination with a relative path in order to move up one directory (cd ..) or stay where we are (cd .). You might notice that latter one is exquisitely useless in practice, although it makes sense to mention it here, for educational purposes. Please note that each directory can contain several other directories,​ called the **child directories**,​ but can only have one single **parent directory**. ​ So we now know how to use the "​cd"​ command in combination with a relative path in order to move up one directory (cd ..) or stay where we are (cd .). You might notice that latter one is exquisitely useless in practice, although it makes sense to mention it here, for educational purposes. Please note that each directory can contain several other directories,​ called the **child directories**,​ but can only have one single **parent directory**. ​
  
-How can joe move to his seqs folder (see figure 2-7)? What is the relative path of /​home/​joe/​seqs with respect to /home/joe?+How can joe move to his seqs folder (see figure ​2-2-7)? What is the relative path of /​home/​joe/​seqs with respect to /home/joe?
  
 This is especially easy, it is simply: This is especially easy, it is simply:
Line 429: Line 441:
   * **relative path**: ../protein   * **relative path**: ../protein
  
-We encourage you to carefully understand each one of these examples, by also referring to figure 2-7 for a getting a "​visual"​ scheme of what is going on.+We encourage you to carefully understand each one of these examples, by also referring to figure ​2-2-7 for a getting a "​visual"​ scheme of what is going on.
  
 Since the absolute path is able to locate univocally a file/​directory in the filesystem, you might wonder why there is the need for such a thing as a relative path and all these dots notations. ​ Since the absolute path is able to locate univocally a file/​directory in the filesystem, you might wonder why there is the need for such a thing as a relative path and all these dots notations. ​
Line 470: Line 482:
 Let's have a look to a sample output Let's have a look to a sample output
  
-== Figure 2-8: Listing files with ls -la ==+== Figure ​2-2-8: Listing files with ls -la ==
 {{ :​chapter_2_-_the_linux_operating_system:​linux_ls-la_command_sample_output.png?​direct |}} {{ :​chapter_2_-_the_linux_operating_system:​linux_ls-la_command_sample_output.png?​direct |}}
  
Line 476: Line 488:
 We now have a output organized in several lines, one for each file, and several columns, that list different properties of the file. In order to be able to administer our Linux machine we need to fully understand this output. We now have a output organized in several lines, one for each file, and several columns, that list different properties of the file. In order to be able to administer our Linux machine we need to fully understand this output.
  
-== Figure 2-9: Understanding the ls -la output ==+== Figure ​2-2-9: Understanding the ls -la output ==
 {{ :​chapter_2_-_the_linux_operating_system:​understanding_the_linux_ls-la_output.png?​direct |}} {{ :​chapter_2_-_the_linux_operating_system:​understanding_the_linux_ls-la_output.png?​direct |}}
  
-The last column contains the file name. Please note, in figure 2-9 the first two files: "​."​ and "​.."​. These indicate, with the relative path notation we are now familiar with, the current directory and it's parent directory.+The last column contains the file name. Please note, in figure ​2-2-9 the first two files: "​."​ and "​.."​. These indicate, with the relative path notation we are now familiar with, the current directory and it's parent directory.
  
 We then have a few invisible files listed (because we used the "​a"​ option with the "​ls"​ command"​) such as .bash_history and .bash_logout. They are invisible because their names start with a dot. This has nothing to do with the dot that indicates the current directory, by the way. We then have a few invisible files listed (because we used the "​a"​ option with the "​ls"​ command"​) such as .bash_history and .bash_logout. They are invisible because their names start with a dot. This has nothing to do with the dot that indicates the current directory, by the way.
Line 485: Line 497:
 We also see a file called "​Desktop"​. This is a directory. Indeed, in Linux a directory is just a particular type of file.  We also see a file called "​Desktop"​. This is a directory. Indeed, in Linux a directory is just a particular type of file. 
  
-== Table 2-2: Linux file types ==+== Table 2-2-2: Linux file types ==
  
   * **-** Regular file   * **-** Regular file
Line 506: Line 518:
 Following the first character, we have other 9 characters that define the file's read, write and execute permissions for the owner, the group, everybody else. These "​rwxr-xr-x"​ notations might seem complicated at first. The goal of the next paragraph is to explain how this works, in simple terms. Following the first character, we have other 9 characters that define the file's read, write and execute permissions for the owner, the group, everybody else. These "​rwxr-xr-x"​ notations might seem complicated at first. The goal of the next paragraph is to explain how this works, in simple terms.
  
-== Figure 2-10: Understanding Linux files permissions - The 777 permission==+== Figure ​2-2-10: Understanding Linux files permissions - The 777 permission==
 {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_777.png |}} {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_777.png |}}
  
-As we can see in figure 2-10, there are also some numeric notations we need to deal with. We'll come to those in a moment. For now, let us concentrate on the first two lines of figure 2-10. The orange line shows the nine characters. They are in fact three groups of three characters each. The first group of three characters defines the permissions for the file's owner. Let's look closely at these three characters, one by one. +As we can see in figure ​2-2-10, there are also some numeric notations we need to deal with. We'll come to those in a moment. For now, let us concentrate on the first two lines of figure ​2-2-10. The orange line shows the nine characters. They are in fact three groups of three characters each. The first group of three characters defines the permissions for the file's owner. Let's look closely at these three characters, one by one. 
   - The first can be either "​r",​ which indicates **read permission**,​ or "​-",​ which indicates no read permission.   - The first can be either "​r",​ which indicates **read permission**,​ or "​-",​ which indicates no read permission.
   - The second can be "​w",​ which indicates **write permission**,​ or "​-",​ which indicates no write permission   - The second can be "​w",​ which indicates **write permission**,​ or "​-",​ which indicates no write permission
Line 515: Line 527:
 In the example in figure 2-10, the owner has a "​rwx"​ permission, which means he can read, write and execute the file. If he could only read and write, but not execute, this would have been "​rw-",​ as in the example in figure 2-11. In the example in figure 2-10, the owner has a "​rwx"​ permission, which means he can read, write and execute the file. If he could only read and write, but not execute, this would have been "​rw-",​ as in the example in figure 2-11.
  
-== Figure 2-11: Understanding Linux files permissions - The 644 permission ==+== Figure ​2-2-11: Understanding Linux files permissions - The 644 permission ==
 {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_644.png |}} {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_644.png |}}
  
Line 527: Line 539:
 This three characters scheme is repeated for the owner of the file, the group, and everybody else (others), this is why we have 9 characters to define permissions in the output of the ls -l command. ​ This three characters scheme is repeated for the owner of the file, the group, and everybody else (others), this is why we have 9 characters to define permissions in the output of the ls -l command. ​
  
-For each group of three, we can summarize the permission with a single number, as just shown. So the final permission for a file becomes a group of three numbers, such as for example "​777"​ (figure 2-10), "​644"​ (figure 2-11) or "​755"​ (figure 2-12).+For each group of three, we can summarize the permission with a single number, as just shown. So the final permission for a file becomes a group of three numbers, such as for example "​777"​ (figure ​2-2-10), "​644"​ (figure ​2-2-11) or "​755"​ (figure ​2-2-12).
  
-== Figure 2-12: Understanding Linux files permissions - The 755 permission ==+== Figure ​2-2-12: Understanding Linux files permissions - The 755 permission ==
 {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_755.png |}} {{ :​chapter_2_-_the_linux_operating_system:​understanding_linux_files_permissions_755.png |}}
  
Line 543: Line 555:
  
 ==== Chapter Sections ==== ==== Chapter Sections ====
-  ​* [[chapter_2_-_the_linux_operating_system:​start|Chapter 2: Introduction]]+<box 100% left round blue | **Chapter 2**> 
 +<​html>&​nbsp;</​html>​ 
 +  ​* [[chapter_2_-_the_linux_operating_system:​start|Introduction]]
   * **2-1:** [[chapter_2_-_the_linux_operating_system:​installing ubuntu linux|Installing Ubuntu Linux]]   * **2-1:** [[chapter_2_-_the_linux_operating_system:​installing ubuntu linux|Installing Ubuntu Linux]]
-  * **2-1:** The Linux Filesystem+  * **2-2:** [[chapter_2_-_the_linux_operating_system:​the linux filesystem |The Linux Filesystem]]
   * **2-3:** [[chapter_2_-_the_linux_operating_system:​basic linux shell commands |Basic Linux Shell Commands]]   * **2-3:** [[chapter_2_-_the_linux_operating_system:​basic linux shell commands |Basic Linux Shell Commands]]
   * **2-4:** [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Installing and using Open SSH Server for remote connections]] ​   * **2-4:** [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Installing and using Open SSH Server for remote connections]] ​
-  * **2-5:​** ​ [[chapter_2_-_the_linux_operating_system:​installing linux apache php mysql lamp server |Installing a LAMP (Linux, Apache, PHP, MySQL) Server]] ​+  * **2-5:​** ​ [[chapter_2_-_the_linux_operating_system:​installing linux apache php mysql lamp server |Installing a LAMP (Linux, Apache, PHP, MySQL) Server]] 
 +  * **2-6:** [[chapter_2_-_the_linux_operating_system:​apache web server configuration |Apache Web Server Configuration]] 
 +  * **2-7:** [[chapter_2_-_the_linux_operating_system:​setting up a linux web server|Setting up a Linux Web Server - Reference Summary]] 
 + 
 + 
 +[[..:​start|Back to index]] 
 +</​box>​
chapter_2_-_the_linux_operating_system/the_linux_filesystem.1359139531.txt.gz · Last modified: 2013/01/25 13:45 by cellbiol