Difference between revisions of "Introduction to Linux in HPC/Linux Directory Structure"

From HPC Wiki
Introduction to Linux in HPC/Linux Directory Structure
Jump to navigation Jump to search
(Created page with "__TOC__ === Video === <!--T:5--> <youtube width="600" height="400" right>IfD9IPixgpo</youtube> [https://git-ce.rwth-aachen.de/hpc.nrw/ap2/tutorials/linux/-/blob/master/Slid...")
 
m (Tweak category sorting)
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Category:Tutorials|Linux Directory Structure]]<nowiki />
 +
{{DISPLAYTITLE:Linux Directory Structure}}<nowiki />
 +
{{Syllabus Introduction to Linux}}<nowiki />
 
__TOC__
 
__TOC__
 +
 +
This part of the tutorial introduces the directory structure on a Linux system and shows how to navigate in it. It explains how a path looks like in Linux, which standard directory structure is shared by most systems and how to navigate from one directory to another.
  
 
=== Video === <!--T:5-->
 
=== Video === <!--T:5-->
  
<youtube width="600" height="400" right>IfD9IPixgpo</youtube>
+
<youtube width="600" height="340" right>rV7Hwi__zZo</youtube>
  
[https://git-ce.rwth-aachen.de/hpc.nrw/ap2/tutorials/linux/-/blob/master/Slides/Linux_Intro/Linux_Intro.pdf Linux Introduction] Slides 33 - 48 (16 pages)
+
([[Media:HPC.NRW_Introduction_to_Linux_in_HPC_03_Linux_Directory_Structure.pdf|Slides as pdf]])
  
=== Slide Layout === <!--T:5-->
+
=== Quiz === <!--T:5-->
  
    page 1:
+
{{hidden begin
        Windows: drive letter + backslash (C:)
+
|title = 1. Which one is the top directory in Linux?
        Linux: standard tree directory structure
+
}}
        Absolute path: starts with /
+
<quiz display=simple>
        Relative path: w.r.t. working directory
+
{
    page 2 - 11:
+
|type="()"}
        Animation for directory structure
+
+  <code>/</code>
        example directories
+
|| Explanation: The tree structure for directory is used in Linux system. Therefore the top directory in Linux is /. The /home directory may be an upper level directory for all non-root users. The last option C:\ represents the C drive on Windows.
    page 12:
+
-  <code>/home</code>
        everything is a file: /dev and /proc
+
||
        program/script can be found with which
+
-  <code>C:\</code>
        special directories: ., .. and ~
+
||  That's Windows
    page 13:
+
</quiz>
        cd command
+
{{hidden end}}
    page 14: 40 sec
 
        ls command
 
    page 15:
 
        specific commands: Ctrl+key (C, Z, D), exit and clear
 
    page 16:
 
        no undo
 
        make sure what you want to do
 
  
  
=== Quiz === <!--T:5-->
+
{{hidden begin
 +
|title = 2. The command <code>cd</code> without arguments: if you start in <code>/var/log/</code> and run <code>cd</code> with no arguments, what do you expect will happen?
 +
}}
 +
<quiz display=simple>
 +
{
 +
|type="()"}
 +
- Nothing it stays in <code>/var/log/</code>
 +
||
 +
+ It goes to your home directory
 +
|| Explanation: It goes to your home directory. <code>cd</code> without arguments is a shortcut to take you home. As long as your home directory exists, you can always go home
 +
- It goes to the filesystem root
 +
|| 
 +
- The shell stops having a working directory
 +
||
 +
- It’s an error
 +
||
 +
- The shell prompt turns into a shark and eats you
 +
||
 +
</quiz>
 +
{{hidden end}}
 +
 
  
 
{{hidden begin  
 
{{hidden begin  
|title = Which keys can be used for command history?
+
|title = 3. Which of these oversimplifications describes the directory structure in a Linux system best?
 
}}
 
}}
 
<quiz display=simple>
 
<quiz display=simple>
 
{
 
{
 
|type="()"}
 
|type="()"}
+ A. up- and down-arrow keys
+
- Everything is a directory
|| Explanation: up- and down-arrow keys (↑ and ↓) can be used for command history. The behavior of Page-up and Page-down keys depends on the setting of a terminal. But normally the command history is not available by using the Page-up and Page-down keys.
 
- B. Page-up and Page-down keys
 
 
||  
 
||  
 +
+ Everything is a file
 +
|| Explanation: In Linux, directories are files with a directory flag. There are even more "special" files, like <code>/dev/null/</code>, <code>/proc/cpuinfo/</code> or links.
 +
- Directories are files and files are directories
 +
|| Explanation:  Directories are files, but files are not directories
 +
- All of the above
 +
||
 
</quiz>
 
</quiz>
 
{{hidden end}}
 
{{hidden end}}
  
  
{{Warning|mode=info|text= '''  Working directory in console reminds user, where they are. (page 3)'''}}
+
{{Warning|mode=warn|text= '''no undo and make sure what you want to do (page 48)'''}}
 +
 
 +
=== Exercises in Terminal=== <!--T:5-->
 +
 
 +
  4. Go to a specific subfolder of a folder (example: <code>cd Documents/courses/</code>) and get back to the home directory using <code>cd</code> command. List 3 different ways to do it using one command. Check after every action your path with <code>pwd</code> command.
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    |
 +
      <code>cd</code>
 +
      <code>cd ~</code>
 +
      <code>cd $HOME</code>
 +
        the last option $HOME is an environment variable. You will learn about environment variables later.
 +
    |}
 +
     
 +
