You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 11 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #+title: Lab 1
  2. #+title: Amirlan Sharipov (BS21-CS-01)
  3. #+author: Amirlan Sharipov (BS21-CS-01)
  4. #+PROPERTY: header-args :results verbatim :exports both
  5. #+OPTIONS: ^:nil
  6. * About this document
  7. I use Org mode in Emacs to write documents and will use it throughout the course.
  8. It has a super useful feature: it can evaluate the code on the fly and save results in the buffer.
  9. Also it's easy to use latex inside Org mode. That's why I will use Org mode for this course.
  10. If there are any problems with that, please report in the comments in Moodle.
  11. * Exercise 1
  12. Code:
  13. #+begin_src bash
  14. lsb_release -a
  15. #+end_src
  16. #+RESULTS:
  17. : -e LSB Version: n/a
  18. : -e Distributor ID: Arch
  19. : -e Description: Arch Linux
  20. : -e Release: rolling
  21. : -e Codename: n/a
  22. Code:
  23. #+begin_src bash
  24. whoami
  25. #+end_src
  26. #+RESULTS:
  27. : rinri
  28. Code:
  29. #+begin_src bash
  30. users
  31. #+end_src
  32. #+RESULTS:
  33. : rinri
  34. Code:
  35. #+begin_src bash
  36. pwd
  37. #+end_src
  38. #+RESULTS:
  39. : /home/rinri/edu/sna
  40. Code:
  41. #+begin_src bash
  42. ls -la
  43. #+end_src
  44. #+RESULTS:
  45. : total 224
  46. : drwxr-xr-x 2 rinri users 4096 Feb 2 15:47 .
  47. : drwxr-xr-x 25 rinri users 4096 Feb 2 14:13 ..
  48. : -rw-r--r-- 1 rinri users 19950 Feb 2 15:50 lab1.html
  49. : -rw-r--r-- 1 rinri users 6407 Feb 2 15:51 lab1.org
  50. : -rw-r--r-- 1 rinri users 190030 Feb 2 15:45 lab1.pdf
  51. Code:
  52. #+begin_src bash
  53. cd ~/library
  54. ls -la
  55. #+end_src
  56. #+RESULTS:
  57. #+begin_example
  58. total 17260
  59. drwxr-xr-x 2 rinri users 4096 Jan 8 10:47 .
  60. drwx--x---+ 74 rinri users 4096 Feb 2 16:07 ..
  61. -rw-r--r-- 1 rinri users 6556637 Jan 8 10:47 Andrew S. Tanenbaum - Modern Operating Systems.pdf
  62. lrwxrwxrwx 1 rinri users 38 Aug 3 2022 cormen-algos.pdf -> /home/rinri/data/docs/cormen-algos.pdf
  63. 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
  64. -rw-r--r-- 1 rinri users 213363 Jan 8 10:47 ipfs-p2p-file-system.pdf
  65. -rwxr-xr-x 1 rinri users 66 Aug 3 2022 library.sh
  66. -rw-r--r-- 1 rinri users 2658531 Jan 8 10:47 Stroustrup B. - A Tour of C++ - Second Edition - 2018.pdf
  67. -rw-r--r-- 1 rinri users 8220353 Jan 8 10:47 TRENCH_FREE_DIFFEQ_I.PDF
  68. #+end_example
  69. Code:
  70. #+begin_src bash
  71. cat /etc/shells
  72. #+end_src
  73. #+RESULTS:
  74. : # Pathnames of valid login shells.
  75. : # See shells(5) for details.
  76. :
  77. : /bin/sh
  78. : /bin/bash
  79. : /bin/zsh
  80. : /usr/bin/zsh
  81. : /usr/bin/git-shell
  82. : /bin/dash
  83. Code:
  84. #+begin_src bash
  85. echo "$SHELL"
  86. #+end_src
  87. #+RESULTS:
  88. : /bin/zsh
  89. * Questions
  90. ** Using hostname command:
  91. Code:
  92. #+begin_src bash
  93. hostname
  94. #+end_src
  95. #+RESULTS:
  96. : akemi
  97. ** Arch Linux.
  98. 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.
  99. ** The root directory is "/"
  100. ** /bin/bash vs /bin/sh
  101. /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)
  102. Code:
  103. #+begin_src bash
  104. ls -l /bin/sh
  105. #+end_src
  106. #+RESULTS:
  107. : lrwxrwxrwx 1 root root 4 Jul 3 2022 /bin/sh -> dash
  108. ** Bash manual
  109. 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.
  110. b. --help - shows help message
  111. c. --rcfile file - use "file" as a initialization file instead of ~/.bashrc
  112. ** Linux distributions I want to try
  113. *** NixOS
  114. NixOS uses a unique package manager called nix that solves many problems of common package managers (e.g. apt), including dependency hell.
  115. Apart from the package manager, NixOS has single configuration file for the entire system.
  116. 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.
  117. *** Gentoo Linux
  118. Gentoo Linux also uses a unique package manager called Portage.
  119. To install software on Gentoo, Portage builds most of the packages from source and allows user to optimize the software for their own needs.
  120. 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.
  121. *** Artix Linux
  122. Artix Linux is essentially Arch Linux, but it gives several options for the init system, including OpenRC, runit, s6, and others.
  123. *** LFS
  124. LFS allows a user to build their own Linux distribution. I think it allows a user to learn many things about Linux.
  125. *** Alpine Linux
  126. 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.
  127. ** POSIX
  128. POSIX is a family of standards created to maintain compatibility between operating systems.
  129. For example, POSIX-compliant shell I mentioned earlier, is a shell that does things as mentioned in the POSIX standard for shells.
  130. If a script is POSIX-compliant, any POSIX-compliant shell can run it without issues and the script usually starts with #!/bin/sh
  131. Some of the information is taken from Wikipedia.
  132. ** Advantages of POSIX standards
  133. If a program is written with POSIX in mind, then it should work on other POSIX OSes too. Thus the portability increases.
  134. Since POSIX standards are public, everyone can create programs that can work and communicate with other POSIX-compliant programs.
  135. ** Slackware vs Debian
  136. Both distributions are old (29 years old), but both are still maintained.
  137. Slackware tries to be stable and simple, thus makes as few changes to the software as possible. It uses pkgtool package management system.
  138. There are not that many packages available in Slackware, but users can use third-party repositories to install software or update the system.
  139. Slackware has a small team of developers, whereas Debian is an popular distribution, that has many maintainers.
  140. 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.
  141. Debian uses apt (with dpkg) package management system. There are many Linux distributions based on Debian, e.g. Ubuntu, MX linux, etc.
  142. ** uname -a
  143. Code:
  144. #+begin_src bash
  145. uname -a
  146. #+end_src
  147. #+RESULTS:
  148. : Linux akemi 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 x86_64 GNU/Linux
  149. 1. Kernel name:
  150. Linux
  151. 2. Hostname:
  152. akemi
  153. 3. Kernel release version and kernel version:
  154. 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000
  155. 4. Hardware platform name:
  156. x86_64
  157. 5. Operating system name:
  158. GNU/Linux