If you do not have linux, you can read How to Create a VM.
If you are using git for the first time on your machine, you should set your name and email for commits.
git config --global user.name "Your Name"
git config --global user.email youremail@example.comAlso it is required to have gcc installed to complete this lab. On Ubuntu/Debian distros you can do this by installing build-essential using apt:
sudo apt update && sudo apt install -y build-essentialIf you use VSCode and Virtual Machine (VM) it's better to launch it on host and connect to vscode server, using code tunnel command. More info
Copy and Paste in Linux Terminal is performed using [Ctrl + Shift + C] & [Ctrl + Shift + V]
You can navigate using:
cdto change directorieslsto show files in current folderpwdto show current folder path
Create repo folder and init the git:
Copy & paste in the terminal. Also you might want to create separate folder for repos, before you create the repo.
mkdir OSLabs
cd OSLabs
git initCopy & paste in the terminal (Ctrl + Shift + V)
echo "mkdir week01
cd week01 >> week01/ex1.sh
ls /usr/bin | grep gcc | sort -r | head -n 5 > ex1.txt" > week01/ex1.sh
cd week01 || true
chmod +x ex1.sh
.ex1.shNext exercise depends on creativity. You need to do this on your own. I have followed this tutorial and played with the commands.
To hide/backup your previous bash history, you can type:
cd ~
cp .bash_history history_backup
history -cwAfter playing with commands, you should put them to ex2.txt (you need to navigate to folder week01 using cd before you do so):
history > ex2.txt
cat ex2.txt | cut -c 8- > ex2.shAnd don't forget to return your history back!
cd ~
rm .bash_history
mv history_backup .bash_history
history -rNavigate to week01 folder using cd, and create ex3.sh file.
nano ex3.sh && chmod +x ex3.shPaste the following code [Ctrl + Shift + V]
#!/bin/bash
mkdir -p root
date & sleep 3
ls -latr / > root/root.txt
date & sleep 3
mkdir -p home
date & sleep 3
ls -latr "/home/${USER}" > home/home.txtThen exit nano ([Ctrl + X] -> [Y] -> [Enter]) and run the script:
bash ex3.sh
You can remove files from folders using this script:
mv root/root.txt root.txt
mv home/home.txt home.txt
rm -rf root
rm -rf homeNavigate to the week01 and paste this code [Ctrl + Shift + V]
echo "#include<stdio.h>
int main()
{
printf(”Hello World!”);
}" > main.c
gcc main.c -O3 -o ex4
chmod +x ex4Now you can execute your freshly compiled ex4 executable:
./ex4After writing sown all the exercises, you can stage and commit your files to a local repository:
git add .
git commit -m "Lab1"You can use gh tool to publish your repo to GitHub.
Install gh on Ubuntu/Debian:
sudo apt update && sudo apt install -y ghLogin to GitHub:
gh auth loginPublish to a private repo:
gh repo create