Lecture 1
Operating System Architecture. Linux
Lecture
Workshop
Outline
- Installing and using Linux Ubuntu in VirtualBox
- Installing Git Bash (for Windows users)
- Learning main Bash commands
- Using Git
Practice
Before start
- Windows users need to download and install Git.
- Make sure that VirtualBox with Linux Ubuntu VM is installed and running.
- See reference on Git is available here.
Connecting to the running VM
- Run terminal in your host operating system (Git Bash for Windows).
- Execute the following command:
ssh acos@localhost -p2022
- Use the password
acos2020
.
Linux utility programs and Bash
Unix-based systems (such as Linux and MacOS) provide utility programs to perform various systems tasks. These utilities are via command-line interface. Bash is command-line processor and language used to execute these command. Bash is supported in Linux and MacOS. In Windows, apratial support is implemented in Git Bash. Also, come of the commands are implemented in Terminal of JetBrains IDEs (PyCharm, IntelliJ IDEA, CLion, etc.).
Main Bash commands
man
- prints documentation on other commandspwd
- prints current working directoryls
- prints directory contentscd
- changes current directorymkdir
- creates a new directoryfile
- determines file typeecho
- prints messages to the standard outputcp
- copies files and foldersmv
- renames or moves files or foldersrm
- deletes files or folderssu
- run a command with substitute user (e.g. root)exit
- causes Bash to exituname
- print system informationwhich
- locate a command
Installing additional programs in Linux Ubuntu
acos@acos-vm:~$ su
root@acos-vm:/home/acos# apt install mc
root@acos-vm:/home/acos# exit
Creating, editing and viewing source code:
cat
- concatnates and prints text fileshead
- outputs the first part of filestail
- outputs the last part of filesnano
- simple console code editormcedit
- mcedit simple editor from Midnight Commandervim
- Vi IMproved, a programmer’s text editor
Compiling and running programs in C
-
Use the following commands (work in MacOS too).
Compiling:
gcc hello.c -o hello
Running:
./hello
Using Git and GitHub
- Create a public repository at GitHub. Create an account if you do already have it.
- Clone the created repository:
git clone https://github.com/andrewt0301/test.git
- The repository will be cloned in the
test
folder. Change the current directory to it:cd test
- See help of using Git:
git help
- Set your user name and email for this repository:
git config user.name Andrei Tatarnikov git config user.email andrewt0301@gmail.com
-
Create or copy the
hello.c
program to this folder. - Check the status of files in the Git repository:
git status
- Add the
hello.c
file to the commit:git add hello.c
- Send the commit to the repository:
git commit -s -m "hello.c is added"
- Update the remote repository (GitHub):
git push origin main
- Get changes from the remote repository (GitHub):
git pull
Homework
TODO
References
- Bash (Wikipedia)
- Linux man pages online
- [PGLC] Mark G. Sobell, Matthew Helmke. Practical Guide to Linux Commands, Editors, and Shell Programming. 4th Edition. 2018.