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...")
 
Line 35: Line 35:
  
 
{{hidden begin  
 
{{hidden begin  
|title = Which keys can be used for command history?
+
|title = 1. Which one is the top directory in Linux?
 
}}
 
}}
 
<quiz display=simple>
 
<quiz display=simple>
 
{
 
{
 
|type="()"}
 
|type="()"}
+ A. up- and down-arrow keys
+
+ A: /
|| 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.
+
|| 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.
- B. Page-up and Page-down keys
+
- B. /home
 +
||
 +
- C. C:\
 
||  
 
||  
 
</quiz>
 
</quiz>
Line 48: Line 50:
  
  
{{Warning|mode=info|text= ''' Working directory in console reminds user, where they are. (page 3)'''}}
+
{{hidden begin
 +
|title = 2. The command 'cd ' without arguments : if you start in var/log/ and run cd with no arguments, what do you expect will happen?
 +
}}
 +
<quiz display=simple>
 +
{
 +
|type="()"}
 +
- Nothing it stays in /var/log/
 +
||
 +
+ It goes to your home directory
 +
|| Explanation: It goes to your home directory. cd 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}}
 +
 
 +
 
 +
{{Warning|mode=info|text= '''no tips in this section'''}}
 +
 
 +
{{Warning|mode=warn|text= '''no undo and make sure what you want to do (page 16)'''}}
 +
 
 +
 
 +
=== Exercises in Terminal (slide 49)=== <!--T:5-->
  
{{Warning|mode=warn|text= ''' In command line user may forget where they are. (page 2)'''</br>
+
1. 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.
     '''Child processes may stop, if parent shell exits. (page 2)'''}}
+
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    |
 +
        cd
 +
        cd ~
 +
        cd $HOME
 +
        the last option $HOME is an enviornment variable. You will learn about enviornment variables later.
 +
    |}
 +
     
 +
  2. 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.
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
     |-
 +
    |
 +
        cd /tmp
 +
        cd -
 +
        cd - with cd - you change back to the previous working directory, pass the dash (-) character as an argument to the cd command.
 +
    |}

Revision as of 17:32, 1 October 2020

Video

Linux Introduction Slides 33 - 48 (16 pages)

Slide Layout

   page 1: 
       Windows: drive letter + backslash (C:)
       Linux: standard tree directory structure
       Absolute path: starts with /
       Relative path: w.r.t. working directory
   page 2 - 11: 
       Animation for directory structure
       example directories
   page 12: 
       everything is a file: /dev and /proc
       program/script can be found with which
       special directories: ., .. and ~
   page 13: 
       cd command
   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

1. Which one is the top directory in Linux?

A: /
B. /home
C. 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


Info:  no tips in this section


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


Exercises in Terminal (slide 49)

1. 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.
2. 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.