Difference between revisions of "Introduction to Linux in HPC/Various tips"
Introduction to Linux in HPC/Various tips
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 31: | Line 31: | ||
very brief into to sed | very brief into to sed | ||
just mention awk | just mention awk | ||
+ | |||
+ | |||
+ | |||
+ | === Quiz === <!--T:5--> | ||
+ | |||
+ | |||
+ | {{hidden begin | ||
+ | |title = How will you find a specific command in history ? HINT: use grep with history, how to use it? | ||
+ | }} | ||
+ | <quiz display=simple> | ||
+ | { | ||
+ | |type="()"} | ||
+ | + Click and submit to see the answer | ||
+ | || <code>history | grep cd</code> | ||
+ | </quiz> | ||
+ | {{hidden end}} | ||
+ | |||
+ | {{hidden begin | ||
+ | |title = How can you compare two files and display a list of the difference? HINT: <code>man diff</code> | ||
+ | }} | ||
+ | <quiz display=simple> | ||
+ | { | ||
+ | |type="()"} | ||
+ | + Click and submit to see the answer | ||
+ | || <code>diff file1 file2</code> | ||
+ | </quiz> | ||
+ | {{hidden end}} | ||
+ | |||
+ | |||
+ | {{Warning|mode=info|text= '''Please make backups regularly!'''}} | ||
+ | |||
+ | {{Warning|mode=warn|text= '''Please make backups regularly!'''}} | ||
+ | |||
+ | |||
+ | === Exercises in Terminal (slide 137) === <!--T:5--> | ||
+ | |||
+ | 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="bash"> | ||
+ | CPU(s): 40 | ||
+ | On-line CPU(s) list: 0-39 | ||
+ | </syntaxhighlight lang="bash"> | ||
+ | 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="bash"> | ||
+ | $ 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="bash"> | ||
+ | 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="bash"> | ||
+ | $ 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. | ||
+ | |} |
Revision as of 11:10, 2 October 2020
Video
Linux Introduction Slides 130 - 136 (7 pages)
Slide Layout
page 1: Please make backups regularly! page 2: du command df command page 3: history command the ~/.bash_history file page 4: ln command and syntax page 5: watch command and the usage page 6: $(( )) as integer calculator page 7: 60 sec very brief into to sed just mention awk
Quiz
How will you find a specific command in history ? HINT: use grep with history, how to use it?
How can you compare two files and display a list of the difference? HINT:
man diff
Info: | Please make backups regularly! |
Warning: | Please make backups regularly! |
Exercises in Terminal (slide 137)
1. Find out the number of CPUs and amount of memory you have.
Answer: | |
There are multiple ways to find out the number of CPUs and amount of memory on Linux computer. the number of CPUs. 1. CPU(s): 40
On-line CPU(s) list: 0-39
</syntaxhighlight lang="bash">
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="bash">
$ grep -c processor /proc/cpuinfo
40
As can be seen, there are 40 CPU cores in this computer. the amount of memory 1. 196698736 K total memory
4982596 K used memory
$ grep Mem[TF] /proc/meminfo
MemTotal: 196698740 kB
MemFree: 113479460 kB
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.
Answer: |
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:
|