Difference between revisions of "User:Mukund-pondkule-6a11@uni-paderborn.de"

From HPC Wiki
Jump to navigation Jump to search
Line 566: Line 566:
  
 
Warning: Be very careful, when editing configuration files. A faulty configuration file may prevent a user from login to computer.
 
Warning: Be very careful, when editing configuration files. A faulty configuration file may prevent a user from login to computer.
 +
 +
 +
=== Various tips === <!--T:8-->
 +
 +
Video: Slide 130 - 136 (7 pages), 5 min 10 sec (Text + Demo)
 +
 +
<gallery mode="packed" heights="250" perrow="1">
 +
Linux intro.png|
 +
</gallery>
 +
 +
Text and Slides
 +
 +
Quiz:
 +
1. How will you find a specific command in history ? HINT: use grep with history, how to use it? 
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    | 
 +
      history | grep cd
 +
    |}
 +
 +
2. How can you compare two files and display a list of the difference? HINT: <code>man diff</code> 
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    | 
 +
      diff file1 file2
 +
    |}
 +
 +
Tips: Please make backups regularly!
 +
 +
Warning: Please make backups regularly!
 +
 +
Exercises in Terminal (slides 137):
 +
1. Find out the number of CPUs and amount of memory you have.
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    |
 +
      There are multiple ways to find out the number of CPUs and amount of memory on Linux computer.
 +
      the number of CPUs.
 +
      1.  <code>lscpu</code>: the following is an example output of the  <code>lscpu</code> command:
 +
      <syntaxhighlight lang="c">
 +
        CPU(s):                40
 +
        On-line CPU(s) list:  0-39
 +
      </syntaxhighlight>
 +
      Brief description:
 +
            <code>CPU(s):                40</code>: this computer contains 40 CPU cores.
 +
            <code>On-line CPU(s) list:  0-39</code>: all 40 CPU cores are active.
 +
      2.  <code>grep -c processor /proc/cpuinfo</code>: This command uses  <code>grep</code> to count the number of lines that match  <code>processor</code> in  <code>/proc/cpuinfo</code>. The following is an example output:
 +
      <syntaxhighlight lang="c">
 +
        $ grep -c processor /proc/cpuinfo
 +
        40
 +
      </syntaxhighlight>
 +
      As can be seen, there are 40 CPU cores in this computer.
 +
      the amount of memory
 +
      1. <code>vmstat -s</code>: the following is an example output of the <code>vmstat</code> command:
 +
        <syntaxhighlight lang="c">
 +
          196698736 K total memory
 +
          4982596 K used memory
 +
        </syntaxhighlight>
 +
        <code>vmstat</code> reports the virtual memory statistics.
 +
        The <code>-s</code> option displays a table for memory statistics.
 +
        In this example there are 196 GB memory in total in the computer and 5 GB memory is used.
 +
      2. <code>grep Mem[TF] /proc/meminfo</code>: This command uses <code>grep</code> to search for either <code>MemT</code> or <code>MemF</code> in <code>/proc/meminfo</code> and the following is an example output:
 +
        <syntaxhighlight lang="c">
 +
          $ grep Mem[TF] /proc/meminfo
 +
          MemTotal:      196698740 kB
 +
          MemFree:        113479460 kB
 +
        </syntaxhighlight>
 +
          As can be seen, MemT and MemF are matched by MemTotal and MemFree, respectively. The total amount of memory in the computer is 196 GB and there are 113 GB are freely available.
 +
    |
 +
    |}
 +
 +
2. Permanently change your vim color scheme.
 +
  {| role="presentation" class="wikitable mw-collapsible mw-collapsed"
 +
    | <strong>Answer:</strong>
 +
    |-
 +
    | 
 +
      Your personal vim configuration file is ~/.vimrc. In this file you can change the vim color scheme permanently. For example, the following setting uses the desert color scheme:
 +
      <code>colorscheme desert</code>
 +
      But beware of this permanent change of vim color scheme, because different color schemes may be preferred by different people. The vim color scheme recommended by others may not the best choice for you.
 +
    |}
 +
 +
 +
=== Beyond the cluster === <!--T:8-->
 +
 +
Video: Slide 139 - 141 (3 pages), 2 min 30 sec (Text)
 +
 +
<gallery mode="packed" heights="250" perrow="1">
 +
Linux intro.png|
 +
</gallery>
 +
 +
Text and Slides
 +
 +
Tips: no tips in this section
 +
 +
Warning: no warning in this section
 +
 +
Exercises in Terminal: no exercises in this section

Revision as of 17:02, 8 September 2020

An Introduction to the Linux Operating System and Command Line. The course provides students with a hands-on approach for learning Linux through assignments and projects.

Historical Background

Video: Slide 17 - 23 (7 pages), 5 min 45 sec (Text) + 15 sec (Quiz)

Text and slides path


Quiz:

1. Are all Top 500 supercomputers using Linux in HPC?
  A: Yes
  B: No
2. What does GNU stands for?
  A. GNU's Not Unix
  B. Geek Needed Unix
  C. General Unix
  D. General Unix
  E. None of the Above
  Answer: a)

Exercises in Terminal: no exercises in this section

The Command Line

Video: Slide 17 - 23 (7 pages), 5 min 45 sec (Text) + 15 sec (Quiz)


Text and slides path


Quiz:

1. Which keys can be used for command history?
  A: up- and down-arrow keys
  B: Page-up and Page-down keys
