Skip to content

Instantly share code, notes, and snippets.

2020-07-08 16:58:48 +mohan43u-we good evening to all
2020-07-08 16:58:58 +mohan43u-we welcome to day 3 of 'sh' Posix Shell session
2020-07-08 16:59:27 +mohan43u-we before we begin, if you are using 'webchat.freenode.net' you can hide join/part messages
2020-07-08 16:59:41 +mohan43u-we the instruction is provided in the 'training.ilugc.in' page
2020-07-08 16:59:58 +mohan43u-we also we have a new practice server. IP address got changed
2020-07-08 17:00:17 +mohan43u-we so make sure you login to the correct server to practice
2020-07-08 17:00:29 +mohan43u-we without further delay, lets start
2020-07-08 17:01:18 +mohan43u-we yesterday we learnt about man command, manual pages and howto execute more than one command with ';', '&&' and '||'combination
2020-07-08 17:01:28 +mohan43u-we today, we will start with redirection
2020-07-08 17:02:02 +mohan43u-we as I explained earlier, a command have "--options", "[args]' arguments, as well as it give returncode when it exits
2020-07-09 16:58:39 +mohan43u-we #ilugc channel is now in restricted mode
2020-07-09 16:59:51 +mohan43u-we type '/msg mohan43u-we message' if you want to say something important
2020-07-09 17:00:46 +mohan43u-we good evening to all
2020-07-09 17:01:06 +mohan43u-we welcome to Day 4 of sh Posix shell session
2020-07-09 17:01:46 +mohan43u-we we will continue from where we left yesterday
2020-07-09 17:02:09 +mohan43u-we just a rewind, yesterday we looked into redirection, pipes, normal and environment variables
2020-07-09 17:03:10 +mohan43u-we our next topic is control structures, like 'if' elif etc.,
2020-07-09 17:04:08 +mohan43u-we before going into the topic, just want to let you guys how to disable that joined/left messages in the irc chat
2020-07-09 17:05:00 +mohan43u-we if you are joining #ilugc through webchat.freenode.net, follow https://pasteboard.co/JgGXsrf.gif this link to disable join/part messages
2020-07-09 17:05:09 +mohan43u-we now, coming to the topic
2020-07-10 17:00:20 +mohan43u-we good evening all
2020-07-10 17:00:37 +mohan43u-we welcome to Day 5 of 'sh' Posix shell Session
2020-07-10 17:01:17 +mohan43u-we I hope all of you who joined #ilugc through webchat followed https://pasteboard.co/JgGXsrf.gif link to disable join/part messages
2020-07-10 17:02:10 +mohan43u-we yesterday we saw variables, if-elif, case, for, while control structures
2020-07-10 17:02:42 +mohan43u-we also we saw how variable get expanded by shell before executing command, different types of variable expansion
2020-07-10 17:02:55 +mohan43u-we we also saw arithmetic expansion, command substitution
2020-07-10 17:03:23 +mohan43u-we we also looked into special built-in variables shell provides like $$, $!, $? etc.,
2020-07-10 17:04:10 +mohan43u-we today, we will look into functions, positional parameters
2020-07-10 17:04:15 +mohan43u-we let see function
2020-07-10 17:04:46 +mohan43u-we a function in shell is nothing but another built-in command which you write, instead of shell providing

unback

gzip -dc boot/berryboot.img | sudo cpio -iuvdm -D berryboot

repack

(C="${PWD}"; cd berryboot; sudo find . | sudo cpio -ov --format=newc | gzip -9 >"${C}"/berryboot.img)
@mohan43u
mohan43u / spmc.c
Last active November 23, 2020 15:23
example of single producer multiple consumer in C
/* compile: gcc -pthread -o spmc spmc.c */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <signal.h>
@mohan43u
mohan43u / mkdirp.c
Created December 13, 2020 11:44
simple mkdir -p implementation in C
+static void mkdirpath(const char *path, mode_t mode) {
+ char *d = NULL;
+ char *i = NULL;
+
+ if(path == NULL) return;
+ d = strdup(path);
+ i = d;
+ while(i != NULL) {
+ if( *i == '/') i++;
+ i = strchr(i, '/');
@mohan43u
mohan43u / gist:7e4cc06226f90225aded5910496498e9
Created June 12, 2021 13:51
systemd-networkd-june-ilugc-meet.chatlog
2021-06-12 15:06:43 mohan43u-we systemd-networkd is part of systemd framework
2021-06-12 15:07:01 mohan43u-we systemd is the init system in modern linux
2021-06-12 15:07:30 mohan43u-we apart from init functionality, systemd is capable of doing lot of other things in order to make a linux os usable
2021-06-12 15:07:46 mohan43u-we one of that functionality is to configure network interface
2021-06-12 15:08:16 mohan43u-we you can configure a network interface through many ways
2021-06-12 15:08:55 mohan43u-we as you see in the presenter terminal (in https://meet.ilugc.in), the command 'ip link' will show all the currently available network interfaces
2021-06-12 15:09:16 mohan43u-we there are physical interfaces as well as virtual network interfaces
2021-06-12 15:09:37 mohan43u-we you can configure a network interface either static or dynamic
2021-06-12 15:10:29 mohan43u-we as you see in the presenter terminal, I'm currently showing details about one physical network interface called eth0
2021-06-12 15:10:49 mohan
@mohan43u
mohan43u / ta-remington.mim
Last active June 28, 2021 12:24
Remington typewriter layout (save it under /usr/share/m17n and restart your computer)
;; ta-remington.mim -- Tamil input method for Remington typewriter layout
;; Copyright (c) 2021 Mohan R, Kaniyam Foundation <https://kaniyam.com>. All Rights Reserved.
;; This file is part of the m17n contrib; a sub-part of the m17n
;; library.
;; The m17n library 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.
FROM alpine
RUN echo -e '#!/bin/sh\n\
apk update\n\
apk upgrade\n\
apk add python3\n\
mkdir -p /var/www/helloworld\n\
echo "<html><head><title>Hello World</title><body><h3>Hello World</h3></body></html>" >/var/www/helloworld/index.html' >/tmp/script &&\
chmod 755 /tmp/script &&\
/tmp/script
2021-07-10 15:05:22 mohan43u-we hi all
2021-07-10 15:05:39 mohan43u-we welcome to ILUGC july month meet for the year 2021
2021-07-10 15:06:06 mohan43u-we Im mohan
2021-07-10 15:06:24 mohan43u-we the first talk is about rootless containers
2021-07-10 15:06:41 mohan43u-we lets first talk about containers
2021-07-10 15:07:07 mohan43u-we to learn containers, we need to first learn about an old command called chroot
2021-07-10 15:07:52 mohan43u-we if you read 'man chroot' you will learn how it changes the root directory of a process
2021-07-10 15:08:14 mohan43u-we every process have a root file system view (the word view is important)
2021-07-10 15:08:56 mohan43u-we normally in unix, every process see root as same
2021-07-10 15:09:41 mohan43u-we I hope everyone joined to this meet can see my terminal either through https://meet.ilugc.in or trough jitsi