5. Go to the directory <code>/tmp</code> and jump between <code>/tmp</code> and your home directory back and forth. Check after every action your path with <code>pwd</code> command.
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    |
 +
        <code>cd /tmp</code>
 +
        <code>cd -</code>
 +
        <code>cd -</code> with <code>cd -</code> you change back to the previous working directory, pass the dash <code>-</code> character as an argument to the <code>cd</code> command.
 +
    |}
 +
 
 +
 
 +
{{hidden begin
 +
|title = Bonus question: How do you copy and paste in the Linux terminal?
 +
}}
 +
<quiz display=simple>
 +
{
 +
|type="()"}
 +
- Ctrl-C & Ctrl-V
 +
|| That's Windows
 +
- <code>yy</code> & <code>pp</code>
 +
|| That's vim
 +
+ Middle Mouse
 +
|| Alternative Solution: Ctrl-Shift-C & Ctrl-Shift-V
 +
-You can't, that's a Windows feature.
 +
||
 +
</quiz>
 +
{{hidden end}}
 +
 
  
{{Warning|mode=warn|text= '''  In command line user may forget where they are. (page 2)'''</br>
+
{{Tutorial Navigation
    '''Child processes may stop, if parent shell exits. (page 2)'''}}
+
| previous = [[Introduction_to_Linux_in_HPC/The_Command_Line | The Command Line ]]
 +
| main = [[Introduction_to_Linux_in_HPC | Overview ]]
 +
| next = [[Introduction_to_Linux_in_HPC/Files | Files ]]
 +
}}

Latest revision as of 17:20, 4 December 2020

Tutorial
Title: Introduction to Linux in HPC
Provider: HPC.NRW

Contact: tutorials@hpc.nrw
Type: Multi-part video
Topic Area: HPC Platforms
License: CC-BY-SA
Syllabus

1. Background and History
2. The Command Line
3. Linux Directory Structure
4. Files
5. Text display and search
6. Users and permissions
7. Processes
8. The vim text editor
9. Shell scripting
10. Environment variables
11. System configuration
12. SSH Connections
13. SSH: Graphics and File Transfer
14. Various tips

This part of the tutorial introduces the directory structure on a Linux system and shows how to navigate in it. It explains how a path looks like in Linux, which standard directory structure is shared by most systems and how to navigate from one directory to another.

Video

(Slides as pdf)

Quiz

1. Which one is the top directory in Linux?

/
/home
C:\


2. The command cd without arguments: if you start in /var/log/ and run cd with no arguments, what do you expect will happen?

Nothing it stays in /var/log/
It goes to your home directory
It goes to the filesystem root
The shell stops having a working directory
It’s an error
The shell prompt turns into a shark and eats you


3. Which of these oversimplifications describes the directory structure in a Linux system best?

Everything is a directory
Everything is a file
Directories are files and files are directories
All of the above


Warning:  no undo and make sure what you want to do (page 48)

Exercises in Terminal

4. Go to a specific subfolder of a folder (example: cd Documents/courses/) and get back to the home directory using cd command. List 3 different ways to do it using one command. Check after every action your path with pwd command.
5. Go to the directory /tmp and jump between /tmp and your home directory back and forth. Check after every action your path with pwd command.


Bonus question: How do you copy and paste in the Linux terminal?

Ctrl-C & Ctrl-V
yy & pp
Middle Mouse
You can't, that's a Windows feature.



<< The Command Line

Overview

Files >>