Info:  Working directory in console reminds user, where they are. (page 3)
Warning:  In command line user may forget where they are (page 2). Child processes may stop, if parent shell exits (page 2).

Exercises in Terminal:

1. What's your username on a Linux computer?
  There are two ways to find your username on a Linux computer 
2. What's the hostname of a Linux computer?
  There are two ways to find the hostname on a Linux computer.
3. What's your current working directory on a Linux computer?
   There are two ways to find your current working directory on a Linux computer.
4.  Use up- and down-arrow keys to see the command history.
5.  Run sleep 1h command and wait, then use Ctrl-C to kill it.

Directory structure

Video: Slide 33 - 48 (16 pages), 5 min 45 sec (Text + Demo + Quiz) + 15 sec (Tips and Warning)


Text and slides path


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?
  A: Nothing it stays in /var/log/.
  B: It goes to your home directory.
  C: It goes to the filesystem root
  D: The shell prompt turns into a shark and eats you.
  E: It’s an error.
  F: The shell stops having a working directory.
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.

Files

Video: Slide 51 - 56 (6 pages), 5 min 30 sec (Text + Demo + Quiz) + 15 sec (Tips and Warning)

Text and slides path


Quiz:

1. Can you copy directory with cp <old_dir> <new_dir> ? 
  A: Yes
  B: No, -r option is needed for copying directory
Warning:  rm -f: no confirmation! Use with care (page 3). Wildcards expand before given to program (page 6).

Exercises in Terminal:

1. Use the find command to search for files, whose name ends with dat, in your home directory.
2. Use the find command to search for directories, whose name begins with test and ends with _dir, in your home directory.

Text display, search

Video: Slide 58 - 64 (7 pages), 5 min 40 sec (Text + Demo) + 15 sec (Quiz)


Text and slides path

Quiz:

1. Which command can be used to append text to filename?
  A: command > filename
  B: command >> filename
2. How do I find all files containing specific text on Linux?
   HINT: use grep command

Exercises in Terminal (slide 65):

1. Create a file using cat (some filename) and write some text in it as below. than use grep to find and display the line number and the line with the word Alan in the file.
        the best way to predict
        the future is to invent it
        –  Alan Kay

Processes and permissions

Video: Slide 67 - 88 (22 pages), 7 min 40 sec (Text + Demo)

Text and slides path

Quiz:

1. Which command can prevent other users not in your group from writing to input.dat? 
  A: chmod u-w input.dat
  B: chmod o-w input.dat
  C: chmod g-w input.dat

Exercises in Terminal (slide 89):

1. Create an empty file, make it read-only, make it executable.
2. Start a process (e.g. sleep 10m)
3. Start a process, bring it into background/foreground.

The vim text editor

Video: Slide 91 - 99 (9 pages), 5 min 0 sec (Text + Demo) + 15 sec (Quiz)

Text and slides path

Quiz:

1. How to enter the insert mode of vim ? 
  A: press enter key
  B: press i key
  C: press Esc key
2. How would you open a file in read-only mode using the vim editor ? 
  Hint: In terminal man vim


 Tips-If you forget which mode you are in while using vim, just keep pressing Esc.


Exercises in Terminal (slide 100):

1.  Create a vim file and write some text in it with insert (pressing i) and than undo and redo the changes. 

Shell scripting, environment variables

Video: Slide 102 - 114 (13 pages), 7 min 0 sec (Text + Demo)

Text and Slides

Quiz:

1. Which bash command below assigns "value" to variable var? 
  A: var="value"
  B: var = "value"
  C: var=="value"

Exercises in Terminal (slides 115 - 116) and solution (slide 117):

1. a. Write a script that
   b. Prints an environment variable
   c. Saves the output of the date command to a variable
   d. Sleeps briefly
   e. Prints the new and old date and time
2. Find a way to execute a script without setting execute permissions.
3. Find out how to do other programming things in bash (e.g. functions, classes). How convenient do they look?
4. Look at different ways you can define if conditions.
5. Find out what different types of quotes (single ' vs. double ") do?
6. create an shell variable MYIDENTITY and export it as below: 
   $ export MYIDENTITY=whoami
   How will you list the shell variable MYIDENTITY?
   Execute the shell variable MYIDENTITY, what is the output? 

System configuration files

Video: Slide 119 - 128 (10 pages), 6 min 50 sec (Text + Demo)

Text and Slides

Quiz:

1. In which system file could you find the CPU information of a Linux computer?  
  A: /dev/cpuinfo
  B: /sys/cpuinfo
  C: /proc/cpuinfo

Warning: Be very careful, when editing configuration files. A faulty configuration file may prevent a user from login to computer.


Various tips

Video: Slide 130 - 136 (7 pages), 5 min 10 sec (Text + Demo)

Text and Slides

Quiz:

1. How will you find a specific command in history ? HINT: use grep with history, how to use it?  
2. How can you compare two files and display a list of the difference? HINT: man diff  

Tips: Please make backups regularly!

Warning: Please make backups regularly!

Exercises in Terminal (slides 137):

1. Find out the number of CPUs and amount of memory you have.
2. Permanently change your vim color scheme. 


Beyond the cluster

Video: Slide 139 - 141 (3 pages), 2 min 30 sec (Text)

Text and Slides

Tips: no tips in this section

Warning: no warning in this section

Exercises in Terminal: no exercises in this section