@@ -0,0 +1,568 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-02-02 Thu 16:34 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab 1 Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab 1 Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org7571a9d">1. About this document</a></li> | |||||
<li><a href="#orgf4668cc">2. Exercise 1</a></li> | |||||
<li><a href="#orge29640a">3. Questions</a> | |||||
<ul> | |||||
<li><a href="#orge1aa2bd">3.1. Using hostname command:</a></li> | |||||
<li><a href="#orgfd20bdc">3.2. Arch Linux.</a></li> | |||||
<li><a href="#orge186e45">3.3. The root directory is “/”</a></li> | |||||
<li><a href="#orgc55cfc1">3.4. /bin/bash vs /bin/sh</a></li> | |||||
<li><a href="#org78ddece">3.5. Bash manual</a></li> | |||||
<li><a href="#org65d1d72">3.6. Linux distributions I want to try</a> | |||||
<ul> | |||||
<li><a href="#orgf7d803e">3.6.1. NixOS</a></li> | |||||
<li><a href="#org2fdefff">3.6.2. Gentoo Linux</a></li> | |||||
<li><a href="#org9c9b380">3.6.3. Artix Linux</a></li> | |||||
<li><a href="#org1bf8e90">3.6.4. LFS</a></li> | |||||
<li><a href="#org896f88e">3.6.5. Alpine Linux</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgc4925a6">3.7. POSIX</a></li> | |||||
<li><a href="#org520649a">3.8. Advantages of POSIX standards</a></li> | |||||
<li><a href="#org7b5efac">3.9. Slackware vs Debian</a></li> | |||||
<li><a href="#org12183b1">3.10. uname -a</a></li> | |||||
</ul> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org7571a9d" class="outline-2"> | |||||
<h2 id="org7571a9d"><span class="section-number-2">1.</span> About this document</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<p> | |||||
I use Org mode in Emacs to write documents and will use it throughout the course. | |||||
It has a super useful feature: it can evaluate the code on the fly and save results in the buffer. | |||||
Also it’s easy to use latex inside Org mode. That’s why I will use Org mode for this course. | |||||
If there are any problems with that, please report in the comments in Moodle. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgf4668cc" class="outline-2"> | |||||
<h2 id="orgf4668cc"><span class="section-number-2">2.</span> Exercise 1</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">lsb_release -a | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
-e LSB Version: n/a | |||||
-e Distributor ID: Arch | |||||
-e Description: Arch Linux | |||||
-e Release: rolling | |||||
-e Codename: n/a | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">whoami | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
rinri | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">users | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
rinri | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">pwd</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
/home/rinri/edu/sna | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">ls</span> -la | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
total 224 | |||||
drwxr-xr-x 2 rinri users 4096 Feb 2 15:47 . | |||||
drwxr-xr-x 25 rinri users 4096 Feb 2 14:13 .. | |||||
-rw-r--r-- 1 rinri users 20424 Feb 2 16:32 lab1.html | |||||
-rw-r--r-- 1 rinri users 6592 Feb 2 16:32 lab1.org | |||||
-rw-r--r-- 1 rinri users 190030 Feb 2 15:45 lab1.pdf | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cd</span> ~/library | |||||
<span style="color: #c792ea;">ls</span> -la | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org95787e4"> | |||||
total 17260 | |||||
drwxr-xr-x 2 rinri users 4096 Jan 8 10:47 . | |||||
drwx--x---+ 74 rinri users 4096 Feb 2 16:31 .. | |||||
-rw-r--r-- 1 rinri users 6556637 Jan 8 10:47 Andrew S. Tanenbaum - Modern Operating Systems.pdf | |||||
lrwxrwxrwx 1 rinri users 38 Aug 3 2022 cormen-algos.pdf -> /home/rinri/data/docs/cormen-algos.pdf | |||||
lrwxrwxrwx 1 rinri users 93 Aug 3 2022 genki -> /home/rinri/data/docs/Banno E., Ikeda Y., Ohno Y., Shinagawa Ch., Tokashiki K. - Genki - 2020 | |||||
-rw-r--r-- 1 rinri users 213363 Jan 8 10:47 ipfs-p2p-file-system.pdf | |||||
-rwxr-xr-x 1 rinri users 66 Aug 3 2022 library.sh | |||||
-rw-r--r-- 1 rinri users 2658531 Jan 8 10:47 Stroustrup B. - A Tour of C++ - Second Edition - 2018.pdf | |||||
-rw-r--r-- 1 rinri users 8220353 Jan 8 10:47 TRENCH_FREE_DIFFEQ_I.PDF | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> /etc/shells | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
# Pathnames of valid login shells. | |||||
# See shells(5) for details. | |||||
/bin/sh | |||||
/bin/bash | |||||
/bin/zsh | |||||
/usr/bin/zsh | |||||
/usr/bin/git-shell | |||||
/bin/dash | |||||
</pre> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">SHELL</span><span style="color: #c3e88d;">"</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
/bin/zsh | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orge29640a" class="outline-2"> | |||||
<h2 id="orge29640a"><span class="section-number-2">3.</span> Questions</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
</div> | |||||
<div id="outline-container-orge1aa2bd" class="outline-3"> | |||||
<h3 id="orge1aa2bd"><span class="section-number-3">3.1.</span> Using hostname command:</h3> | |||||
<div class="outline-text-3" id="text-3-1"> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">hostname | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
akemi | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgfd20bdc" class="outline-3"> | |||||
<h3 id="orgfd20bdc"><span class="section-number-3">3.2.</span> Arch Linux.</h3> | |||||
<div class="outline-text-3" id="text-3-2"> | |||||
<p> | |||||
It’s a rolling-release distribution. That’s why there is no “version”. I’ve been using it for several years. Used lsb_release -a command to check the info. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orge186e45" class="outline-3"> | |||||
<h3 id="orge186e45"><span class="section-number-3">3.3.</span> The root directory is “/”</h3> | |||||
</div> | |||||
<div id="outline-container-orgc55cfc1" class="outline-3"> | |||||
<h3 id="orgc55cfc1"><span class="section-number-3">3.4.</span> /bin/bash vs /bin/sh</h3> | |||||
<div class="outline-text-3" id="text-3-4"> | |||||
<p> | |||||
/bin/bash is a path to the bash shell. Whereas /bin/sh, on most of the systems, is a symbolic link to a POSIX-compliant shell. In many cases, it’s linked to bash. On my machine, it’s dash (it’s usually faster if the script is POSIX-compliant) | |||||
</p> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">ls</span> -l /bin/sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
lrwxrwxrwx 1 root root 4 Jul 3 2022 /bin/sh -> dash | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org78ddece" class="outline-3"> | |||||
<h3 id="org78ddece"><span class="section-number-3">3.5.</span> Bash manual</h3> | |||||
<div class="outline-text-3" id="text-3-5"> | |||||
<ol class="org-ol"> | |||||
<li>–verbose - When verbose mode is used, bash doesn’t hide extra information (prints it), including all the steps done of a script, bashrc commands, and other info.</li> | |||||
<li>–help - shows help message</li> | |||||
<li>–rcfile file - use “file” as a initialization file instead of ~/.bashrc</li> | |||||
</ol> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org65d1d72" class="outline-3"> | |||||
<h3 id="org65d1d72"><span class="section-number-3">3.6.</span> Linux distributions I want to try</h3> | |||||
<div class="outline-text-3" id="text-3-6"> | |||||
</div> | |||||
<div id="outline-container-orgf7d803e" class="outline-4"> | |||||
<h4 id="orgf7d803e"><span class="section-number-4">3.6.1.</span> NixOS</h4> | |||||
<div class="outline-text-4" id="text-3-6-1"> | |||||
<p> | |||||
NixOS uses a unique package manager called nix that solves many problems of common package managers (e.g. apt), including dependency hell. | |||||
Apart from the package manager, NixOS has single configuration file for the entire system. | |||||
Moreover, NixOS saves different “states” of the OS, and a user can rollback, for example, to the yesterday’s state of the OS if something breaks. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org2fdefff" class="outline-4"> | |||||
<h4 id="org2fdefff"><span class="section-number-4">3.6.2.</span> Gentoo Linux</h4> | |||||
<div class="outline-text-4" id="text-3-6-2"> | |||||
<p> | |||||
Gentoo Linux also uses a unique package manager called Portage. | |||||
To install software on Gentoo, Portage builds most of the packages from source and allows user to optimize the software for their own needs. | |||||
Gentoo also allows to use OpenRC as an init system instead of systemd. Even though OpenRC doesn’t have many features of systemd, it’s significantly lighter and simpler than systemd. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org9c9b380" class="outline-4"> | |||||
<h4 id="org9c9b380"><span class="section-number-4">3.6.3.</span> Artix Linux</h4> | |||||
<div class="outline-text-4" id="text-3-6-3"> | |||||
<p> | |||||
Artix Linux is essentially Arch Linux, but it gives several options for the init system, including OpenRC, runit, s6, and others. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org1bf8e90" class="outline-4"> | |||||
<h4 id="org1bf8e90"><span class="section-number-4">3.6.4.</span> LFS</h4> | |||||
<div class="outline-text-4" id="text-3-6-4"> | |||||
<p> | |||||
LFS allows a user to build their own Linux distribution. I think it allows a user to learn many things about Linux. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org896f88e" class="outline-4"> | |||||
<h4 id="org896f88e"><span class="section-number-4">3.6.5.</span> Alpine Linux</h4> | |||||
<div class="outline-text-4" id="text-3-6-5"> | |||||
<p> | |||||
Alpine Linux is a lightweight Linux distribution, since it uses musl libc instead of glibc and busybox instead of GNU coreutils. It’s widely used in Docker Images, thus it’s useful to learn Alpine Linux. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgc4925a6" class="outline-3"> | |||||
<h3 id="orgc4925a6"><span class="section-number-3">3.7.</span> POSIX</h3> | |||||
<div class="outline-text-3" id="text-3-7"> | |||||
<p> | |||||
POSIX is a family of standards created to maintain compatibility between operating systems. | |||||
For example, POSIX-compliant shell I mentioned earlier, is a shell that does things as mentioned in the POSIX standard for shells. | |||||
If a script is POSIX-compliant, any POSIX-compliant shell can run it without issues and the script usually starts with #!/bin/sh | |||||
Some of the information is taken from Wikipedia. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org520649a" class="outline-3"> | |||||
<h3 id="org520649a"><span class="section-number-3">3.8.</span> Advantages of POSIX standards</h3> | |||||
<div class="outline-text-3" id="text-3-8"> | |||||
<p> | |||||
If a program is written with POSIX in mind, then it should work on other POSIX OSes too. Thus the portability increases. | |||||
Since POSIX standards are public, everyone can create programs that can work and communicate with other POSIX-compliant programs. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org7b5efac" class="outline-3"> | |||||
<h3 id="org7b5efac"><span class="section-number-3">3.9.</span> Slackware vs Debian</h3> | |||||
<div class="outline-text-3" id="text-3-9"> | |||||
<p> | |||||
Both distributions are old (29 years old), but both are still maintained. | |||||
</p> | |||||
<p> | |||||
Slackware tries to be stable and simple, thus makes as few changes to the software as possible. It uses pkgtool package management system. | |||||
There are not that many packages available in Slackware, but users can use third-party repositories to install software or update the system. | |||||
Slackware has a small team of developers, whereas Debian is an popular distribution, that has many maintainers. | |||||
</p> | |||||
<p> | |||||
Debian stable is widely used on servers, thanks to its stability and long-term support, while Debian unstable (rolling-release) and testing are used on PCs. | |||||
Debian uses apt (with dpkg) package management system. There are many Linux distributions based on Debian, e.g. Ubuntu, MX linux, etc. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org12183b1" class="outline-3"> | |||||
<h3 id="org12183b1"><span class="section-number-3">3.10.</span> uname -a</h3> | |||||
<div class="outline-text-3" id="text-3-10"> | |||||
<p> | |||||
Code: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">uname -a | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
Linux akemi 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 x86_64 GNU/Linux | |||||
</pre> | |||||
<ol class="org-ol"> | |||||
<li>Kernel name: | |||||
Linux</li> | |||||
<li>Hostname: | |||||
akemi</li> | |||||
<li>Kernel release version and kernel version: | |||||
6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000</li> | |||||
<li>Hardware platform name: | |||||
x86_64</li> | |||||
<li>Operating system name: | |||||
GNU/Linux</li> | |||||
</ol> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-02-02 Thu 16:34</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,187 @@ | |||||
#+title: Lab 1 | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* About this document | |||||
I use Org mode in Emacs to write documents and will use it throughout the course. | |||||
It has a super useful feature: it can evaluate the code on the fly and save results in the buffer. | |||||
Also it's easy to use latex inside Org mode. That's why I will use Org mode for this course. | |||||
If there are any problems with that, please report in the comments in Moodle. | |||||
* Exercise 1 | |||||
Code: | |||||
#+begin_src bash | |||||
lsb_release -a | |||||
#+end_src | |||||
#+RESULTS: | |||||
: -e LSB Version: n/a | |||||
: -e Distributor ID: Arch | |||||
: -e Description: Arch Linux | |||||
: -e Release: rolling | |||||
: -e Codename: n/a | |||||
Code: | |||||
#+begin_src bash | |||||
whoami | |||||
#+end_src | |||||
#+RESULTS: | |||||
: rinri | |||||
Code: | |||||
#+begin_src bash | |||||
users | |||||
#+end_src | |||||
#+RESULTS: | |||||
: rinri | |||||
Code: | |||||
#+begin_src bash | |||||
pwd | |||||
#+end_src | |||||
#+RESULTS: | |||||
: /home/rinri/edu/sna | |||||
Code: | |||||
#+begin_src bash | |||||
ls -la | |||||
#+end_src | |||||
#+RESULTS: | |||||
: total 224 | |||||
: drwxr-xr-x 2 rinri users 4096 Feb 2 15:47 . | |||||
: drwxr-xr-x 25 rinri users 4096 Feb 2 14:13 .. | |||||
: -rw-r--r-- 1 rinri users 19950 Feb 2 15:50 lab1.html | |||||
: -rw-r--r-- 1 rinri users 6407 Feb 2 15:51 lab1.org | |||||
: -rw-r--r-- 1 rinri users 190030 Feb 2 15:45 lab1.pdf | |||||
Code: | |||||
#+begin_src bash | |||||
cd ~/library | |||||
ls -la | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
total 17260 | |||||
drwxr-xr-x 2 rinri users 4096 Jan 8 10:47 . | |||||
drwx--x---+ 74 rinri users 4096 Feb 2 16:07 .. | |||||
-rw-r--r-- 1 rinri users 6556637 Jan 8 10:47 Andrew S. Tanenbaum - Modern Operating Systems.pdf | |||||
lrwxrwxrwx 1 rinri users 38 Aug 3 2022 cormen-algos.pdf -> /home/rinri/data/docs/cormen-algos.pdf | |||||
lrwxrwxrwx 1 rinri users 93 Aug 3 2022 genki -> /home/rinri/data/docs/Banno E., Ikeda Y., Ohno Y., Shinagawa Ch., Tokashiki K. - Genki - 2020 | |||||
-rw-r--r-- 1 rinri users 213363 Jan 8 10:47 ipfs-p2p-file-system.pdf | |||||
-rwxr-xr-x 1 rinri users 66 Aug 3 2022 library.sh | |||||
-rw-r--r-- 1 rinri users 2658531 Jan 8 10:47 Stroustrup B. - A Tour of C++ - Second Edition - 2018.pdf | |||||
-rw-r--r-- 1 rinri users 8220353 Jan 8 10:47 TRENCH_FREE_DIFFEQ_I.PDF | |||||
#+end_example | |||||
Code: | |||||
#+begin_src bash | |||||
cat /etc/shells | |||||
#+end_src | |||||
#+RESULTS: | |||||
: # Pathnames of valid login shells. | |||||
: # See shells(5) for details. | |||||
: | |||||
: /bin/sh | |||||
: /bin/bash | |||||
: /bin/zsh | |||||
: /usr/bin/zsh | |||||
: /usr/bin/git-shell | |||||
: /bin/dash | |||||
Code: | |||||
#+begin_src bash | |||||
echo "$SHELL" | |||||
#+end_src | |||||
#+RESULTS: | |||||
: /bin/zsh | |||||
* Questions | |||||
** Using hostname command: | |||||
Code: | |||||
#+begin_src bash | |||||
hostname | |||||
#+end_src | |||||
#+RESULTS: | |||||
: akemi | |||||
** Arch Linux. | |||||
It's a rolling-release distribution. That's why there is no "version". I've been using it for several years. Used lsb_release -a command to check the info. | |||||
** The root directory is "/" | |||||
** /bin/bash vs /bin/sh | |||||
/bin/bash is a path to the bash shell. Whereas /bin/sh, on most of the systems, is a symbolic link to a POSIX-compliant shell. In many cases, it's linked to bash. On my machine, it's dash (it's usually faster if the script is POSIX-compliant) | |||||
Code: | |||||
#+begin_src bash | |||||
ls -l /bin/sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: lrwxrwxrwx 1 root root 4 Jul 3 2022 /bin/sh -> dash | |||||
** Bash manual | |||||
a. --verbose - When verbose mode is used, bash doesn't hide extra information (prints it), including all the steps done of a script, bashrc commands, and other info. | |||||
b. --help - shows help message | |||||
c. --rcfile file - use "file" as a initialization file instead of ~/.bashrc | |||||
** Linux distributions I want to try | |||||
*** NixOS | |||||
NixOS uses a unique package manager called nix that solves many problems of common package managers (e.g. apt), including dependency hell. | |||||
Apart from the package manager, NixOS has single configuration file for the entire system. | |||||
Moreover, NixOS saves different "states" of the OS, and a user can rollback, for example, to the yesterday's state of the OS if something breaks. | |||||
*** Gentoo Linux | |||||
Gentoo Linux also uses a unique package manager called Portage. | |||||
To install software on Gentoo, Portage builds most of the packages from source and allows user to optimize the software for their own needs. | |||||
Gentoo also allows to use OpenRC as an init system instead of systemd. Even though OpenRC doesn't have many features of systemd, it's significantly lighter and simpler than systemd. | |||||
*** Artix Linux | |||||
Artix Linux is essentially Arch Linux, but it gives several options for the init system, including OpenRC, runit, s6, and others. | |||||
*** LFS | |||||
LFS allows a user to build their own Linux distribution. I think it allows a user to learn many things about Linux. | |||||
*** Alpine Linux | |||||
Alpine Linux is a lightweight Linux distribution, since it uses musl libc instead of glibc and busybox instead of GNU coreutils. It's widely used in Docker Images, thus it's useful to learn Alpine Linux. | |||||
** POSIX | |||||
POSIX is a family of standards created to maintain compatibility between operating systems. | |||||
For example, POSIX-compliant shell I mentioned earlier, is a shell that does things as mentioned in the POSIX standard for shells. | |||||
If a script is POSIX-compliant, any POSIX-compliant shell can run it without issues and the script usually starts with #!/bin/sh | |||||
Some of the information is taken from Wikipedia. | |||||
** Advantages of POSIX standards | |||||
If a program is written with POSIX in mind, then it should work on other POSIX OSes too. Thus the portability increases. | |||||
Since POSIX standards are public, everyone can create programs that can work and communicate with other POSIX-compliant programs. | |||||
** Slackware vs Debian | |||||
Both distributions are old (29 years old), but both are still maintained. | |||||
Slackware tries to be stable and simple, thus makes as few changes to the software as possible. It uses pkgtool package management system. | |||||
There are not that many packages available in Slackware, but users can use third-party repositories to install software or update the system. | |||||
Slackware has a small team of developers, whereas Debian is an popular distribution, that has many maintainers. | |||||
Debian stable is widely used on servers, thanks to its stability and long-term support, while Debian unstable (rolling-release) and testing are used on PCs. | |||||
Debian uses apt (with dpkg) package management system. There are many Linux distributions based on Debian, e.g. Ubuntu, MX linux, etc. | |||||
** uname -a | |||||
Code: | |||||
#+begin_src bash | |||||
uname -a | |||||
#+end_src | |||||
#+RESULTS: | |||||
: Linux akemi 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 x86_64 GNU/Linux | |||||
1. Kernel name: | |||||
Linux | |||||
2. Hostname: | |||||
akemi | |||||
3. Kernel release version and kernel version: | |||||
6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 | |||||
4. Hardware platform name: | |||||
x86_64 | |||||
5. Operating system name: | |||||
GNU/Linux |
@@ -0,0 +1,334 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-04-14 Fri 00:00 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab9 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
<script> | |||||
window.MathJax = { | |||||
tex: { | |||||
ams: { | |||||
multlineWidth: '85%' | |||||
}, | |||||
tags: 'ams', | |||||
tagSide: 'right', | |||||
tagIndent: '.8em' | |||||
}, | |||||
chtml: { | |||||
scale: 1.0, | |||||
displayAlign: 'center', | |||||
displayIndent: '0em' | |||||
}, | |||||
svg: { | |||||
scale: 1.0, | |||||
displayAlign: 'center', | |||||
displayIndent: '0em' | |||||
}, | |||||
output: { | |||||
font: 'mathjax-modern', | |||||
displayOverflow: 'overflow' | |||||
} | |||||
}; | |||||
</script> | |||||
<script | |||||
id="MathJax-script" | |||||
async | |||||
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"> | |||||
</script> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab9 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org0dd7aad">1. Question 1</a></li> | |||||
<li><a href="#org3526c7a">2. Question 2</a></li> | |||||
<li><a href="#orgac5e4b2">3. Question 3</a></li> | |||||
<li><a href="#orgf20b9b2">4. Question 4</a></li> | |||||
<li><a href="#org215ffc5">5. Question 5</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org0dd7aad" class="outline-2"> | |||||
<h2 id="org0dd7aad"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<p> | |||||
I would use rsyslog and journald. Forward them to ELK stack and use it as a SIEM. | |||||
There are many people people familiar with the ELK stack, and it’s easy to scale it. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org3526c7a" class="outline-2"> | |||||
<h2 id="org3526c7a"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
> sudo cat /etc/rsyslog.d/auth-errors.conf | |||||
auth.alert,authpriv.alert /var/log/auth-errors | |||||
</p> | |||||
<p> | |||||
<a href="./rsyslogpriority.jpg">rsyslogpriority | |||||
</a> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgac5e4b2" class="outline-2"> | |||||
<h2 id="orgac5e4b2"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> /etc/logrotate.d/httpd | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
/var/log/httpd/*log { | |||||
rotate 10 | |||||
compress | |||||
missingok | |||||
sharedscripts | |||||
postrotate | |||||
/usr/bin/systemctl reload httpd.service 2>/dev/null || true | |||||
endscript | |||||
} | |||||
</pre> | |||||
<p> | |||||
’* */6 * * * logrotate /etc/logrotate.d/httpd | |||||
</p> | |||||
<p> | |||||
<a href="./logrotate.jpg">logrotate | |||||
</a> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgf20b9b2" class="outline-2"> | |||||
<h2 id="orgf20b9b2"><span class="section-number-2">4.</span> Question 4</h2> | |||||
</div> | |||||
<div id="outline-container-org215ffc5" class="outline-2"> | |||||
<h2 id="org215ffc5"><span class="section-number-2">5.</span> Question 5</h2> | |||||
<div class="outline-text-2" id="text-5"> | |||||
<p> | |||||
in /etc/bashrc: | |||||
</p> | |||||
<p> | |||||
export PROMPT_COMMAND=’RETRN_VAL=\(?;logger -p local6.debug "\)(whoami) [$$]: $(history 1 | sed “s/^[ ]*[0-9]\+[ ]*//” )“’ | |||||
</p> | |||||
<p> | |||||
in /etc/rsyslog.d/bash.conf | |||||
local6.* /var/log/commands.log | |||||
</p> | |||||
<p> | |||||
Taken from <a href="https://unix.stackexchange.com/questions/664581/how-do-i-log-all-commands-executed-by-all-users">https://unix.stackexchange.com/questions/664581/how-do-i-log-all-commands-executed-by-all-users</a> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-04-14 Fri 00:00</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,50 @@ | |||||
#+title: Lab9 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
I would use rsyslog and journald. Forward them to ELK stack and use it as a SIEM. | |||||
There are many people people familiar with the ELK stack, and it's easy to scale it. | |||||
* Question 2 | |||||
> sudo cat /etc/rsyslog.d/auth-errors.conf | |||||
auth.alert,authpriv.alert /var/log/auth-errors | |||||
[[./rsyslogpriority.jpg][rsyslogpriority | |||||
]] | |||||
* Question 3 | |||||
#+begin_src bash | |||||
cat /etc/logrotate.d/httpd | |||||
#+end_src | |||||
#+RESULTS: | |||||
: /var/log/httpd/*log { | |||||
: rotate 10 | |||||
: compress | |||||
: missingok | |||||
: sharedscripts | |||||
: postrotate | |||||
: /usr/bin/systemctl reload httpd.service 2>/dev/null || true | |||||
: endscript | |||||
: } | |||||
'* */6 * * * logrotate /etc/logrotate.d/httpd | |||||
[[./logrotate.jpg][logrotate | |||||
]] | |||||
* Question 4 | |||||
* Question 5 | |||||
in /etc/bashrc: | |||||
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" )"' | |||||
in /etc/rsyslog.d/bash.conf | |||||
local6.* /var/log/commands.log | |||||
Taken from https://unix.stackexchange.com/questions/664581/how-do-i-log-all-commands-executed-by-all-users |
@@ -0,0 +1 @@ | |||||
HELLO |
@@ -0,0 +1,407 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-04-20 Thu 22:23 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab 11 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab 11 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#orgb5383c0">1. Question 1</a></li> | |||||
<li><a href="#org68c7989">2. Question 2</a> | |||||
<ul> | |||||
<li><a href="#orga0d213f">2.1. Choose a host OS that provides maximum container isolation. (hardened host OS)</a></li> | |||||
<li><a href="#org68baa0a">2.2. Use network namespaces</a></li> | |||||
<li><a href="#org5ffdd26">2.3. Use kubernetes to manage access right</a></li> | |||||
<li><a href="#org7a83b2b">2.4. Monitor the logs using SIEM tools</a></li> | |||||
<li><a href="#orgc61de8d">2.5. Don’t use outdated images</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgf0252b1">3. Question 3</a></li> | |||||
<li><a href="#orgad34306">4. Question 4</a></li> | |||||
<li><a href="#org10585ce">5. Question 5</a></li> | |||||
<li><a href="#org2339204">6. Question 6</a></li> | |||||
<li><a href="#org5da35ee">7. Question 8</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgb5383c0" class="outline-2"> | |||||
<h2 id="orgb5383c0"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<p> | |||||
Source: <a href="https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile">https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile</a> | |||||
Usually, the entrypoint is /bin/sh -c CMD. So this command gets executed when the container is run. | |||||
It’s a standard practice to customize CMD, though. If you want to use other shell for executing commands, it may be useful to customize the entrypoint. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org68c7989" class="outline-2"> | |||||
<h2 id="org68c7989"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
Source: <a href="https://www.redhat.com/en/topics/security/container-security">https://www.redhat.com/en/topics/security/container-security</a> | |||||
</p> | |||||
</div> | |||||
<div id="outline-container-orga0d213f" class="outline-3"> | |||||
<h3 id="orga0d213f"><span class="section-number-3">2.1.</span> Choose a host OS that provides maximum container isolation. (hardened host OS)</h3> | |||||
</div> | |||||
<div id="outline-container-org68baa0a" class="outline-3"> | |||||
<h3 id="org68baa0a"><span class="section-number-3">2.2.</span> Use network namespaces</h3> | |||||
</div> | |||||
<div id="outline-container-org5ffdd26" class="outline-3"> | |||||
<h3 id="org5ffdd26"><span class="section-number-3">2.3.</span> Use kubernetes to manage access right</h3> | |||||
</div> | |||||
<div id="outline-container-org7a83b2b" class="outline-3"> | |||||
<h3 id="org7a83b2b"><span class="section-number-3">2.4.</span> Monitor the logs using SIEM tools</h3> | |||||
</div> | |||||
<div id="outline-container-orgc61de8d" class="outline-3"> | |||||
<h3 id="orgc61de8d"><span class="section-number-3">2.5.</span> Don’t use outdated images</h3> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgf0252b1" class="outline-2"> | |||||
<h2 id="orgf0252b1"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<p> | |||||
<img src="./container-ls-1.jpg" alt="container-ls-1.jpg" /> | |||||
<img src="./container-ls-2.jpg" alt="container-ls-2.jpg" /> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgad34306" class="outline-2"> | |||||
<h2 id="orgad34306"><span class="section-number-2">4.</span> Question 4</h2> | |||||
<div class="outline-text-2" id="text-4"> | |||||
<p> | |||||
Source: <a href="https://docs.docker.com/engine/reference/commandline/cp/">https://docs.docker.com/engine/reference/commandline/cp/</a> | |||||
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- | |||||
</p> | |||||
<p> | |||||
Example: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> ~/nginx.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="orgb1f78fc"> | |||||
#!/bin/bash | |||||
docker run \ | |||||
-v /etc/ssl/certs/monica.crt:/etc/ssl/certs/monica.crt \ | |||||
-v /etc/ssl/private/monica.key:/etc/ssl/private/monica.key \ | |||||
-v /home/rinri/.config/nginx:/etc/nginx/conf.d \ | |||||
-v /home/rinri/edu/sna/:/var/www \ | |||||
-p 80:80 -p 443:443 -p 5000:5000 \ | |||||
--restart unless-stopped \ | |||||
-d nginx | |||||
</pre> | |||||
<p> | |||||
After running nginx.sh: | |||||
<img src="./container-cp.jpg" alt="container-cp.jpg" /> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org10585ce" class="outline-2"> | |||||
<h2 id="org10585ce"><span class="section-number-2">5.</span> Question 5</h2> | |||||
<div class="outline-text-2" id="text-5"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Run Nginx container:"</span> | |||||
<span style="color: #c792ea;">cat</span> ~/nginx.sh | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Config file:"</span> | |||||
<span style="color: #c792ea;">cat</span> ~/.config/nginx/test.conf | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org01c388f"> | |||||
Run Nginx container: | |||||
#!/bin/bash | |||||
docker run \ | |||||
-v /etc/ssl/certs/monica.crt:/etc/ssl/certs/monica.crt \ | |||||
-v /etc/ssl/private/monica.key:/etc/ssl/private/monica.key \ | |||||
-v /home/rinri/.config/nginx:/etc/nginx/conf.d \ | |||||
-v /home/rinri/edu/sna/:/var/www \ | |||||
-p 80:80 -p 443:443 -p 5000:5000 \ | |||||
--restart unless-stopped \ | |||||
-d nginx | |||||
Config file: | |||||
server { | |||||
listen 5000; | |||||
listen [::]:5000; | |||||
root /var/www; | |||||
index index.html index.htm; | |||||
location / { | |||||
try_files $uri $uri/ =404; | |||||
} | |||||
} | |||||
server { | |||||
listen 80; | |||||
listen [::]:80; | |||||
server_name monica.local; | |||||
return 302 https://$server_name$request_uri; | |||||
} | |||||
server { | |||||
listen 443; | |||||
listen [::]:443; | |||||
include conf.d/snippets/self-signed.conf; | |||||
server_name monica.local; | |||||
location / { | |||||
proxy_pass http://172.17.0.4; | |||||
proxy_set_header Host monica.local; | |||||
} | |||||
} | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org2339204" class="outline-2"> | |||||
<h2 id="org2339204"><span class="section-number-2">6.</span> Question 6</h2> | |||||
<div class="outline-text-2" id="text-6"> | |||||
<p> | |||||
In /etc/rsyslog.conf: | |||||
$ModLoad imtcp.so | |||||
$InputTCPServerRun 514 | |||||
</p> | |||||
<p> | |||||
Command: | |||||
docker run -it –log-driver syslog –log-opt syslog-address=tcp://172.17.0.1:514 alpine ash | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5da35ee" class="outline-2"> | |||||
<h2 id="org5da35ee"><span class="section-number-2">7.</span> Question 8</h2> | |||||
<div class="outline-text-2" id="text-7"> | |||||
<p> | |||||
FROM alpine | |||||
RUN apk add –update –no-cache python3 && ln -sf python3 /usr/bin/python | |||||
RUN python3 -m ensurepip | |||||
RUN pip3 install –no-cache –upgrade pip setuptools | |||||
RUN touch index.html | |||||
RUN echo “<html><h1>Testing web</h1></html>” >> index.html | |||||
CMD [“python”, “-m”, “http.server”] | |||||
</p> | |||||
<p> | |||||
changed apt to apk. | |||||
source: <a href="https://stackoverflow.com/questions/62554991/how-do-i-install-python-on-alpine-linux">https://stackoverflow.com/questions/62554991/how-do-i-install-python-on-alpine-linux</a> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-04-20 Thu 22:23</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,125 @@ | |||||
#+title: Lab 11 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
Source: https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile | |||||
Usually, the entrypoint is /bin/sh -c CMD. So this command gets executed when the container is run. | |||||
It's a standard practice to customize CMD, though. If you want to use other shell for executing commands, it may be useful to customize the entrypoint. | |||||
* Question 2 | |||||
Source: https://www.redhat.com/en/topics/security/container-security | |||||
** Choose a host OS that provides maximum container isolation. (hardened host OS) | |||||
** Use network namespaces | |||||
** Use kubernetes to manage access right | |||||
** Monitor the logs using SIEM tools | |||||
** Don't use outdated images | |||||
* Question 3 | |||||
[[./container-ls-1.jpg]] | |||||
[[./container-ls-2.jpg]] | |||||
* Question 4 | |||||
Source: https://docs.docker.com/engine/reference/commandline/cp/ | |||||
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- | |||||
Example: | |||||
#+begin_src bash | |||||
cat ~/nginx.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
#!/bin/bash | |||||
docker run \ | |||||
-v /etc/ssl/certs/monica.crt:/etc/ssl/certs/monica.crt \ | |||||
-v /etc/ssl/private/monica.key:/etc/ssl/private/monica.key \ | |||||
-v /home/rinri/.config/nginx:/etc/nginx/conf.d \ | |||||
-p 80:80 -p 443:443 \ | |||||
--restart unless-stopped \ | |||||
-d nginx | |||||
#+end_example | |||||
After running nginx.sh: | |||||
[[./container-cp.jpg]] | |||||
* Question 5 | |||||
#+begin_src bash | |||||
echo "Run Nginx container:" | |||||
cat ~/nginx.sh | |||||
echo "Config file:" | |||||
cat ~/.config/nginx/test.conf | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
Run Nginx container: | |||||
#!/bin/bash | |||||
docker run \ | |||||
-v /etc/ssl/certs/monica.crt:/etc/ssl/certs/monica.crt \ | |||||
-v /etc/ssl/private/monica.key:/etc/ssl/private/monica.key \ | |||||
-v /home/rinri/.config/nginx:/etc/nginx/conf.d \ | |||||
-v /home/rinri/edu/sna/:/var/www \ | |||||
-p 80:80 -p 443:443 -p 5000:5000 \ | |||||
--restart unless-stopped \ | |||||
-d nginx | |||||
Config file: | |||||
server { | |||||
listen 5000; | |||||
listen [::]:5000; | |||||
root /var/www; | |||||
index index.html index.htm; | |||||
location / { | |||||
try_files $uri $uri/ =404; | |||||
} | |||||
} | |||||
server { | |||||
listen 80; | |||||
listen [::]:80; | |||||
server_name monica.local; | |||||
return 302 https://$server_name$request_uri; | |||||
} | |||||
server { | |||||
listen 443; | |||||
listen [::]:443; | |||||
include conf.d/snippets/self-signed.conf; | |||||
server_name monica.local; | |||||
location / { | |||||
proxy_pass http://172.17.0.4; | |||||
proxy_set_header Host monica.local; | |||||
} | |||||
} | |||||
#+end_example | |||||
* Question 6 | |||||
In /etc/rsyslog.conf: | |||||
$ModLoad imtcp.so | |||||
$InputTCPServerRun 514 | |||||
Command: | |||||
docker run -it --log-driver syslog --log-opt syslog-address=tcp://172.17.0.1:514 alpine ash | |||||
* Question 8 | |||||
FROM alpine | |||||
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python | |||||
RUN python3 -m ensurepip | |||||
RUN pip3 install --no-cache --upgrade pip setuptools | |||||
RUN touch index.html | |||||
RUN echo "<html><h1>Testing web</h1></html>" >> index.html | |||||
CMD ["python", "-m", "http.server"] | |||||
changed apt to apk. | |||||
source: https://stackoverflow.com/questions/62554991/how-do-i-install-python-on-alpine-linux |
@@ -0,0 +1,468 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-02-09 Thu 23:36 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab2 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab2 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#orgab91f72">1. Questions 1</a> | |||||
<ul> | |||||
<li><a href="#org5b80d60">1.1. What is fdisk utility used for?</a></li> | |||||
<li><a href="#org0c664e2">1.2. Show the bootable device(s) on your machine, and identify which partition(s) are bootable.</a> | |||||
<ul> | |||||
<li><a href="#orged3ed3c">1.2.1. Output of fdisk -l:</a></li> | |||||
<li><a href="#orga4fdfef">1.2.2. Answer</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgb7c19d5">1.3. What is logical block address?</a></li> | |||||
<li><a href="#orgd76c04a">1.4. Why did we specify the count, the bs, and the skip options when using dd?</a></li> | |||||
<li><a href="#org396d8fc">1.5. Why does a GPT formatted disk have the MBR?</a></li> | |||||
<li><a href="#org47988d3">1.6. Name two differences between primary and logical partitions in an MBR partitioning scheme</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgd07cf30">2. Questions 2</a> | |||||
<ul> | |||||
<li><a href="#org7dd9497">2.1. Why is Shim used to load the GRUB bootloader?</a></li> | |||||
<li><a href="#orgdf33504">2.2. Can you locate your grub configuration file? Show the path.</a></li> | |||||
<li><a href="#orge9d54d1">2.3. According to the boot order, what is the third boot device on your computer? How did you check this?</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgdc23d89">3. Questions 3</a> | |||||
<ul> | |||||
<li><a href="#orgd513e26">3.1. How many inodes are in use on your system?</a></li> | |||||
<li><a href="#orge9e0733">3.2. What is the filesystem type of the EFI partition?</a></li> | |||||
<li><a href="#org8478339">3.3. What device is mounted at your root / directory? Show proof.</a></li> | |||||
<li><a href="#org3c9680d">3.4. What is your partition UUID?</a></li> | |||||
<li><a href="#org9f79854">3.5. Show at least two methods of viewing the UUID of a block device.</a></li> | |||||
<li><a href="#org4b16e3f">3.6. What is the function of /dev/zero?</a></li> | |||||
</ul> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgab91f72" class="outline-2"> | |||||
<h2 id="orgab91f72"><span class="section-number-2">1.</span> Questions 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
</div> | |||||
<div id="outline-container-org5b80d60" class="outline-3"> | |||||
<h3 id="org5b80d60"><span class="section-number-3">1.1.</span> What is fdisk utility used for?</h3> | |||||
<div class="outline-text-3" id="text-1-1"> | |||||
<p> | |||||
to manipulate disk partition table | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org0c664e2" class="outline-3"> | |||||
<h3 id="org0c664e2"><span class="section-number-3">1.2.</span> Show the bootable device(s) on your machine, and identify which partition(s) are bootable.</h3> | |||||
<div class="outline-text-3" id="text-1-2"> | |||||
</div> | |||||
<div id="outline-container-orged3ed3c" class="outline-4"> | |||||
<h4 id="orged3ed3c"><span class="section-number-4">1.2.1.</span> Output of fdisk -l:</h4> | |||||
<div class="outline-text-4" id="text-1-2-1"> | |||||
<p> | |||||
… | |||||
Device Start End Sectors Size Type | |||||
/dev/sdb1 2048 34815 32768 16M Microsoft reserved | |||||
/dev/sdb2 34816 524285951 524251136 250G Microsoft basic data | |||||
/dev/sdb3 524285952 659988479 135702528 64.7G Linux filesystem | |||||
/dev/sdb4 659988480 863920127 203931648 97.2G Linux filesystem | |||||
/dev/sdb5 958291968 975173631 16881664 8G Linux swap | |||||
/dev/sdb6 975173632 976773134 1599503 781M EFI System | |||||
/dev/sdb7 863920128 956194815 92274688 44G Linux filesystem | |||||
/dev/sdb8 956194816 958291967 2097152 1G EFI System | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orga4fdfef" class="outline-4"> | |||||
<h4 id="orga4fdfef"><span class="section-number-4">1.2.2.</span> Answer</h4> | |||||
<div class="outline-text-4" id="text-1-2-2"> | |||||
<p> | |||||
/dev/sdb6 and /dev/sdb8 are bootable partitions | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgb7c19d5" class="outline-3"> | |||||
<h3 id="orgb7c19d5"><span class="section-number-3">1.3.</span> What is logical block address?</h3> | |||||
<div class="outline-text-3" id="text-1-3"> | |||||
<p> | |||||
is a scheme to index the locations of logical blocks of a device. Starts with LBA 0 | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgd76c04a" class="outline-3"> | |||||
<h3 id="orgd76c04a"><span class="section-number-3">1.4.</span> Why did we specify the count, the bs, and the skip options when using dd?</h3> | |||||
<div class="outline-text-3" id="text-1-4"> | |||||
<p> | |||||
Number of blocks, block size, and how many blocks to skip | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org396d8fc" class="outline-3"> | |||||
<h3 id="org396d8fc"><span class="section-number-3">1.5.</span> Why does a GPT formatted disk have the MBR?</h3> | |||||
<div class="outline-text-3" id="text-1-5"> | |||||
<p> | |||||
To maintain compatibility and protect GPT disk and from MBR-based disk utilities. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org47988d3" class="outline-3"> | |||||
<h3 id="org47988d3"><span class="section-number-3">1.6.</span> Name two differences between primary and logical partitions in an MBR partitioning scheme</h3> | |||||
<div class="outline-text-3" id="text-1-6"> | |||||
<p> | |||||
There can be only 4 primary partitions in MBR disk, while there can be many logical ones on top of an extended partition. Some operating systems cannot boot from a logical partition. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgd07cf30" class="outline-2"> | |||||
<h2 id="orgd07cf30"><span class="section-number-2">2.</span> Questions 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
</div> | |||||
<div id="outline-container-org7dd9497" class="outline-3"> | |||||
<h3 id="org7dd9497"><span class="section-number-3">2.1.</span> Why is Shim used to load the GRUB bootloader?</h3> | |||||
<div class="outline-text-3" id="text-2-1"> | |||||
<p> | |||||
To make Secure Boot mechanism work. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgdf33504" class="outline-3"> | |||||
<h3 id="orgdf33504"><span class="section-number-3">2.2.</span> Can you locate your grub configuration file? Show the path.</h3> | |||||
<div class="outline-text-3" id="text-2-2"> | |||||
<p> | |||||
/boot/grub/grub.cfg | |||||
Also, there is /etc/default/grub which can be used to generate a grub config using grub-mkconfig | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orge9d54d1" class="outline-3"> | |||||
<h3 id="orge9d54d1"><span class="section-number-3">2.3.</span> According to the boot order, what is the third boot device on your computer? How did you check this?</h3> | |||||
<div class="outline-text-3" id="text-2-3"> | |||||
<p> | |||||
BootCurrent: 0003 | |||||
Timeout: 0 seconds | |||||
BootOrder: 0003,0004,0009,0001,0002,0000,2001,0006,0005,2002,2003 | |||||
… | |||||
Boot0009* Artix HD(10,GPT,… | |||||
It’s Artix on my hard drive, accoding to efibootmgr -v | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgdc23d89" class="outline-2"> | |||||
<h2 id="orgdc23d89"><span class="section-number-2">3.</span> Questions 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
</div> | |||||
<div id="outline-container-orgd513e26" class="outline-3"> | |||||
<h3 id="orgd513e26"><span class="section-number-3">3.1.</span> How many inodes are in use on your system?</h3> | |||||
<div class="outline-text-3" id="text-3-1"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">df --output=source,iused | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org1e237a1"> | |||||
Filesystem IUsed | |||||
dev 717 | |||||
run 1314 | |||||
/dev/sdb3 720461 | |||||
tmpfs 1 | |||||
tmpfs 26 | |||||
/dev/sdb4 677813 | |||||
/dev/sdb6 0 | |||||
tmpfs 71 | |||||
/dev/sda9 16193 | |||||
/dev/sda8 33171 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orge9e0733" class="outline-3"> | |||||
<h3 id="orge9e0733"><span class="section-number-3">3.2.</span> What is the filesystem type of the EFI partition?</h3> | |||||
<div class="outline-text-3" id="text-3-2"> | |||||
<p> | |||||
FAT32 | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org8478339" class="outline-3"> | |||||
<h3 id="org8478339"><span class="section-number-3">3.3.</span> What device is mounted at your root / directory? Show proof.</h3> | |||||
<div class="outline-text-3" id="text-3-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">lsblk | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org1ee58fc"> | |||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS | |||||
sda 8:0 0 931.5G 0 disk | |||||
├─sda1 8:1 0 499M 0 part | |||||
├─sda2 8:2 0 100M 0 part | |||||
├─sda3 8:3 0 16M 0 part | |||||
├─sda4 8:4 0 42.4G 0 part | |||||
├─sda5 8:5 0 38.8G 0 part | |||||
├─sda6 8:6 0 100M 0 part | |||||
├─sda7 8:7 0 3.1G 0 part | |||||
├─sda8 8:8 0 315G 0 part /mnt/rec | |||||
└─sda9 8:9 0 531.5G 0 part /mnt/data | |||||
sdb 8:16 0 465.8G 0 disk | |||||
├─sdb1 8:17 0 16M 0 part | |||||
├─sdb2 8:18 0 250G 0 part | |||||
├─sdb3 8:19 0 64.7G 0 part / | |||||
├─sdb4 8:20 0 97.2G 0 part /home | |||||
├─sdb5 8:21 0 8G 0 part [SWAP] | |||||
├─sdb6 8:22 0 781M 0 part /boot | |||||
├─sdb7 8:23 0 44G 0 part | |||||
└─sdb8 8:24 0 1G 0 part | |||||
</pre> | |||||
<p> | |||||
/dev/sdb3 | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org3c9680d" class="outline-3"> | |||||
<h3 id="org3c9680d"><span class="section-number-3">3.4.</span> What is your partition UUID?</h3> | |||||
<div class="outline-text-3" id="text-3-4"> | |||||
<p> | |||||
For PARTUUID: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">lsblk -dno PARTUUID /dev/sdb3 | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
fbef9613-fbf5-8445-8d1c-7a63709d1229 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org9f79854" class="outline-3"> | |||||
<h3 id="org9f79854"><span class="section-number-3">3.5.</span> Show at least two methods of viewing the UUID of a block device.</h3> | |||||
<div class="outline-text-3" id="text-3-5"> | |||||
<p> | |||||
lsblk -dno UUID /dev/sdb3 | |||||
blkid | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org4b16e3f" class="outline-3"> | |||||
<h3 id="org4b16e3f"><span class="section-number-3">3.6.</span> What is the function of /dev/zero?</h3> | |||||
<div class="outline-text-3" id="text-3-6"> | |||||
<p> | |||||
Source of zero bytes. Can be used with dd to fill a file with zeros. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-02-09 Thu 23:36</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,108 @@ | |||||
#+title: Lab2 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Questions 1 | |||||
** What is fdisk utility used for? | |||||
to manipulate disk partition table | |||||
** Show the bootable device(s) on your machine, and identify which partition(s) are bootable. | |||||
*** Output of fdisk -l: | |||||
... | |||||
Device Start End Sectors Size Type | |||||
/dev/sdb1 2048 34815 32768 16M Microsoft reserved | |||||
/dev/sdb2 34816 524285951 524251136 250G Microsoft basic data | |||||
/dev/sdb3 524285952 659988479 135702528 64.7G Linux filesystem | |||||
/dev/sdb4 659988480 863920127 203931648 97.2G Linux filesystem | |||||
/dev/sdb5 958291968 975173631 16881664 8G Linux swap | |||||
/dev/sdb6 975173632 976773134 1599503 781M EFI System | |||||
/dev/sdb7 863920128 956194815 92274688 44G Linux filesystem | |||||
/dev/sdb8 956194816 958291967 2097152 1G EFI System | |||||
*** Answer | |||||
/dev/sdb6 and /dev/sdb8 are bootable partitions | |||||
** What is logical block address? | |||||
is a scheme to index the locations of logical blocks of a device. Starts with LBA 0 | |||||
** Why did we specify the count, the bs, and the skip options when using dd? | |||||
Number of blocks, block size, and how many blocks to skip | |||||
** Why does a GPT formatted disk have the MBR? | |||||
To maintain compatibility and protect GPT disk and from MBR-based disk utilities. | |||||
** Name two differences between primary and logical partitions in an MBR partitioning scheme | |||||
There can be only 4 primary partitions in MBR disk, while there can be many logical ones on top of an extended partition. Some operating systems cannot boot from a logical partition. | |||||
* Questions 2 | |||||
** Why is Shim used to load the GRUB bootloader? | |||||
To make Secure Boot mechanism work. | |||||
** Can you locate your grub configuration file? Show the path. | |||||
/boot/grub/grub.cfg | |||||
Also, there is /etc/default/grub which can be used to generate a grub config using grub-mkconfig | |||||
** According to the boot order, what is the third boot device on your computer? How did you check this? | |||||
BootCurrent: 0003 | |||||
Timeout: 0 seconds | |||||
BootOrder: 0003,0004,0009,0001,0002,0000,2001,0006,0005,2002,2003 | |||||
... | |||||
Boot0009* Artix HD(10,GPT,... | |||||
It's Artix on my hard drive, accoding to efibootmgr -v | |||||
* Questions 3 | |||||
** How many inodes are in use on your system? | |||||
#+begin_src bash | |||||
df --output=source,iused | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
Filesystem IUsed | |||||
dev 717 | |||||
run 1314 | |||||
/dev/sdb3 720461 | |||||
tmpfs 1 | |||||
tmpfs 22 | |||||
/dev/sdb4 677792 | |||||
/dev/sdb6 0 | |||||
tmpfs 71 | |||||
/dev/sda9 16193 | |||||
/dev/sda8 33171 | |||||
#+end_example | |||||
** What is the filesystem type of the EFI partition? | |||||
FAT32 | |||||
** What device is mounted at your root / directory? Show proof. | |||||
#+begin_src bash | |||||
lsblk | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS | |||||
sda 8:0 0 931.5G 0 disk | |||||
... | |||||
sdb 8:16 0 465.8G 0 disk | |||||
├─sdb1 8:17 0 16M 0 part | |||||
├─sdb2 8:18 0 250G 0 part | |||||
├─sdb3 8:19 0 64.7G 0 part / | |||||
├─sdb4 8:20 0 97.2G 0 part /home | |||||
├─sdb5 8:21 0 8G 0 part [SWAP] | |||||
├─sdb6 8:22 0 781M 0 part /boot | |||||
├─sdb7 8:23 0 44G 0 part | |||||
└─sdb8 8:24 0 1G 0 part | |||||
#+end_example | |||||
/dev/sdb3 | |||||
** What is your partition UUID? | |||||
For PARTUUID: | |||||
#+begin_src bash | |||||
lsblk -dno PARTUUID /dev/sdb3 | |||||
#+end_src | |||||
#+RESULTS: | |||||
: fbef9613-fbf5-8445-8d1c-7a63709d1229 | |||||
** Show at least two methods of viewing the UUID of a block device. | |||||
lsblk -dno UUID /dev/sdb3 | |||||
blkid | |||||
** What is the function of /dev/zero? | |||||
Source of zero bytes. Can be used with dd to fill a file with zeros. |
@@ -0,0 +1,318 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-02-17 Fri 00:07 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab3 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab3 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org2b08f84">1. Question 1</a></li> | |||||
<li><a href="#org9415243">2. Question 2</a></li> | |||||
<li><a href="#org5d672da">3. Question 3</a></li> | |||||
<li><a href="#orgd1f87fe">4. Question 4</a></li> | |||||
<li><a href="#org47aa941">5. Question 5</a></li> | |||||
<li><a href="#org3a7880f">6. Question 6</a></li> | |||||
<li><a href="#org1459886">7. Question 7</a></li> | |||||
<li><a href="#org5520163">8. Question 8</a></li> | |||||
<li><a href="#org1fcc283">9. Question 9</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org2b08f84" class="outline-2"> | |||||
<h2 id="org2b08f84"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<p> | |||||
Pipe takes stdout of one command and forwards it to another as stdin | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org9415243" class="outline-2"> | |||||
<h2 id="org9415243"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
File formats and conventions | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5d672da" class="outline-2"> | |||||
<h2 id="org5d672da"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #82aaff;">which</span> <span style="color: #c792ea;">ls</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
/usr/bin/ls | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgd1f87fe" class="outline-2"> | |||||
<h2 id="orgd1f87fe"><span class="section-number-2">4.</span> Question 4</h2> | |||||
<div class="outline-text-2" id="text-4"> | |||||
<p> | |||||
mv test_file.tot test_file.txt | |||||
rename ’s/tot/txt/’ test-file.tot | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org47aa941" class="outline-2"> | |||||
<h2 id="org47aa941"><span class="section-number-2">5.</span> Question 5</h2> | |||||
<div class="outline-text-2" id="text-5"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">echo</span> -e <span style="color: #c3e88d;">"The location of hundreds of crab pots\nLittle Red Riding Hood\nThe location of hundreds of crab pots\nThe location of hundreds of crab pots\nThe sound of thunder\nEight hours in a row\nAll aboard\nEight hours in a row"</span> | sort | uniq > newfile.txt; whoami >> newfile.txt | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org3a7880f" class="outline-2"> | |||||
<h2 id="org3a7880f"><span class="section-number-2">6.</span> Question 6</h2> | |||||
<div class="outline-text-2" id="text-6"> | |||||
<p> | |||||
ping 127.0.0.1 &> /dev/null | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org1459886" class="outline-2"> | |||||
<h2 id="org1459886"><span class="section-number-2">7.</span> Question 7</h2> | |||||
<div class="outline-text-2" id="text-7"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">sort | nl -ba > output.txt | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5520163" class="outline-2"> | |||||
<h2 id="org5520163"><span class="section-number-2">8.</span> Question 8</h2> | |||||
<div class="outline-text-2" id="text-8"> | |||||
<p> | |||||
cd <i>home/rinri/testdir | |||||
cd ..</i>../home/rinri/testdir | |||||
cd ~/testdir | |||||
cd; cd testdir | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org1fcc283" class="outline-2"> | |||||
<h2 id="org1fcc283"><span class="section-number-2">9.</span> Question 9</h2> | |||||
<div class="outline-text-2" id="text-9"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">awk -F <span style="color: #c3e88d;">':'</span> <span style="color: #c3e88d;">'{print $7;}'</span> /etc/passwd | sort | uniq | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
/bin/bash | |||||
/bin/false | |||||
/bin/zsh | |||||
/sbin/nologin | |||||
/usr/bin/git-shell | |||||
/usr/bin/nologin | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-02-17 Fri 00:07</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,50 @@ | |||||
#+title: Lab3 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
Pipe takes stdout of one command and forwards it to another as stdin | |||||
* Question 2 | |||||
File formats and conventions | |||||
* Question 3 | |||||
#+begin_src bash | |||||
which ls | |||||
#+end_src | |||||
#+RESULTS: | |||||
: /usr/bin/ls | |||||
* Question 4 | |||||
mv test_file.tot test_file.txt | |||||
rename 's/tot/txt/' test-file.tot | |||||
* Question 5 | |||||
#+begin_src bash | |||||
echo -e "The location of hundreds of crab pots\nLittle Red Riding Hood\nThe location of hundreds of crab pots\nThe location of hundreds of crab pots\nThe sound of thunder\nEight hours in a row\nAll aboard\nEight hours in a row" | sort | uniq > newfile.txt; whoami >> newfile.txt | |||||
#+end_src | |||||
* Question 6 | |||||
ping 127.0.0.1 &> /dev/null | |||||
* Question 7 | |||||
#+begin_src bash | |||||
sort | nl -ba > output.txt | |||||
#+end_src | |||||
#+RESULTS: | |||||
* Question 8 | |||||
cd /home/rinri/testdir | |||||
cd ../../home/rinri/testdir | |||||
cd ~/testdir | |||||
cd; cd testdir | |||||
* Question 9 | |||||
#+begin_src bash | |||||
awk -F ':' '{print $7;}' /etc/passwd | sort | uniq | |||||
#+end_src | |||||
#+RESULTS: | |||||
: /bin/bash | |||||
: /bin/false | |||||
: /bin/zsh | |||||
: /sbin/nologin | |||||
: /usr/bin/git-shell | |||||
: /usr/bin/nologin |
@@ -0,0 +1,305 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-02-22 Wed 15:55 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab4 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab4 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#orgb19b1fd">1. Question 1</a></li> | |||||
<li><a href="#org71726c2">2. Question 2</a></li> | |||||
<li><a href="#orgf7b5bdd">3. Question 3</a></li> | |||||
<li><a href="#org54ff846">4. Question 4</a></li> | |||||
<li><a href="#org5397b06">5. Question 5</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgb19b1fd" class="outline-2"> | |||||
<h2 id="orgb19b1fd"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">grep</span> -E <span style="color: #c3e88d;">'(ERROR|WARNING)'</span> server-data.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org71726c2" class="outline-2"> | |||||
<h2 id="org71726c2"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">grep</span> -v <span style="color: #c3e88d;">'INFO'</span> server-data.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgf7b5bdd" class="outline-2"> | |||||
<h2 id="orgf7b5bdd"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">grep</span> -c <span style="color: #c3e88d;">'ERROR'</span> server-data.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
2 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org54ff846" class="outline-2"> | |||||
<h2 id="org54ff846"><span class="section-number-2">4.</span> Question 4</h2> | |||||
<div class="outline-text-2" id="text-4"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">sed -E <span style="color: #c3e88d;">'s/([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\/([0-2]?[0-9]|3[0-2])/xxx.xxx.xxx.xxx\/xx/g'</span> server-data.log > newlog.log | |||||
<span style="color: #c792ea;">cat</span> newlog.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.410.15.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
Log1 2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' END | |||||
2022/09/18 13:25:35 wazuh-remoted: ACTION: none INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5397b06" class="outline-2"> | |||||
<h2 id="org5397b06"><span class="section-number-2">5.</span> Question 5</h2> | |||||
<div class="outline-text-2" id="text-5"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">grep</span> -P <span style="color: #c3e88d;">"^2022\/09\/18 13:25:(34|35) wazuh-remoted: (INFO|ERROR|WARNING): Remote syslog (allowed|blocked|not parsed) from: '10\.110\.(15|18)\.0\/24'$"</span> server-data.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-02-22 Wed 15:55</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,62 @@ | |||||
#+title: Lab4 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
#+begin_src bash | |||||
grep -E '(ERROR|WARNING)' server-data.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: 2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
* Question 2 | |||||
#+begin_src bash | |||||
grep -v 'INFO' server-data.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: 2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
* Question 3 | |||||
#+begin_src bash | |||||
grep -c 'ERROR' server-data.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: 2 | |||||
* Question 4 | |||||
#+begin_src bash | |||||
sed -E 's/([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\/([0-2]?[0-9]|3[0-2])/xxx.xxx.xxx.xxx\/xx/g' server-data.log > newlog.log | |||||
cat newlog.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: 2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
: 2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.410.15.0/24' | |||||
: 2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
: 2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: 'xxx.xxx.xxx.xxx/xx' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
: Log1 2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' END | |||||
: 2022/09/18 13:25:35 wazuh-remoted: ACTION: none INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
* Question 5 | |||||
#+begin_src bash | |||||
grep -P "^2022\/09\/18 13:25:(34|35) wazuh-remoted: (INFO|ERROR|WARNING): Remote syslog (allowed|blocked|not parsed) from: '10\.110\.(15|18)\.0\/24'$" server-data.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: 2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
: 2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
: 2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' |
@@ -0,0 +1,9 @@ | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.410.15.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: 'xxx.xxx.xxx.xxx/xx' | |||||
Log1 2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' | |||||
2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' END | |||||
2022/09/18 13:25:35 wazuh-remoted: ACTION: none INFO: Remote syslog allowed from: 'xxx.xxx.xxx.xxx/xx' |
@@ -0,0 +1,9 @@ | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.410.15.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
2022/09/18 13:25:34 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: WARNING: Remote syslog not parsed from: '10.110.18.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: ERROR: Remote syslog blocked from: '10.110.18.0/24' | |||||
Log1 2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' | |||||
2022/09/18 13:25:35 wazuh-remoted: INFO: Remote syslog allowed from: '10.110.15.0/24' END | |||||
2022/09/18 13:25:35 wazuh-remoted: ACTION: none INFO: Remote syslog allowed from: '10.110.15.0/24' |
@@ -0,0 +1,306 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-03-02 Thu 23:55 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab5 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab5 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#orgc73e026">1. Question 1</a></li> | |||||
<li><a href="#org1d63a7a">2. Question 2</a></li> | |||||
<li><a href="#org4ea83ba">3. Question 3</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgc73e026" class="outline-2"> | |||||
<h2 id="orgc73e026"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Username: </span><span style="color: #89DDFF; font-weight: bold;">$(whoami)</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Home Directory: </span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">HOME</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Shell: </span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">SHELL</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Hostname: </span><span style="color: #89DDFF; font-weight: bold;">$(hostname)</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #ffcb6b;">ipaddress</span>=<span style="color: #c3e88d;">"</span><span style="color: #89DDFF; font-weight: bold;">$(ip addr | </span><span style="color: #89DDFF; font-weight: bold;">grep</span><span style="color: #89DDFF; font-weight: bold;"> -A5 "enp2s0f1:" | </span><span style="color: #89DDFF; font-weight: bold;">grep</span><span style="color: #89DDFF; font-weight: bold;"> "inet .*" | awk '{print </span><span style="color: #89DDFF; font-weight: bold;">$</span><span style="color: #89DDFF; font-weight: bold;">2</span><span style="color: #89DDFF; font-weight: bold;">}')</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"IP address: </span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">ipaddress</span><span style="color: #c3e88d;">"</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
Username: rinri | |||||
Home Directory: /home/rinri | |||||
Shell: /bin/zsh | |||||
Hostname: akemi | |||||
IP address: 10.244.1.78/24 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org1d63a7a" class="outline-2"> | |||||
<h2 id="org1d63a7a"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #ffcb6b;">HOME</span>=lab5-solution.org <span style="color: #676E95;"># </span><span style="color: #676E95;">THIS IS DONE TO NOT MAKE HOME BACKUP WHEN EXPORTING</span> | |||||
<span style="color: #c792ea;">sudo</span> <span style="color: #c792ea;">mkdir</span> -p /var/backups | |||||
<span style="color: #ffcb6b;">FNAME</span>=<span style="color: #c3e88d;">"</span><span style="color: #89DDFF; font-weight: bold;">$(</span><span style="color: #89DDFF; font-weight: bold;">date</span><span style="color: #89DDFF; font-weight: bold;"> '+/var/backups/home_backup_%b_%d_%Y_%H_%M_%S.tar.gz')</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">sudo</span> tar caf $<span style="color: #ffcb6b;">FNAME</span> $<span style="color: #ffcb6b;">HOME</span> | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org4ea83ba" class="outline-2"> | |||||
<h2 id="org4ea83ba"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">uname -svm | |||||
w | |||||
<span style="color: #ffcb6b;">CUR_USERS</span>=<span style="color: #c3e88d;">"</span><span style="color: #89DDFF; font-weight: bold;">$(who | awk '{print </span><span style="color: #89DDFF; font-weight: bold;">$</span><span style="color: #89DDFF; font-weight: bold;">1</span><span style="color: #89DDFF; font-weight: bold;">}' | sort | uniq)</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #89DDFF;">if</span> <span style="color: #c792ea;">[</span> -d <span style="color: #c3e88d;">"/sys/firmware/efi"</span> <span style="color: #c792ea;">]</span>; <span style="color: #89DDFF;">then</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"EFI"</span> | |||||
<span style="color: #89DDFF;">else</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"No EFI"</span> | |||||
<span style="color: #89DDFF;">fi</span> | |||||
lsblk -o <span style="color: #c3e88d;">"+PTTYPE"</span> | sed <span style="color: #c3e88d;">'s/^\([A-Za-z]*\) \(.*\)gpt/\1*\2gpt/'</span> | |||||
efibootmgr | <span style="color: #c792ea;">grep</span> <span style="color: #c3e88d;">"Boot</span><span style="color: #89DDFF; font-weight: bold;">$(efibootmgr | </span><span style="color: #89DDFF; font-weight: bold;">grep</span><span style="color: #89DDFF; font-weight: bold;"> "BootOrder" | awk '{print substr(</span><span style="color: #89DDFF; font-weight: bold;">$</span><span style="color: #89DDFF; font-weight: bold;">2</span><span style="color: #89DDFF; font-weight: bold;">, 0, 4)</span><span style="color: #c3e88d;">;}')"</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="orge8b7bd2"> | |||||
Linux #1 SMP PREEMPT_DYNAMIC Tue, 14 Feb 2023 22:08:08 +0000 x86_64 | |||||
23:55:56 up 9:44, 2 users, load average: 1.35, 1.71, 1.34 | |||||
USER TTY LOGIN@ IDLE JCPU PCPU WHAT | |||||
rinri tty1 14:11 9:44m 8:14 0.00s xinit /home/rinri/.xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.unEBAJdBrv | |||||
root tty2 14:46 9:09m 0.00s 0.00s -bash | |||||
EFI | |||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS PTTYPE | |||||
sda* 8:0 0 931.5G 0 disk gpt | |||||
├─sda1 8:1 0 499M 0 part gpt | |||||
├─sda2 8:2 0 100M 0 part gpt | |||||
├─sda3 8:3 0 16M 0 part gpt | |||||
├─sda4 8:4 0 42.4G 0 part gpt | |||||
├─sda5 8:5 0 38.8G 0 part gpt | |||||
├─sda6 8:6 0 100M 0 part gpt | |||||
├─sda7 8:7 0 3.1G 0 part gpt | |||||
├─sda8 8:8 0 315G 0 part /mnt/rec gpt | |||||
└─sda9 8:9 0 531.5G 0 part /mnt/data gpt | |||||
sdb* 8:16 0 465.8G 0 disk gpt | |||||
├─sdb1 8:17 0 16M 0 part gpt | |||||
├─sdb2 8:18 0 250G 0 part gpt | |||||
├─sdb3 8:19 0 64.7G 0 part / gpt | |||||
├─sdb4 8:20 0 97.2G 0 part /home gpt | |||||
├─sdb5 8:21 0 8G 0 part [SWAP] gpt | |||||
├─sdb6 8:22 0 781M 0 part /boot gpt | |||||
├─sdb7 8:23 0 44G 0 part gpt | |||||
└─sdb8 8:24 0 1G 0 part gpt | |||||
Boot0003* Arch BTW HD(7,GPT,1d75b784-ef17-3c4d-9e74-0b058e17bf83,0x3a1ff800,0x18680f)/File(\vmlinuz-linux)72006f006f0074003d00500041005200540055005500490044003d00660062006500660039003600310033002d0066006200660035002d0038003400340035002d0038006400310063002d00370061003600330037003000390064003100320032003900200072006500730075006d0065003d00500041005200540055005500490044003d00660033003700300031003100360031002d0035006500350036002d0065003000340037002d0061006200640031002d00390063003600380034003100320030006400340061006400200072007700200069006e0069007400720064003d005c0069006e0069007400720061006d00660073002d006c0069006e00750078002e0069006d006700 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-03-02 Thu 23:55</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,82 @@ | |||||
#+title: Lab5 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
#+begin_src bash | |||||
echo "Username: $(whoami)" | |||||
echo "Home Directory: $HOME" | |||||
echo "Shell: $SHELL" | |||||
echo "Hostname: $(hostname)" | |||||
ipaddress="$(ip addr | grep -A5 "enp2s0f1:" | grep "inet .*" | awk '{print $2}')" | |||||
echo "IP address: $ipaddress" | |||||
#+end_src | |||||
#+RESULTS: | |||||
: Username: rinri | |||||
: Home Directory: /home/rinri | |||||
: Shell: /bin/zsh | |||||
: Hostname: akemi | |||||
: IP address: 10.244.1.78/24 | |||||
* Question 2 | |||||
#+begin_src bash | |||||
HOME=lab5-solution.org # THIS IS DONE TO NOT MAKE HOME BACKUP WHEN EXPORTING | |||||
sudo mkdir -p /var/backups | |||||
FNAME="$(date '+/var/backups/home_backup_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
sudo tar caf $FNAME $HOME | |||||
#+end_src | |||||
#+RESULTS: | |||||
* Question 3 | |||||
#+begin_src bash | |||||
uname -svm | |||||
w | |||||
CUR_USERS="$(who | awk '{print $1}' | sort | uniq)" | |||||
if [ -d "/sys/firmware/efi" ]; then | |||||
echo "EFI" | |||||
else | |||||
echo "No EFI" | |||||
fi | |||||
lsblk -o "+PTTYPE" | sed 's/^\([A-Za-z]*\) \(.*\)gpt/\1*\2gpt/' | |||||
efibootmgr | grep "Boot$(efibootmgr | grep "BootOrder" | awk '{print substr($2, 0, 4);}')" | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
Linux #1 SMP PREEMPT_DYNAMIC Tue, 14 Feb 2023 22:08:08 +0000 x86_64 | |||||
23:43:06 up 9:31, 2 users, load average: 0.94, 1.05, 0.96 | |||||
USER TTY LOGIN@ IDLE JCPU PCPU WHAT | |||||
rinri tty1 14:11 9:31m 7:29 0.00s xinit /home/rinri/.xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.unEBAJdBrv | |||||
root tty2 14:46 8:56m 0.00s 0.00s -bash | |||||
EFI | |||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS PTTYPE | |||||
sda* 8:0 0 931.5G 0 disk gpt | |||||
├─sda1 8:1 0 499M 0 part gpt | |||||
├─sda2 8:2 0 100M 0 part gpt | |||||
├─sda3 8:3 0 16M 0 part gpt | |||||
├─sda4 8:4 0 42.4G 0 part gpt | |||||
├─sda5 8:5 0 38.8G 0 part gpt | |||||
├─sda6 8:6 0 100M 0 part gpt | |||||
├─sda7 8:7 0 3.1G 0 part gpt | |||||
├─sda8 8:8 0 315G 0 part /mnt/rec gpt | |||||
└─sda9 8:9 0 531.5G 0 part /mnt/data gpt | |||||
sdb* 8:16 0 465.8G 0 disk gpt | |||||
├─sdb1 8:17 0 16M 0 part gpt | |||||
├─sdb2 8:18 0 250G 0 part gpt | |||||
├─sdb3 8:19 0 64.7G 0 part / gpt | |||||
├─sdb4 8:20 0 97.2G 0 part /home gpt | |||||
├─sdb5 8:21 0 8G 0 part [SWAP] gpt | |||||
├─sdb6 8:22 0 781M 0 part /boot gpt | |||||
├─sdb7 8:23 0 44G 0 part gpt | |||||
└─sdb8 8:24 0 1G 0 part gpt | |||||
Boot0003* Arch BTW HD(7,GPT,1d75b784-ef17-3c4d-9e74-0b058e17bf83,0x3a1ff800,0x18680f)/File(\vmlinuz-linux)72006f006f0074003d00500041005200540055005500490044003d00660062006500660039003600310033002d0066006200660035002d0038003400340035002d0038006400310063002d00370061003600330037003000390064003100320032003900200072006500730075006d0065003d00500041005200540055005500490044003d00660033003700300031003100360031002d0035006500350036002d0065003000340037002d0061006200640031002d00390063003600380034003100320030006400340061006400200072007700200069006e0069007400720064003d005c0069006e0069007400720061006d00660073002d006c0069006e00750078002e0069006d006700 | |||||
#+end_example |
@@ -0,0 +1,8 @@ | |||||
#!/bin/bash | |||||
trap 'echo "Interrupt received"; exit' SIGUSR1 | |||||
while : | |||||
do | |||||
echo "Hello World" | |||||
sleep 10 | |||||
done |
@@ -0,0 +1,424 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-03-09 Thu 19:12 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab5 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab5 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#orgb4a8d53">1. Question 1</a> | |||||
<ul> | |||||
<li><a href="#orgb9d88ac">1.1. What is a zombie process</a></li> | |||||
<li><a href="#org266fff4">1.2. Finding zombie processes</a></li> | |||||
<li><a href="#org459fc7a">1.3. kill vs killall vs pkill</a></li> | |||||
<li><a href="#org5ff0fe7">1.4. top</a></li> | |||||
<li><a href="#org83cfe45">1.5. kill fun processes script</a></li> | |||||
<li><a href="#org48d69a8">1.6. Hello world</a></li> | |||||
<li><a href="#org96feea4">1.7. System util</a></li> | |||||
</ul> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgb4a8d53" class="outline-2"> | |||||
<h2 id="orgb4a8d53"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
</div> | |||||
<div id="outline-container-orgb9d88ac" class="outline-3"> | |||||
<h3 id="orgb9d88ac"><span class="section-number-3">1.1.</span> What is a zombie process</h3> | |||||
<div class="outline-text-3" id="text-1-1"> | |||||
<p> | |||||
Zombie processes appear in parent-child process relationships. They are finished executing, but they are still in the process table. For example, when a child process finishes executing, but parent process didn’t acknowledge it yet. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org266fff4" class="outline-3"> | |||||
<h3 id="org266fff4"><span class="section-number-3">1.2.</span> Finding zombie processes</h3> | |||||
<div class="outline-text-3" id="text-1-2"> | |||||
<p> | |||||
I created a zombie process using C and then run this command: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">bat zombie.c | |||||
gcc zombie.c | |||||
./a.out & | |||||
ps aux | <span style="color: #c792ea;">grep</span> <span style="color: #c3e88d;">"defunct"</span> | <span style="color: #c792ea;">grep</span> -v <span style="color: #c3e88d;">"</span><span style="color: #c3e88d;">grep</span><span style="color: #c3e88d;">"</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org9746a26"> | |||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <unistd.h> | |||||
int main() { | |||||
pid_t p = fork(); | |||||
if (p == 0) { | |||||
exit(0); | |||||
} else { | |||||
sleep(10); | |||||
} | |||||
} | |||||
rinri 810248 0.0 0.0 0 0 ? Z 19:11 0:00 [a.out] <defunct> | |||||
</pre> | |||||
<p> | |||||
So, using the last command I can find zombie processes. Let’s say that I know that there is only one zombie process. To kill it, let’s kill its parent process: | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">kill</span> -9 $<span style="color: #c792ea;">(</span>ps -o <span style="color: #ffcb6b;">ppid</span>= -p $<span style="color: #f78c6c;">(</span>ps aux | <span style="color: #c792ea;">grep</span> -m <span style="color: #f78c6c; font-weight: bold;">1</span> <span style="color: #c3e88d;">"defunct"</span> | <span style="color: #c792ea;">grep</span> -v <span style="color: #c3e88d;">"</span><span style="color: #c3e88d;">grep</span><span style="color: #c3e88d;">"</span> | awk <span style="color: #c3e88d;">'{print $2;}'</span><span style="color: #f78c6c;">)</span><span style="color: #c792ea;">)</span> | |||||
</pre> | |||||
</div> | |||||
<p> | |||||
By using this line, it’s possible to create script to kill all the zombie processes. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org459fc7a" class="outline-3"> | |||||
<h3 id="org459fc7a"><span class="section-number-3">1.3.</span> kill vs killall vs pkill</h3> | |||||
<div class="outline-text-3" id="text-1-3"> | |||||
<p> | |||||
kill sends the specified signal to the given pid. | |||||
killall sends the specified signal to all the processes by the given process name. | |||||
pkill sends the specified signal to all the processes matching the given pattern. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5ff0fe7" class="outline-3"> | |||||
<h3 id="org5ff0fe7"><span class="section-number-3">1.4.</span> top</h3> | |||||
<div class="outline-text-3" id="text-1-4"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">top -b -n <span style="color: #f78c6c; font-weight: bold;">1</span> | head -n <span style="color: #f78c6c; font-weight: bold;">5</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
top - 19:12:03 up 2:35, 1 user, load average: 2.29, 2.75, 2.98 | |||||
Tasks: 299 total, 1 running, 298 sleeping, 0 stopped, 0 zombie | |||||
%Cpu(s): 17.4 us, 6.5 sy, 0.0 ni, 73.2 id, 0.0 wa, 0.0 hi, 2.9 si, 0.0 st | |||||
MiB Mem : 14886.6 total, 6722.9 free, 4607.7 used, 3556.0 buff/cache | |||||
MiB Swap: 8243.0 total, 8243.0 free, 0.0 used. 9791.8 avail Mem | |||||
</pre> | |||||
<p> | |||||
(Explaining the first evaluation, results may differ after export) | |||||
The Tasks line says, that there is 283 total processes, 1 of them is currently running, others are sleeping. No stopeed and no zombie processes. | |||||
The %Cpu(s) line says about processor utilization. | |||||
(Taken from the Lab6 file) | |||||
us is the percent of time spent running user processes. | |||||
sy is the percent of time spent running the kernel. | |||||
ni is the percent of time spent running processes with manually configured nice values. | |||||
id is the percent of time idle (if high, CPU may be overworked). | |||||
wa is the percent of wait time (if high, CPU is waiting for I/O access). | |||||
hi is the percent of time managing hardware interrupts. | |||||
si is the percent of time managing software interrupts. | |||||
st is the percent of virtual CPU time waiting for access to physical CPU. | |||||
Values such as id, wa, and st help identify whether the system is overworked. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org83cfe45" class="outline-3"> | |||||
<h3 id="org83cfe45"><span class="section-number-3">1.5.</span> kill fun processes script</h3> | |||||
<div class="outline-text-3" id="text-1-5"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">bash -c <span style="color: #c3e88d;">"exec -a fun</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">{RANDOM}</span><span style="color: #c3e88d;">process </span><span style="color: #c3e88d;">sleep</span><span style="color: #c3e88d;"> infinity"</span> & | |||||
bash -c <span style="color: #c3e88d;">"exec -a fun</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">{RANDOM}</span><span style="color: #c3e88d;">process </span><span style="color: #c3e88d;">sleep</span><span style="color: #c3e88d;"> infinity"</span> & | |||||
bash -c <span style="color: #c3e88d;">"exec -a fun</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">{RANDOM}</span><span style="color: #c3e88d;">process </span><span style="color: #c3e88d;">sleep</span><span style="color: #c3e88d;"> infinity"</span> & | |||||
<span style="color: #ffcb6b;">FUNPROCS</span>=<span style="color: #c3e88d;">"</span><span style="color: #89DDFF; font-weight: bold;">$(</span><span style="color: #89DDFF; font-weight: bold;">pgrep</span><span style="color: #89DDFF; font-weight: bold;"> -f 'fun.*process.*infinity')</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"Found </span><span style="color: #89DDFF; font-weight: bold;">$(</span><span style="color: #89DDFF; font-weight: bold;">echo</span><span style="color: #89DDFF; font-weight: bold;"> "</span><span style="color: #89DDFF; font-weight: bold;">$</span><span style="color: #89DDFF; font-weight: bold;">FUNPROCS</span><span style="color: #89DDFF; font-weight: bold;">" | wc -l)</span><span style="color: #c3e88d;"> processes:"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">FUNPROCS</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #89DDFF;">for</span> FUNPROC<span style="color: #89DDFF;"> in</span> $<span style="color: #ffcb6b;">FUNPROCS</span> | |||||
<span style="color: #89DDFF;">do</span> | |||||
<span style="color: #c792ea;">kill</span> -9 <span style="color: #c3e88d;">"</span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">FUNPROC</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #c792ea;">echo</span> <span style="color: #c3e88d;">"killed </span><span style="color: #f78c6c;">$</span><span style="color: #ffcb6b;">FUNPROC</span><span style="color: #c3e88d;">"</span> | |||||
<span style="color: #89DDFF;">done</span> | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
Found 3 processes: | |||||
811145 | |||||
811146 | |||||
811147 | |||||
killed 811145 | |||||
killed 811146 | |||||
killed 811147 | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org48d69a8" class="outline-3"> | |||||
<h3 id="org48d69a8"><span class="section-number-3">1.6.</span> Hello world</h3> | |||||
<div class="outline-text-3" id="text-1-6"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">bat helloworld.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
trap 'echo "Interrupt received"; exit' SIGUSR1 | |||||
while : | |||||
do | |||||
echo "Hello World" | |||||
sleep 10 | |||||
done | |||||
</pre> | |||||
<p> | |||||
To kill: | |||||
kill -s SIGUSR1 “$(ps aux | grep ”helloworld.sh“ | grep -v ”grep“ | awk ’{print $2}’)” | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org96feea4" class="outline-3"> | |||||
<h3 id="org96feea4"><span class="section-number-3">1.7.</span> System util</h3> | |||||
<div class="outline-text-3" id="text-1-7"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">bat status.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org928686a"> | |||||
#!/bin/bash | |||||
while : | |||||
do | |||||
CPUUSAGE="$(top -b - n 1 | grep "Cpu" | awk '{print 100-$8}')%" | |||||
MEMUSAGE="$(free -h | grep "Mem" | awk '{print $3/$2*100}')%" | |||||
# disk usage for root directory | |||||
DISKUSAGE="$(df -h | awk '{ if ($6 == "/") | |||||
print $5; | |||||
}')" | |||||
echo "$(date) CPU: $CPUUSAGE Mem: $MEMUSAGE Disk:$DISKUSAGE" >> /var/log/system_utilization.log | |||||
sleep 15 | |||||
done | |||||
</pre> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">bat /var/log/system_utilization.log | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
Thu Mar 9 07:09:13 PM MSK 2023 CPU: 43.2% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:09:29 PM MSK 2023 CPU: 45.7% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:09:44 PM MSK 2023 CPU: 34.1% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:09:59 PM MSK 2023 CPU: 28.5% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:10:14 PM MSK 2023 CPU: 22.5% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:10:30 PM MSK 2023 CPU: 34.8% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:10:45 PM MSK 2023 CPU: 37.6% Mem: 32.1429% Disk:70% | |||||
Thu Mar 9 07:11:00 PM MSK 2023 CPU: 29.8% Mem: 32.1429% Disk:70% | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-03-09 Thu 19:12</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,148 @@ | |||||
#+title: Lab5 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
** What is a zombie process | |||||
Zombie processes appear in parent-child process relationships. They are finished executing, but they are still in the process table. For example, when a child process finishes executing, but parent process didn't acknowledge it yet. | |||||
** Finding zombie processes | |||||
I created a zombie process using C and then run this command: | |||||
#+begin_src bash | |||||
bat zombie.c | |||||
gcc zombie.c | |||||
./a.out & | |||||
ps aux | grep "defunct" | grep -v "grep" | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <unistd.h> | |||||
int main() { | |||||
pid_t p = fork(); | |||||
if (p == 0) { | |||||
exit(0); | |||||
} else { | |||||
sleep(2); | |||||
} | |||||
} | |||||
rinri 178372 0.0 0.0 0 0 ? Z 17:11 0:00 [a.out] <defunct> | |||||
#+end_example | |||||
So, using the last command I can find zombie processes. Let's say that I know that there is only one zombie process. To kill it, let's kill its parent process: | |||||
#+begin_src bash | |||||
kill -9 $(ps -o ppid= -p $(ps aux | grep -m 1 "defunct" | grep -v "grep" | awk '{print $2;}')) | |||||
#+end_src | |||||
#+RESULTS: | |||||
By using this line, it's possible to create script to kill all the zombie processes. | |||||
** kill vs killall vs pkill | |||||
kill sends the specified signal to the given pid. | |||||
killall sends the specified signal to all the processes by the given process name. | |||||
pkill sends the specified signal to all the processes matching the given pattern. | |||||
** top | |||||
#+begin_src bash | |||||
top -b -n 1 | head -n 5 | |||||
#+end_src | |||||
#+RESULTS: | |||||
: top - 17:29:37 up 52 min, 1 user, load average: 0.97, 1.02, 1.18 | |||||
: Tasks: 283 total, 1 running, 282 sleeping, 0 stopped, 0 zombie | |||||
: %Cpu(s): 3.8 us, 3.0 sy, 0.0 ni, 92.5 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st | |||||
: MiB Mem : 14886.6 total, 9247.6 free, 3192.2 used, 2446.7 buff/cache | |||||
: MiB Swap: 8243.0 total, 8243.0 free, 0.0 used. 11272.0 avail Mem | |||||
(Explaining the first evaluation, results may differ after export) | |||||
The Tasks line says, that there is 283 total processes, 1 of them is currently running, others are sleeping. No stopeed and no zombie processes. | |||||
The %Cpu(s) line says about processor utilization. | |||||
(Taken from the Lab6 file) | |||||
us is the percent of time spent running user processes. | |||||
sy is the percent of time spent running the kernel. | |||||
ni is the percent of time spent running processes with manually configured nice values. | |||||
id is the percent of time idle (if high, CPU may be overworked). | |||||
wa is the percent of wait time (if high, CPU is waiting for I/O access). | |||||
hi is the percent of time managing hardware interrupts. | |||||
si is the percent of time managing software interrupts. | |||||
st is the percent of virtual CPU time waiting for access to physical CPU. | |||||
Values such as id, wa, and st help identify whether the system is overworked. | |||||
** kill fun processes script | |||||
#+begin_src bash | |||||
bash -c "exec -a fun${RANDOM}process sleep infinity" & | |||||
bash -c "exec -a fun${RANDOM}process sleep infinity" & | |||||
bash -c "exec -a fun${RANDOM}process sleep infinity" & | |||||
FUNPROCS="$(pgrep -f 'fun.*process.*infinity')" | |||||
echo "Found $(echo "$FUNPROCS" | wc -l) processes:" | |||||
echo "$FUNPROCS" | |||||
for FUNPROC in $FUNPROCS | |||||
do | |||||
kill -9 "$FUNPROC" | |||||
echo "killed $FUNPROC" | |||||
done | |||||
#+end_src | |||||
#+RESULTS: | |||||
: Found 3 processes: | |||||
: 394357 | |||||
: 394358 | |||||
: 394359 | |||||
: killed 394357 | |||||
: killed 394358 | |||||
: killed 394359 | |||||
** Hello world | |||||
#+begin_src bash | |||||
bat helloworld.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: #!/bin/bash | |||||
: | |||||
: trap 'echo "Interrupt received"; exit' SIGUSR1 | |||||
: while : | |||||
: do | |||||
: echo "Hello World" | |||||
: sleep 10 | |||||
: done | |||||
To kill: | |||||
kill -s SIGUSR1 "$(ps aux | grep "helloworld.sh" | grep -v "grep" | awk '{print $2}')" | |||||
** System util | |||||
#+begin_src bash | |||||
bat status.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
while : | |||||
do | |||||
CPUUSAGE="$(top -b - n 1 | grep "Cpu" | awk '{print 100-$8}')%" | |||||
MEMUSAGE="$(free -h | grep "Mem" | awk '{print $3/$2*100}')%" | |||||
# disk usage for root directory | |||||
DISKUSAGE="$(df -h | awk '{ if ($6 == "/") | |||||
print $5; | |||||
}')" | |||||
echo "$(date) CPU: $CPUUSAGE Mem: $MEMUSAGE Disk:$DISKUSAGE" >> /var/log/system_utilization.log | |||||
sleep 15 | |||||
done | |||||
#+end_example | |||||
#+begin_src bash | |||||
bat /var/log/system_utilization.log | |||||
#+end_src | |||||
#+RESULTS: | |||||
: Thu Mar 9 07:09:13 PM MSK 2023 CPU: 43.2% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:09:29 PM MSK 2023 CPU: 45.7% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:09:44 PM MSK 2023 CPU: 34.1% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:09:59 PM MSK 2023 CPU: 28.5% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:10:14 PM MSK 2023 CPU: 22.5% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:10:30 PM MSK 2023 CPU: 34.8% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:10:45 PM MSK 2023 CPU: 37.6% Mem: 32.1429% Disk:70% | |||||
: Thu Mar 9 07:11:00 PM MSK 2023 CPU: 29.8% Mem: 32.1429% Disk:70% |
@@ -0,0 +1,14 @@ | |||||
#!/bin/bash | |||||
while : | |||||
do | |||||
CPUUSAGE="$(top -b - n 1 | grep "Cpu" | awk '{print 100-$8}')%" | |||||
MEMUSAGE="$(free -h | grep "Mem" | awk '{print $3/$2*100}')%" | |||||
# disk usage for root directory | |||||
DISKUSAGE="$(df -h | awk '{ if ($6 == "/") | |||||
print $5; | |||||
}')" | |||||
echo "$(date) CPU: $CPUUSAGE Mem: $MEMUSAGE Disk:$DISKUSAGE" >> /var/log/system_utilization.log | |||||
sleep 15 | |||||
done |
@@ -0,0 +1,12 @@ | |||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <unistd.h> | |||||
int main() { | |||||
pid_t p = fork(); | |||||
if (p == 0) { | |||||
exit(0); | |||||
} else { | |||||
sleep(2); | |||||
} | |||||
} |
@@ -0,0 +1,4 @@ | |||||
#!/bin/bash | |||||
rm /home/rinri/edu/sna/funny-dir_* | |||||
FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /home/rinri/edu/sna/funny-dir |
@@ -0,0 +1,4 @@ | |||||
#!/bin/bash | |||||
rm /home/rinri/edu/sna/nginx-www_* | |||||
FNAME="$(date '+/home/rinri/edu/sna/nginx-www_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /var/www/ |
@@ -0,0 +1,2 @@ | |||||
FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /home/rinri/edu/sna/funny-dir |
@@ -0,0 +1,327 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-03-16 Thu 23:57 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab7 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab7 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org8c14420">1. Question 1</a> | |||||
<ul> | |||||
<li><a href="#orgc4ec78f">1.1. Cron job</a></li> | |||||
<li><a href="#org5944223">1.2. Anacron</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#org0c66d73">2. Question 2</a> | |||||
<ul> | |||||
<li><a href="#org3b52abd">2.1. Cron job</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgc000000">3. Question 3</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org8c14420" class="outline-2"> | |||||
<h2 id="org8c14420"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
</div> | |||||
<div id="outline-container-orgc4ec78f" class="outline-3"> | |||||
<h3 id="orgc4ec78f"><span class="section-number-3">1.1.</span> Cron job</h3> | |||||
<div class="outline-text-3" id="text-1-1"> | |||||
<p> | |||||
0 0 */5 * * /home/rinri/edu/sna/backup.sh | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> backup.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /home/rinri/edu/sna/funny-dir | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org5944223" class="outline-3"> | |||||
<h3 id="org5944223"><span class="section-number-3">1.2.</span> Anacron</h3> | |||||
<div class="outline-text-3" id="text-1-2"> | |||||
<p> | |||||
1 10 backup-anacron /home/rinri/edu/sna/backup-anacron.sh | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> backup-anacron.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
rm /home/rinri/edu/sna/funny-dir_* | |||||
FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /home/rinri/edu/sna/funny-dir | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org0c66d73" class="outline-2"> | |||||
<h2 id="org0c66d73"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
</div> | |||||
<div id="outline-container-org3b52abd" class="outline-3"> | |||||
<h3 id="org3b52abd"><span class="section-number-3">2.1.</span> Cron job</h3> | |||||
<div class="outline-text-3" id="text-2-1"> | |||||
<p> | |||||
0 0 * * 0 /home/rinri/edu/sna/backup-nginx.sh | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> backup-nginx.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
rm /home/rinri/edu/sna/nginx-www_* | |||||
FNAME="$(date '+/home/rinri/edu/sna/nginx-www_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
tar caf "$FNAME" /var/www/ | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgc000000" class="outline-2"> | |||||
<h2 id="orgc000000"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<p> | |||||
5 * * * * /home/rinri/edu/sna/log-info.sh “5 minutes after midnight everyday” | |||||
</p> | |||||
<p> | |||||
0 10 * * 1-5 /home/rinri/edu/sna/log-info.sh “10:00 on weekdays” | |||||
</p> | |||||
<p> | |||||
0 4 * * 1 /home/rinri/edu/sna/log-info.sh “4:00 on Monday” | |||||
</p> | |||||
<p> | |||||
0 0 8-14 * 6 /home/rinri/edu/sna/log-info.sh “second saturday of the month” | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> log-info.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
echo "$(date '+%d-%m-%y %H:%M:%S') $1" >> /var/log/sna_cron.log | |||||
</pre> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-03-16 Thu 23:57</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,61 @@ | |||||
#+title: Lab7 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
** Cron job | |||||
0 0 */5 * * /home/rinri/edu/sna/backup.sh | |||||
#+begin_src bash | |||||
cat backup.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
: tar caf "$FNAME" /home/rinri/edu/sna/funny-dir | |||||
** Anacron | |||||
1 10 backup-anacron /home/rinri/edu/sna/backup-anacron.sh | |||||
#+begin_src bash | |||||
cat backup-anacron.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: #!/bin/bash | |||||
: rm /home/rinri/edu/sna/funny-dir_* | |||||
: FNAME="$(date '+/home/rinri/edu/sna/funny-dir_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
: tar caf "$FNAME" /home/rinri/edu/sna/funny-dir | |||||
* Question 2 | |||||
** Cron job | |||||
0 0 * * 0 /home/rinri/edu/sna/backup-nginx.sh | |||||
#+begin_src bash | |||||
cat backup-nginx.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: #!/bin/bash | |||||
: rm /home/rinri/edu/sna/nginx-www_* | |||||
: FNAME="$(date '+/home/rinri/edu/sna/nginx-www_%b_%d_%Y_%H_%M_%S.tar.gz')" | |||||
: tar caf "$FNAME" /var/www/ | |||||
* Question 3 | |||||
5 * * * * /home/rinri/edu/sna/log-info.sh "5 minutes after midnight everyday" | |||||
0 10 * * 1-5 /home/rinri/edu/sna/log-info.sh "10:00 on weekdays" | |||||
0 4 * * 1 /home/rinri/edu/sna/log-info.sh "4:00 on Monday" | |||||
0 0 8-14 * 6 /home/rinri/edu/sna/log-info.sh "second saturday of the month" | |||||
#+begin_src bash | |||||
cat log-info.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: #!/bin/bash | |||||
: echo "$(date '+%d-%m-%y %H:%M:%S') $1" >> /var/log/sna_cron.log |
@@ -0,0 +1,2 @@ | |||||
#!/bin/bash | |||||
echo "$(date '+%d-%m-%y %H:%M:%S') $1" >> /var/log/sna_cron.log |
@@ -0,0 +1,466 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-03-23 Thu 23:57 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab8 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab8 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org0007992">1. Question 1</a></li> | |||||
<li><a href="#orga4022cb">2. Question 2</a> | |||||
<ul> | |||||
<li><a href="#orgaa7681b">2.1. Information taken from man pages:</a> | |||||
<ul> | |||||
<li><a href="#org3d62e77">2.1.1. basic.target</a></li> | |||||
<li><a href="#org2c7a54d">2.1.2. graphical.target</a></li> | |||||
<li><a href="#orgaa0ad68">2.1.3. multi-user.target</a></li> | |||||
<li><a href="#org088723a">2.1.4. sysinit.target</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#org28d8cd5">2.2. Wants for sysinit.target</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#org6fe32f2">3. Question 3</a></li> | |||||
<li><a href="#org198189e">4. Question 4</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org0007992" class="outline-2"> | |||||
<h2 id="org0007992"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash">systemd-analyze | |||||
systemd-analyze plot > systemd.svg | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
Startup finished in 5.093s (firmware) + 122ms (loader) + 7.459s (kernel) + 4.545s (userspace) = 17.221s | |||||
graphical.target reached after 4.544s in userspace. | |||||
</pre> | |||||
<div id="orgcc0476f" class="figure"> | |||||
<p><img src="./systemd.svg" alt="systemd.svg" class="org-svg" width="1000px" /> | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orga4022cb" class="outline-2"> | |||||
<h2 id="orga4022cb"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
graphical.target -> multi-user.target -> basic.target -> sysinit.target | |||||
</p> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/graphical.target | |||||
<span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/multi-user.target | |||||
<span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/basic.target | |||||
<span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/sysinit.target | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="org05984f4"> | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Graphical Interface | |||||
Documentation=man:systemd.special(7) | |||||
Requires=multi-user.target | |||||
Wants=display-manager.service | |||||
Conflicts=rescue.service rescue.target | |||||
After=multi-user.target rescue.service rescue.target display-manager.service | |||||
AllowIsolate=yes | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Multi-User System | |||||
Documentation=man:systemd.special(7) | |||||
Requires=basic.target | |||||
Conflicts=rescue.service rescue.target | |||||
After=basic.target rescue.service rescue.target | |||||
AllowIsolate=yes | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Basic System | |||||
Documentation=man:systemd.special(7) | |||||
Requires=sysinit.target | |||||
Wants=sockets.target timers.target paths.target slices.target | |||||
After=sysinit.target sockets.target paths.target slices.target tmp.mount | |||||
# We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in | |||||
# remote-fs.target by default, hence pull them in explicitly here. Note that we | |||||
# require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as | |||||
# we support that unit being masked, and this should not be considered an error. | |||||
RequiresMountsFor=/var /var/tmp | |||||
Wants=tmp.mount | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=System Initialization | |||||
Documentation=man:systemd.special(7) | |||||
Wants=local-fs.target swap.target | |||||
After=local-fs.target swap.target | |||||
Conflicts=emergency.service emergency.target | |||||
Before=emergency.service emergency.target | |||||
</pre> | |||||
</div> | |||||
<div id="outline-container-orgaa7681b" class="outline-3"> | |||||
<h3 id="orgaa7681b"><span class="section-number-3">2.1.</span> Information taken from man pages:</h3> | |||||
<div class="outline-text-3" id="text-2-1"> | |||||
</div> | |||||
<div id="outline-container-org3d62e77" class="outline-4"> | |||||
<h4 id="org3d62e77"><span class="section-number-4">2.1.1.</span> basic.target</h4> | |||||
<div class="outline-text-4" id="text-2-1-1"> | |||||
<p> | |||||
A special target unit covering basic boot-up. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org2c7a54d" class="outline-4"> | |||||
<h4 id="org2c7a54d"><span class="section-number-4">2.1.2.</span> graphical.target</h4> | |||||
<div class="outline-text-4" id="text-2-1-2"> | |||||
<p> | |||||
A special target unit for setting up a graphical login screen. This pulls in multi-user.target. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgaa0ad68" class="outline-4"> | |||||
<h4 id="orgaa0ad68"><span class="section-number-4">2.1.3.</span> multi-user.target</h4> | |||||
<div class="outline-text-4" id="text-2-1-3"> | |||||
<p> | |||||
A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org088723a" class="outline-4"> | |||||
<h4 id="org088723a"><span class="section-number-4">2.1.4.</span> sysinit.target</h4> | |||||
<div class="outline-text-4" id="text-2-1-4"> | |||||
<p> | |||||
This target pulls in the services required for system initialization. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org28d8cd5" class="outline-3"> | |||||
<h3 id="org28d8cd5"><span class="section-number-3">2.2.</span> Wants for sysinit.target</h3> | |||||
<div class="outline-text-3" id="text-2-2"> | |||||
<p> | |||||
Wants=local-fs.target swap.target | |||||
Wants is used like Requires, but it’s less strict, meaning that it can start if the “wanted” service doesn’t exist or failed to start. | |||||
In this case, it wants local filesystems and swap to start. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org6fe32f2" class="outline-2"> | |||||
<h2 id="org6fe32f2"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> webserver.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
while true ; do | |||||
STATS="<h1>Uptime</h1>$(uptime)\n<h1>Inode and disk usage</h1>$(df -ih)\n<h1>Mem usage</h1>$(free -h)\n<h1>Syslog</h1>$(tail -n 15 /var/log/syslog)\r\n\r\n" | |||||
LEN=$(printf "%s" "$STATS" | wc -c) | |||||
RES="HTTP/1.1 200OK\r\nContent-Length: $LEN\r\n\r\n" | |||||
echo -e "$RES$STATS"| nc -l -p 1500; | |||||
done | |||||
</pre> | |||||
<p> | |||||
[Unit] | |||||
Description=stats web server | |||||
</p> | |||||
<p> | |||||
[Service] | |||||
User=root | |||||
ExecStart=/home/rinri/edu/sna/webserver.sh | |||||
Restart=always | |||||
CPUQuota=15% | |||||
MemoryMax=256000000 | |||||
</p> | |||||
<p> | |||||
[Install] | |||||
WantedBy=multi-user.target | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org198189e" class="outline-2"> | |||||
<h2 id="org198189e"><span class="section-number-2">4.</span> Question 4</h2> | |||||
<div class="outline-text-2" id="text-4"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> update.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example"> | |||||
#!/bin/bash | |||||
pacman -Sy | |||||
</pre> | |||||
<p> | |||||
[Unit] | |||||
Description=update package sources list | |||||
</p> | |||||
<p> | |||||
[Service] | |||||
User=root | |||||
ExecStart=/home/rinri/edu/sna/update.sh | |||||
</p> | |||||
<p> | |||||
[Install] | |||||
WantedBy=multi-user.target | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-03-23 Thu 23:57</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,161 @@ | |||||
#+title: Lab8 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
#+begin_src bash | |||||
systemd-analyze | |||||
systemd-analyze plot > systemd.svg | |||||
#+end_src | |||||
#+RESULTS: | |||||
: Startup finished in 5.093s (firmware) + 122ms (loader) + 7.459s (kernel) + 4.545s (userspace) = 17.221s | |||||
: graphical.target reached after 4.544s in userspace. | |||||
#+ATTR_HTML: :width 1000px | |||||
[[./systemd.svg]] | |||||
* Question 2 | |||||
graphical.target -> multi-user.target -> basic.target -> sysinit.target | |||||
#+begin_src bash | |||||
cat /usr/lib/systemd/system/graphical.target | |||||
cat /usr/lib/systemd/system/multi-user.target | |||||
cat /usr/lib/systemd/system/basic.target | |||||
cat /usr/lib/systemd/system/sysinit.target | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Graphical Interface | |||||
Documentation=man:systemd.special(7) | |||||
Requires=multi-user.target | |||||
Wants=display-manager.service | |||||
Conflicts=rescue.service rescue.target | |||||
After=multi-user.target rescue.service rescue.target display-manager.service | |||||
AllowIsolate=yes | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Multi-User System | |||||
Documentation=man:systemd.special(7) | |||||
Requires=basic.target | |||||
Conflicts=rescue.service rescue.target | |||||
After=basic.target rescue.service rescue.target | |||||
AllowIsolate=yes | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=Basic System | |||||
Documentation=man:systemd.special(7) | |||||
Requires=sysinit.target | |||||
Wants=sockets.target timers.target paths.target slices.target | |||||
After=sysinit.target sockets.target paths.target slices.target tmp.mount | |||||
# We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in | |||||
# remote-fs.target by default, hence pull them in explicitly here. Note that we | |||||
# require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as | |||||
# we support that unit being masked, and this should not be considered an error. | |||||
RequiresMountsFor=/var /var/tmp | |||||
Wants=tmp.mount | |||||
# SPDX-License-Identifier: LGPL-2.1-or-later | |||||
# | |||||
# This file is part of systemd. | |||||
# | |||||
# systemd is free software; you can redistribute it and/or modify it | |||||
# under the terms of the GNU Lesser General Public License as published by | |||||
# the Free Software Foundation; either version 2.1 of the License, or | |||||
# (at your option) any later version. | |||||
[Unit] | |||||
Description=System Initialization | |||||
Documentation=man:systemd.special(7) | |||||
Wants=local-fs.target swap.target | |||||
After=local-fs.target swap.target | |||||
Conflicts=emergency.service emergency.target | |||||
Before=emergency.service emergency.target | |||||
#+end_example | |||||
** Information taken from man pages: | |||||
*** basic.target | |||||
A special target unit covering basic boot-up. | |||||
*** graphical.target | |||||
A special target unit for setting up a graphical login screen. This pulls in multi-user.target. | |||||
*** multi-user.target | |||||
A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target. | |||||
*** sysinit.target | |||||
This target pulls in the services required for system initialization. | |||||
** Wants for sysinit.target | |||||
Wants=local-fs.target swap.target | |||||
Wants is used like Requires, but it's less strict, meaning that it can start if the "wanted" service doesn't exist or failed to start. | |||||
In this case, it wants local filesystems and swap to start. | |||||
* Question 3 | |||||
#+begin_src bash | |||||
cat webserver.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
: #!/bin/bash | |||||
: | |||||
: while true ; do | |||||
: STATS="<h1>Uptime</h1>$(uptime)\n<h1>Inode and disk usage</h1>$(df -ih)\n<h1>Mem usage</h1>$(free -h)\n<h1>Syslog</h1>$(tail -n 15 /var/log/syslog)\r\n\r\n" | |||||
: LEN=$(printf "%s" "$STATS" | wc -c) | |||||
: RES="HTTP/1.1 200OK\r\nContent-Length: $LEN\r\n\r\n" | |||||
: echo -e "$RES$STATS"| nc -l -p 1500; | |||||
: done | |||||
[Unit] | |||||
Description=stats web server | |||||
[Service] | |||||
User=root | |||||
ExecStart=/home/rinri/edu/sna/webserver.sh | |||||
Restart=always | |||||
CPUQuota=15% | |||||
MemoryMax=256000000 | |||||
[Install] | |||||
WantedBy=multi-user.target | |||||
* Question 4 | |||||
#+begin_src bash | |||||
cat update.sh | |||||
#+end_src | |||||
[Unit] | |||||
Description=update package sources list | |||||
[Service] | |||||
User=root | |||||
ExecStart=/home/rinri/edu/sna/update.sh | |||||
[Install] | |||||
WantedBy=multi-user.target |
@@ -0,0 +1,3 @@ | |||||
#!/bin/bash | |||||
pacman -Sy |
@@ -0,0 +1,8 @@ | |||||
#!/bin/bash | |||||
while true ; do | |||||
STATS="<h1>Uptime</h1>$(uptime)\n<h1>Inode and disk usage</h1>$(df -ih)\n<h1>Mem usage</h1>$(free -h)\n<h1>Syslog</h1>$(tail -n 15 /var/log/syslog)\r\n\r\n" | |||||
LEN=$(printf "%s" "$STATS" | wc -c) | |||||
RES="HTTP/1.1 200OK\r\nContent-Length: $LEN\r\n\r\n" | |||||
echo -e "$RES$STATS"| nc -l -p 1500; | |||||
done |
@@ -0,0 +1,6 @@ | |||||
Package: hellopackage | |||||
Version: 1.0 | |||||
Architecture: all | |||||
Maintainer: RinRi | |||||
Depends: python3 | |||||
Description: Hello world |
@@ -0,0 +1,11 @@ | |||||
#!/bin/bash | |||||
rm -rf hellopackage | |||||
mkdir -p hellopackage hellopackage/usr/local/bin hellopackage/var/helloworld | |||||
printf "%s" '#!/usr/bin/env python3\nprint("Hello, World!")' > hellopackage/var/helloworld/helloworld.py | |||||
printf "%s" '#!/bin/bash\n/var/helloworld/helloworld.py' > hellopackage/usr/local/bin/helloworld | |||||
chmod -R 0755 hellopackage/var/helloworld hellopackage/usr/local/bin/helloworld | |||||
mkdir -p hellopackage/DEBIAN | |||||
cp control hellopackage/DEBIAN/ | |||||
dpkg-deb --build --root-owner-group hellopackage |
@@ -0,0 +1,6 @@ | |||||
Package: hellopackage | |||||
Version: 1.0 | |||||
Architecture: all | |||||
Maintainer: RinRi | |||||
Depends: python3 | |||||
Description: Hello world |
@@ -0,0 +1 @@ | |||||
#!/bin/bash\n/var/helloworld/helloworld.py |
@@ -0,0 +1 @@ | |||||
#!/usr/bin/env python3\nprint("Hello, World!") |
@@ -0,0 +1,360 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |||||
<head> | |||||
<!-- 2023-03-30 Thu 21:34 --> | |||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||||
<title>Lab9 Solution Amirlan Sharipov (BS21-CS-01)</title> | |||||
<meta name="author" content="Amirlan Sharipov (BS21-CS-01)" /> | |||||
<meta name="generator" content="Org Mode" /> | |||||
<style> | |||||
#content { max-width: 60em; margin: auto; } | |||||
.title { text-align: center; | |||||
margin-bottom: .2em; } | |||||
.subtitle { text-align: center; | |||||
font-size: medium; | |||||
font-weight: bold; | |||||
margin-top:0; } | |||||
.todo { font-family: monospace; color: red; } | |||||
.done { font-family: monospace; color: green; } | |||||
.priority { font-family: monospace; color: orange; } | |||||
.tag { background-color: #eee; font-family: monospace; | |||||
padding: 2px; font-size: 80%; font-weight: normal; } | |||||
.timestamp { color: #bebebe; } | |||||
.timestamp-kwd { color: #5f9ea0; } | |||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } | |||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } | |||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; } | |||||
.underline { text-decoration: underline; } | |||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; } | |||||
p.verse { margin-left: 3%; } | |||||
pre { | |||||
border: 1px solid #e6e6e6; | |||||
border-radius: 3px; | |||||
background-color: #f2f2f2; | |||||
padding: 8pt; | |||||
font-family: monospace; | |||||
overflow: auto; | |||||
margin: 1.2em; | |||||
} | |||||
pre.src { | |||||
position: relative; | |||||
overflow: auto; | |||||
} | |||||
pre.src:before { | |||||
display: none; | |||||
position: absolute; | |||||
top: -8px; | |||||
right: 12px; | |||||
padding: 3px; | |||||
color: #555; | |||||
background-color: #f2f2f299; | |||||
} | |||||
pre.src:hover:before { display: inline; margin-top: 14px;} | |||||
/* Languages per Org manual */ | |||||
pre.src-asymptote:before { content: 'Asymptote'; } | |||||
pre.src-awk:before { content: 'Awk'; } | |||||
pre.src-authinfo::before { content: 'Authinfo'; } | |||||
pre.src-C:before { content: 'C'; } | |||||
/* pre.src-C++ doesn't work in CSS */ | |||||
pre.src-clojure:before { content: 'Clojure'; } | |||||
pre.src-css:before { content: 'CSS'; } | |||||
pre.src-D:before { content: 'D'; } | |||||
pre.src-ditaa:before { content: 'ditaa'; } | |||||
pre.src-dot:before { content: 'Graphviz'; } | |||||
pre.src-calc:before { content: 'Emacs Calc'; } | |||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } | |||||
pre.src-fortran:before { content: 'Fortran'; } | |||||
pre.src-gnuplot:before { content: 'gnuplot'; } | |||||
pre.src-haskell:before { content: 'Haskell'; } | |||||
pre.src-hledger:before { content: 'hledger'; } | |||||
pre.src-java:before { content: 'Java'; } | |||||
pre.src-js:before { content: 'Javascript'; } | |||||
pre.src-latex:before { content: 'LaTeX'; } | |||||
pre.src-ledger:before { content: 'Ledger'; } | |||||
pre.src-lisp:before { content: 'Lisp'; } | |||||
pre.src-lilypond:before { content: 'Lilypond'; } | |||||
pre.src-lua:before { content: 'Lua'; } | |||||
pre.src-matlab:before { content: 'MATLAB'; } | |||||
pre.src-mscgen:before { content: 'Mscgen'; } | |||||
pre.src-ocaml:before { content: 'Objective Caml'; } | |||||
pre.src-octave:before { content: 'Octave'; } | |||||
pre.src-org:before { content: 'Org mode'; } | |||||
pre.src-oz:before { content: 'OZ'; } | |||||
pre.src-plantuml:before { content: 'Plantuml'; } | |||||
pre.src-processing:before { content: 'Processing.js'; } | |||||
pre.src-python:before { content: 'Python'; } | |||||
pre.src-R:before { content: 'R'; } | |||||
pre.src-ruby:before { content: 'Ruby'; } | |||||
pre.src-sass:before { content: 'Sass'; } | |||||
pre.src-scheme:before { content: 'Scheme'; } | |||||
pre.src-screen:before { content: 'Gnu Screen'; } | |||||
pre.src-sed:before { content: 'Sed'; } | |||||
pre.src-sh:before { content: 'shell'; } | |||||
pre.src-sql:before { content: 'SQL'; } | |||||
pre.src-sqlite:before { content: 'SQLite'; } | |||||
/* additional languages in org.el's org-babel-load-languages alist */ | |||||
pre.src-forth:before { content: 'Forth'; } | |||||
pre.src-io:before { content: 'IO'; } | |||||
pre.src-J:before { content: 'J'; } | |||||
pre.src-makefile:before { content: 'Makefile'; } | |||||
pre.src-maxima:before { content: 'Maxima'; } | |||||
pre.src-perl:before { content: 'Perl'; } | |||||
pre.src-picolisp:before { content: 'Pico Lisp'; } | |||||
pre.src-scala:before { content: 'Scala'; } | |||||
pre.src-shell:before { content: 'Shell Script'; } | |||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } | |||||
/* additional language identifiers per "defun org-babel-execute" | |||||
in ob-*.el */ | |||||
pre.src-cpp:before { content: 'C++'; } | |||||
pre.src-abc:before { content: 'ABC'; } | |||||
pre.src-coq:before { content: 'Coq'; } | |||||
pre.src-groovy:before { content: 'Groovy'; } | |||||
/* additional language identifiers from org-babel-shell-names in | |||||
ob-shell.el: ob-shell is the only babel language using a lambda to put | |||||
the execution function name together. */ | |||||
pre.src-bash:before { content: 'bash'; } | |||||
pre.src-csh:before { content: 'csh'; } | |||||
pre.src-ash:before { content: 'ash'; } | |||||
pre.src-dash:before { content: 'dash'; } | |||||
pre.src-ksh:before { content: 'ksh'; } | |||||
pre.src-mksh:before { content: 'mksh'; } | |||||
pre.src-posh:before { content: 'posh'; } | |||||
/* Additional Emacs modes also supported by the LaTeX listings package */ | |||||
pre.src-ada:before { content: 'Ada'; } | |||||
pre.src-asm:before { content: 'Assembler'; } | |||||
pre.src-caml:before { content: 'Caml'; } | |||||
pre.src-delphi:before { content: 'Delphi'; } | |||||
pre.src-html:before { content: 'HTML'; } | |||||
pre.src-idl:before { content: 'IDL'; } | |||||
pre.src-mercury:before { content: 'Mercury'; } | |||||
pre.src-metapost:before { content: 'MetaPost'; } | |||||
pre.src-modula-2:before { content: 'Modula-2'; } | |||||
pre.src-pascal:before { content: 'Pascal'; } | |||||
pre.src-ps:before { content: 'PostScript'; } | |||||
pre.src-prolog:before { content: 'Prolog'; } | |||||
pre.src-simula:before { content: 'Simula'; } | |||||
pre.src-tcl:before { content: 'tcl'; } | |||||
pre.src-tex:before { content: 'TeX'; } | |||||
pre.src-plain-tex:before { content: 'Plain TeX'; } | |||||
pre.src-verilog:before { content: 'Verilog'; } | |||||
pre.src-vhdl:before { content: 'VHDL'; } | |||||
pre.src-xml:before { content: 'XML'; } | |||||
pre.src-nxml:before { content: 'XML'; } | |||||
/* add a generic configuration mode; LaTeX export needs an additional | |||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */ | |||||
pre.src-conf:before { content: 'Configuration File'; } | |||||
table { border-collapse:collapse; } | |||||
caption.t-above { caption-side: top; } | |||||
caption.t-bottom { caption-side: bottom; } | |||||
td, th { vertical-align:top; } | |||||
th.org-right { text-align: center; } | |||||
th.org-left { text-align: center; } | |||||
th.org-center { text-align: center; } | |||||
td.org-right { text-align: right; } | |||||
td.org-left { text-align: left; } | |||||
td.org-center { text-align: center; } | |||||
dt { font-weight: bold; } | |||||
.footpara { display: inline; } | |||||
.footdef { margin-bottom: 1em; } | |||||
.figure { padding: 1em; } | |||||
.figure p { text-align: center; } | |||||
.equation-container { | |||||
display: table; | |||||
text-align: center; | |||||
width: 100%; | |||||
} | |||||
.equation { | |||||
vertical-align: middle; | |||||
} | |||||
.equation-label { | |||||
display: table-cell; | |||||
text-align: right; | |||||
vertical-align: middle; | |||||
} | |||||
.inlinetask { | |||||
padding: 10px; | |||||
border: 2px solid gray; | |||||
margin: 10px; | |||||
background: #ffffcc; | |||||
} | |||||
#org-div-home-and-up | |||||
{ text-align: right; font-size: 70%; white-space: nowrap; } | |||||
textarea { overflow-x: auto; } | |||||
.linenr { font-size: smaller } | |||||
.code-highlighted { background-color: #ffff00; } | |||||
.org-info-js_info-navigation { border-style: none; } | |||||
#org-info-js_console-label | |||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; } | |||||
.org-info-js_search-highlight | |||||
{ background-color: #ffff00; color: #000000; font-weight: bold; } | |||||
.org-svg { } | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<div id="content" class="content"> | |||||
<h1 class="title">Lab9 Solution Amirlan Sharipov (BS21-CS-01)</h1> | |||||
<div id="table-of-contents" role="doc-toc"> | |||||
<h2>Table of Contents</h2> | |||||
<div id="text-table-of-contents" role="doc-toc"> | |||||
<ul> | |||||
<li><a href="#org21d542a">1. Question 1</a></li> | |||||
<li><a href="#org3b74767">2. Question 2</a></li> | |||||
<li><a href="#org8d3c3fc">3. Question 3</a></li> | |||||
<li><a href="#org469c55f">4. Question 4</a></li> | |||||
<li><a href="#orgdfe38ae">5. Question 5</a> | |||||
<ul> | |||||
<li><a href="#org9953654">5.1. Add gpg atom’s gpg keys</a></li> | |||||
<li><a href="#org8291486">5.2. Add atom’s repository to sources list</a></li> | |||||
<li><a href="#orgef945fa">5.3. Dowload packages information from all sources</a></li> | |||||
<li><a href="#org3bb35d0">5.4. Search for atom</a></li> | |||||
<li><a href="#org232fa14">5.5. Finally install atom</a></li> | |||||
</ul> | |||||
</li> | |||||
<li><a href="#orgb6f9c6c">6. Question 6</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org21d542a" class="outline-2"> | |||||
<h2 id="org21d542a"><span class="section-number-2">1.</span> Question 1</h2> | |||||
<div class="outline-text-2" id="text-1"> | |||||
<p> | |||||
One of the alternative is to use GPS-based ntp and sync time with the satellites. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org3b74767" class="outline-2"> | |||||
<h2 id="org3b74767"><span class="section-number-2">2.</span> Question 2</h2> | |||||
<div class="outline-text-2" id="text-2"> | |||||
<p> | |||||
Use one server as an ntp client and another as an ntp server and sync them regularly using cron. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org8d3c3fc" class="outline-2"> | |||||
<h2 id="org8d3c3fc"><span class="section-number-2">3.</span> Question 3</h2> | |||||
<div class="outline-text-2" id="text-3"> | |||||
<p> | |||||
apt is a new command-line interface aimer for interactive usage. | |||||
apt is a high-level tool to interact with tools like apt-get and apt-cache. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org469c55f" class="outline-2"> | |||||
<h2 id="org469c55f"><span class="section-number-2">4.</span> Question 4</h2> | |||||
<div class="outline-text-2" id="text-4"> | |||||
<p> | |||||
upgrade only upgrades the packages and never removes them, whereas full-upgrade may result in removal of some packages. This may cause problems for system administrators. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgdfe38ae" class="outline-2"> | |||||
<h2 id="orgdfe38ae"><span class="section-number-2">5.</span> Question 5</h2> | |||||
<div class="outline-text-2" id="text-5"> | |||||
<p> | |||||
The information is taken from <a href="https://linuxhint.com/install-atom-text-editor-ubuntu-22-04/">https://linuxhint.com/install-atom-text-editor-ubuntu-22-04/</a> | |||||
I am very skeptical about this method. Atom is deprecated. As well as apt-key. But it works | |||||
</p> | |||||
</div> | |||||
<div id="outline-container-org9953654" class="outline-3"> | |||||
<h3 id="org9953654"><span class="section-number-3">5.1.</span> Add gpg atom’s gpg keys</h3> | |||||
<div class="outline-text-3" id="text-5-1"> | |||||
<p> | |||||
wget -qO - <a href="https://packagecloud.io/AtomEditor/atom/gpgkey">https://packagecloud.io/AtomEditor/atom/gpgkey</a> | sudo apt-key add - | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org8291486" class="outline-3"> | |||||
<h3 id="org8291486"><span class="section-number-3">5.2.</span> Add atom’s repository to sources list</h3> | |||||
<div class="outline-text-3" id="text-5-2"> | |||||
<p> | |||||
sudo sh -c ’echo “deb [arch=amd64] <a href="https://packagecloud.io/AtomEditor/atom/any/">https://packagecloud.io/AtomEditor/atom/any/</a> any main” > /etc/apt/sources.list.d/atom.list’ | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgef945fa" class="outline-3"> | |||||
<h3 id="orgef945fa"><span class="section-number-3">5.3.</span> Dowload packages information from all sources</h3> | |||||
<div class="outline-text-3" id="text-5-3"> | |||||
<p> | |||||
sudo apt update | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org3bb35d0" class="outline-3"> | |||||
<h3 id="org3bb35d0"><span class="section-number-3">5.4.</span> Search for atom</h3> | |||||
<div class="outline-text-3" id="text-5-4"> | |||||
<p> | |||||
apt search atom | |||||
There was a huge output with atom in it. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-org232fa14" class="outline-3"> | |||||
<h3 id="org232fa14"><span class="section-number-3">5.5.</span> Finally install atom</h3> | |||||
<div class="outline-text-3" id="text-5-5"> | |||||
<p> | |||||
sudo apt install atom | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="outline-container-orgb6f9c6c" class="outline-2"> | |||||
<h2 id="orgb6f9c6c"><span class="section-number-2">6.</span> Question 6</h2> | |||||
<div class="outline-text-2" id="text-6"> | |||||
<div class="org-src-container"> | |||||
<pre class="src src-bash"><span style="color: #c792ea;">cat</span> control create-package.sh | |||||
</pre> | |||||
</div> | |||||
<pre class="example" id="orge68b8fa"> | |||||
Package: hellopackage | |||||
Version: 1.0 | |||||
Architecture: all | |||||
Maintainer: RinRi | |||||
Depends: python3 | |||||
Description: Hello world | |||||
#!/bin/bash | |||||
rm -rf hellopackage | |||||
mkdir -p hellopackage hellopackage/usr/local/bin hellopackage/var/helloworld | |||||
printf "%s" '#!/usr/bin/env python3\nprint("Hello, World!")' > hellopackage/var/helloworld/helloworld.py | |||||
printf "%s" '#!/bin/bash\n/var/helloworld/helloworld.py' > hellopackage/usr/local/bin/helloworld | |||||
chmod -R 0755 hellopackage/var/helloworld hellopackage/usr/local/bin/helloworld | |||||
mkdir -p hellopackage/DEBIAN | |||||
cp control hellopackage/DEBIAN/ | |||||
dpkg-deb --build --root-owner-group hellopackage | |||||
</pre> | |||||
<p> | |||||
After this just use sudo apt install ./hellopackage.deb and everything works. | |||||
</p> | |||||
<div id="orgf4ac92c" class="figure"> | |||||
<p><img src="./lab9-image-01.jpg" alt="lab9-image-01.jpg" /> | |||||
</p> | |||||
</div> | |||||
<p> | |||||
The artifacts created by the package are the same as in the image but from the root directory. | |||||
</p> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div id="postamble" class="status"> | |||||
<p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p> | |||||
<p class="date">Created: 2023-03-30 Thu 21:34</p> | |||||
</div> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,66 @@ | |||||
#+title: Lab9 Solution | |||||
#+title: Amirlan Sharipov (BS21-CS-01) | |||||
#+author: Amirlan Sharipov (BS21-CS-01) | |||||
#+PROPERTY: header-args :results verbatim :exports both | |||||
#+OPTIONS: ^:nil | |||||
* Question 1 | |||||
One of the alternative is to use GPS-based ntp and sync time with the satellites. | |||||
* Question 2 | |||||
Use one server as an ntp client and another as an ntp server and sync them regularly using cron. | |||||
* Question 3 | |||||
apt is a new command-line interface aimer for interactive usage. | |||||
apt is a high-level tool to interact with tools like apt-get and apt-cache. | |||||
* Question 4 | |||||
upgrade only upgrades the packages and never removes them, whereas full-upgrade may result in removal of some packages. This may cause problems for system administrators. | |||||
* Question 5 | |||||
The information is taken from https://linuxhint.com/install-atom-text-editor-ubuntu-22-04/ | |||||
I am very skeptical about this method. Atom is deprecated. As well as apt-key. But it works | |||||
** Add gpg atom's gpg keys | |||||
wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add - | |||||
** Add atom's repository to sources list | |||||
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list' | |||||
** Dowload packages information from all sources | |||||
sudo apt update | |||||
** Search for atom | |||||
apt search atom | |||||
There was a huge output with atom in it. | |||||
** Finally install atom | |||||
sudo apt install atom | |||||
* Question 6 | |||||
#+begin_src bash | |||||
cat control create-package.sh | |||||
#+end_src | |||||
#+RESULTS: | |||||
#+begin_example | |||||
Package: hellopackage | |||||
Version: 1.0 | |||||
Architecture: all | |||||
Maintainer: RinRi | |||||
Depends: python3 | |||||
Description: Hello world | |||||
#!/bin/bash | |||||
rm -rf hellopackage | |||||
mkdir -p hellopackage hellopackage/usr/local/bin hellopackage/var/helloworld | |||||
printf "%s" '#!/usr/bin/env python3\nprint("Hello, World!")' > hellopackage/var/helloworld/helloworld.py | |||||
printf "%s" '#!/bin/bash\n/var/helloworld/helloworld.py' > hellopackage/usr/local/bin/helloworld | |||||
chmod -R 0755 hellopackage/var/helloworld hellopackage/usr/local/bin/helloworld | |||||
mkdir -p hellopackage/DEBIAN | |||||
cp control hellopackage/DEBIAN/ | |||||
dpkg-deb --build --root-owner-group hellopackage | |||||
#+end_example | |||||
After this just use sudo apt install ./hellopackage.deb and everything works. | |||||
[[./lab9-image-01.jpg]] | |||||
The artifacts created by the package are the same as in the image but from the root directory. |