graywolf is fork of Timberwolf:

TimberWolf doc is here: http://opencircuitdesign.com/qflow/archive/TimberWolf.pdf

To install Timberwolf, we need to install couple other software:

A. CMake => CMake is a popular alternative to autotools. It is usedin many open-source projects including large ones such as KDE, LLVM and Blender. See CMake section for more details on cmake.

Steps for downloading cmake:

1. dwnload cmake from here: https://cmake.org/download/ (cmake-3.14.0-rc2.tar.gz)

2.  extract .gz file, and goto dir "cmake-3.14.0-rc1). Now run these 3 steps: 1. /bootstrap 2. make 3. sudo make install

B. GSL => GNU Scientific Library (libgsl): this is used in C pgms to call many scientific functions.

1. downlaod GSL from here: https://www.gnu.org/software/gsl/ 2.goto gnu ftp mirror link and download gsl-latest.tar.gz (currently latest is pointing to version 2.5)

2. extract .gz. cd to gsl-2.5 dir. Now run these 3 steps: 1. ./configure 2. make 3. make install

3. We should see libgsl.so and libgslcblas.so shared lib in /usr/local/lib dir. Also make sure env var "LD_LIBRARY_PATH" is set to ":/usr/loacal/lib/" (assuming gsl was installed in defau;t pat). echo $LD_LIBRARY_PATH => ://usr/local/lib/ . All header files for gsl lib will be in /usr/local/inlcude/gsl

Now, to test that gsl is installed correctly, we can write a simple C test program which include one of the GSL functions, and see if works. Write a pgm named gsl_test.c

#include <gsl/gsl_sf_bessel.h> //this header file dir is in /usr/local/include dir
int main (void) {
    double x = 15.0;
    double y = gsl_sf_bessel_J0 (x);
    printf ("J0(%g) = %.18e\n", x, y);
    return 0;
}

Run:  gcc gsl_test.c -lgsl -lgslcblas => This should create a.out, and running a.out should produce bessel output.

-----

 Once above 2 software are installed, we install Timberwolf as follows:

1. Download graywolf from here: https://github.com/rubund/graywolf.

2. Download zip file, "graywolf-master.zip". Unzip it, and you should have a dir "garywolf-master". cd to that dir, and read thru README.md. It has instructions for installing it. Run these steps:

!. cd graywolf-master

II. mkdir buid

III. cd build

IV. cmake .. => NOTE: cmake is used to build this, instead of traditional GNU Autotools

This runs CMakeLists.txt in dir graywolf-master. At this stage, you may get an error:

--   No package 'gsl' found
CMake Error at CMakeLists.txt:15 (MESSAGE):
  The development files for the GNU Scientific Library (libgsl) are required
  to build graywolf.

This happens, since pkg_check_modules is not able to find GSL package, even though it's installed in std location.

To fix this, modify CMakeLists.txt in dir graywolf-master. comment out line "pkg_check_modules(GSL gsl)" and replace it with "include(FindGSL)". This will allow cmake to find GSL pkg.

#pkg_check_modules(GSL gsl)

include(FindGSL)

Once done, cd to build dir, and run "cmake .." once again. This time it should run fine:

[graywolf-master/build]$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Ajay/Downloads/graywolf-master/build

V. make => now run make, Last few lines on screen look something like this:

[100%] Built target mc_compact
Scanning dependencies of target run
[100%] Generating show_flows
[100%] Built target run

VI. sudo make install => this will install various files of this software in /usr/local/lib and /usr/local/bin

VII. make test => This will run 6 tests, but 1 of them fails.

The following tests FAILED:
      5 - map9v3-twmc (Failed)
Errors while running CTest
make: *** [test] Error 8

VIII. CTEST_OUTPUT_ON_FAILURE=1 make test => this step is optional. running this produces more verbose o/p for test 5 to help us debug.

iX: now cd to any dir, (cd /home/) type "graywolf" on terminal, and it should run it. Add steps on running it => FIXME

 

yosys - open source synthesis tool

Yosys is oen source synthesis tool. You provide it an RTL, and it spits out optimized gate level netlist.

yosys details are on this link: http://www.clifford.at/yosys/about.html

yosys download and installation. I'll show steps for both debian based OS (as Linux Mint or Ubuntu) and Fedora based OS (as CentOS). I haven't gotten to installing Yosys on LinuxMint, so will provide instructions for it later.

A CentOS: I will show steps for yosys installation on CentOS 7.5 1804 distro.

1. download python3 => see instructions for downloading python3 on python page. Do these steps:

  •  I. First do "sudo yum install epel-release".
  •  II. Next do "sudo yum install python3.4"
  •  III. sudo curl -O https://bootstrap.pypa.io/get-pip.py
  •  IV. sudo /usr/bin/python3.4 get-pip.py

2. download tcl/tk => see instructions for downloading tcl/tk in tcl/tk page. Use manual download and install from tcl8.7a

3. download libffi => run "sudo yum install libffi libffi-devel". Run "locate libffi" This will show libffi.so lib in /usr/lib64 and docs in /usr/share/doc. ffi.h file will be in /usr/include/libffi.h

4. install readline => sudo yum install readline-devel. This creates /usr/include/readline/readline.h

5. Now download yosys from here: http://www.clifford.at/yosys/download.html. Steps below:

 A. download yosys-0.8.tar.gz. Extract it within the file windows manager using right click and choosing "extract". That will create another dir named "yosys-yosys-0.8"

 B. type "make config-gcc". This will create Makefile with gcc as the compiler. this will suffice, as gcc can compile C++ also. There is no need to install clang.

 C. type "make" => this will start compilation process using gcc (should show CONFIG := gcc from Makefile.conf). Possible Errors:

  • tcl.h not found (called in kernel/yosys.h) => tclsh not installed or found. See bullet 2 above.
  • tclsh command not found => If you see this error and tclsh is alrready installed, probably the link or path for tclsh is not correct.
  • readline/readline.h not found (called in kernel/driver.cc) => readline not installed. See bullet 4 above.
  • ffi.h not found (called in frontends/ast/dpicall.cc) => libffl not installed. See bullet 3 above.

     If no errors found, we should see 100% build for yosys, then it downloads "abc" from berkeley, does 95% build for abc binary, and then finally "Build successful" message.

7. make test => runs all tests. Needs icarus verilog or "icarus"

8. sudo make install => This is final step where it just puts binaries for yosys in /usr/local/bin/yosys. Other yosys related binaries also here.

9. Now running yosys (typing yosys or /usr/local/bin/yosys) should bring up yosys tool. However, if we get "error while loading shared libraries: libtcl8.7.so: cannot open shared object file: No such file or directory" , that means LD_LIBRARY_PATH var is not set.   If we find "libtcl8.7.so", we see it in /usr/local/lib/libtcl.8.7.so". "echo $LD_LIBRARY_PATH" shows blank. For bash shell, type "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/". Now, "echo $LD_LIBRARY_PATH" will show ":/usr/local/lib/". Type "export LD_LIBRARY_PATH". Now typing yosys brings up cmd line yosys tool. To make this change permanent, add this line in ~/.bashrc (assuming you are using bash)

  • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/

10. Install open src s/w graphviz for graphical viewing: sudo yum install graphviz => installs graphviz-2.30*

10. All yosys cmds and scripts available on yosys webpage.

 

yosys usage:

 1. Read Yosys manual which explains everything in very good detail. http://www.clifford.at/yosys/files/yosys_manual.pdf

 

Yosys example: TO DO ---

 Setting internet server:

You can host a website on any of the computers called as servers. The hosting services are provided for a yearly fee by a lot of hosting companies as godaddy.com, ipage.com, hostinger.com to name a few. If you do not want to pay anyone money, and want to use your own computer for hosting a website, it's pretty easy too.

Before hosting a website on your personal computer in your home, you will need to configure the router. Then you need to install a server software as "apache", and then get a name assigned to your website. We will talk about installing apache in this section. In next section, we'll talk about all the other steps.

Here, I'll talk about hosting a website on a laptop running Linux OS "Linux Mint 18". These steps should work on latest Ubuntu release too.

Install apache:

First, we need to install software, that will make our regular laptop dual work as a server. This software is called apache (or httpd process, d stands for daemon or process). Here's a good link explaining the steps (steps are the same on any debian based system, as Ubuntu, Linux Mint, etc):

UBUNTU: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-16-04

LINUX MINT: https://www.computerbeginnersguides.com/blog/2017/07/25/install-and-configure-apache-web-server-on-linux-mint-18-2/

First, install apache. We install apache2, since it's the latest apache.

  • sudo apt-get update => we could also use more modern cmd "apt" instead of "apt-get", i.e: "sudo apt update"
  • sudo apt-get install apache2 => could also run "sudo apt install apache2". It will ask for password, and then intsall Apache,utilities, configuration files, etc.

Once installed, run cmds as below:

which apache2 => should show /usr/sbin/apache2 as the path

Debian/Ubuntu start Apache automatically after installation, so we do not need to start apache separately. Now, goto web browser, and type "localhost" or "127.0.0.1" in the address tab. localhost resolves to the IP address 127.0.0.1, which is the most commonly used IPv4 loopback address. This address is used to establish an IP connection to the same machine or computer being used by the end-user. So, typing this makes computer look for httpd process running on same machine and fetch default website page from there.It should show "Apache2 Ubuntu Default page" with important dir info. This page is located at /var/www/html/index.html.

apache2 dir:

/usr/sbin/apache2 => apache2 is the executable. Normally running this executable directly should start the apache2 pgm, but due to use of env var, in it's default configuration, apache2 can't be started/stopped directly by running the binary. Cmds to start/stop it are discussed later.

/usr/share/doc/apache2/README.Debian.gz => apache2 documentation


/etc/apache2/ => this dir has many important configuration files

  • envvars => contains default environent variables for apache2ctl scrpt
  • apache2.conf => apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server. It includes following file:
    • ports.conf: determines listening ports for incoming connections which can be customized anytime. By default, port 80 is assigned to http, and port 443 to https (secure http).
  • Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations respectively.
    • mods_enabled => This dir contains many *.load and *.conf file for each module (i.e alias.conf and alias.load for alias module, and so on). *.load file just loads the module *.so from appr dir (i.e LoadModule dir_module /usr/lib/apache2/modules/mod_dir.so). *.conf sets config for modules, and is written in xml format.
    • conf_enabled => few more *.conf files for customizing
    • sites_enabled => There is usually just 1 file here, 000-default.conf. This is very important file, if you plan to host more than 1 virtual host on same ip address. In that case, for each virtual host, we need to specify "ServerName", "ServerAdmin", "DocumentRoot", and log file locations.
  • Configuration files that we saw above are links from dir mods-available, conf-available and sites-available. Whenever we put a soft link from *-available dir to corresponding *-enabled dir, those files get activated. For Linux Mint, these files are enabled/disabled by using  helper scripts: a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf.

 /var/log/apache2 => stores log files for all requests apache processes.

apache2 cmds:

Now, depending of which linux distro we have, we have bunch of cmds that are used to monitor/control apache server. Due to use of env var, calling binary apache2 directly to start/stop apache2 doesn't work.

This is a good link showing diff ways to do that:

https://www.cyberciti.biz/faq/ubuntu-linux-start-restart-stop-apache-web-server/

Most modern Linux OS use systemd linux cmds to check status of pgm. On earlier versions of linux, init process was started as 1st process, but RedHat introduced systemd to replace init. All derivatives of red hat, and other linux distro (latest versions) use systemd. "systemctl" cmd is used for systemd based systems. Ubuntu uses systemd starting from "Ubuntu 16.04 LTS"  but earlier version of Ubuntu still uses init.  For more details, see in "init vs systemd" link in "linux intro" section.

Init for apache2:

On Linux Mint 19, I see apache2 files getting installed in /etc/init.d. Basically installation of Apache essentially runs this cmd during some point of installation:

sudo update-rc.d apache2 defaults => This creates the appropriate symlinks in the /etc/rc*.d/ folders. Ubuntu uses scripts in the /etc/init.d/ folder to start/stop services.For apache2 script, we see that they have links starting with S in rc2.d, rc3.d,rc4.d and rc5.d, but have links starting with K in rc0.d, rc1.d and no link for rcS.d. Since runlevel for ubuntu is 2, all links in rc2.d that start with S get started, so apache2 gets started by default anytime computer boots up (since it's link starts with S).

If we want to disable apache2 on startup, we can run this cmd: sudo update-rc.d apache2 disable which removes all the "S" symlinks and replaces them with "K" symlinks

to re-enable Apache: sudo update-rc.d apache2 enable

ex: /etc/init.d/apache2 status => Here, apache2 process init script is called to check status of apache2

systemd for apache2:

We'll use "service" or "apache2ctl" cmds, as they work on all linux distro. apache2ctl is apache server ctl i/f cmd, so it ships with apache, and will work anywhere apache is installed. However, on linux mint 19, apach2ctl is not installed by default, when installing apache2, so we'll stick with service cmd. Currently, apach2ctl uses /etc/init.d/apache2 script, but in future, it may use native systemd unit file.

Find if apache2 is running: (similarly we can use start/stop to start/stop apache server. However start./stop requires root privileges, so need to use sudo before each cmd)

service apache2 status => displays "* apache2 is active (running)". shows detailed o/p on linux mint

/etc/init.d/apache2 status => same o/p as above

systemctl status apache2.service => same o/p as above, for systemd based systems

Customizing website:

We saw above that index.html file is the one fetched to display the webpage for your website. It's located at /var/www/html/index.html. It has default ubuntu info. We can move this file to a backup file (index.back.html), and start from scratch with a new index.html file, and put very simple html code in it.

 

 

Riddles/puzzles:

1. Transport problem: There is a lion, cow and heap of grass. All 3 need to be transported from 1 side of river to other side on a boat. The boatman is rowing the boat, and he can only carry 1 of the 3 at one time, otherwise the boat will drown. Lion can eat cow, while cow can eat grass. Lion doesn't eat grass. How can the boatman transport all 3 of them across the river, without any of them eating anyone else. He can make as many trips as he wants. The only problem is that as soon as the boatman disappears from the scene, the animals are free to eat their food. So, if he leaves lion and cow while carrying grass with him, lion can eat cow. Since boatman cannot carry more than 1 of them with him, he has to leave 2 of them together, but in such a combination that no one can eat the other.

Soln: carry cow in 1st trip and leave it on other side of river. Then come back empty and carry lion with him. Then leave lion on other side, but bring back cow with him, else lion will eat cow. On his third trip, leave cow on the bank of river, and carry grass with him, and leave it on other side. Then come back empty, and carry cow with him to other side. Then all 3 animals end up on other side.

2. Switch problem: You have seen light switches in house. Sometimes we see the same light bulb being controlled by 2 switches. i.e light in the bedroom being controlled by the switch at entrance of bedroom, while also being controlled by switch by the side of bed. Draw a connection diagram showing how it works. We will need 3 way switch for these, not the regular 2 way switch. Also, how can you control the light bulb with "n" switches. We will need 4 way switches to make this work.

3. Bulb Problem: 3 incandescent bulbs in a closed room, 3 switches outside the room. All switches are in off state to start with, so all light bulbs are off. How can you figure out which light bulb is controlled by which switch. You are allowed to turn switches on/off as many times as you want, but once you enter the room, you are not allowed to go outside the room and flip switches again.

4. monty hall problem: Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice? 

5. Hardest Logic puzzle: Logic puzzles are yes/no questions to derive an answer. Link to Hardest Logic Puzzle => https://en.wikipedia.org/wiki/The_Hardest_Logic_Puzzle_Ever

  • A simpler version of this puzzle for kids is as follows (the answer is in link above) => You are standing before two doors. One of the path leads to heaven and the other one leads to hell. There are two guardians, one by each door. You know one of them always tells the truth and the other always lies, but you don’t know who is the honest one and who is the liar. You can only ask one question to one of them in order to find the way to heaven. What is the question?

 


 

Kids Maths:

1. If there are 4 apples and you take away 3, how many do you have? => 3, because you took 3

2. What occurs twice in a week, once in a year but never in a day? => letter e

3. What goes up and doesn’t come back down?

4. What has two hands but no legs? => clock

5. What’s the easiest way to double your money? => in front of mirror

6. Which month has 28 days? => all of them

7. If four men can build four tables in four hours, how many tables can eight men build in eight hours? =>

8. Three guys rent a hotel room for the night. When they get to the hotel they pay the $30 fee, then go up to their room. Soon the bellhop brings up their bags and gives the lawyers back $5 because the hotel was having a special discount that weekend. So the three lawyers decide to each keep one of the $5 dollars and to give the bellhop a $2 tip. However, when they sat down to tally up their expenses for the weekend the could not explain the following details:
Each one of them had originally paid $10 (towards the initial $30), then each got back $1 which meant that they each paid $9. Then they gave the bellhop a $2 tip. HOWEVER, 3 • $9 + $2 = $29
The guys couldn't figure out what happened to the other dollar. After all, the three paid out $30 but could only account for $29. Can you determine what happened?


9. What digit is the most frequent between the numbers 1 and 1,000 (inclusive)? To solve this riddle you don't want to manually do all of the math but rather try to figure out a pattern.

10. How can you add eight 8's to get the number 1,000? (only use addition) => 888+88+8+8+8

11. Jammy is a milkman. He has 3-liter and 5-liter milk cans. Now, he want to measure 4 liters from these milk cans. How can he do it? =>

 


 

 

 

Linux Directory structure:

tldp website is very good resource for learning Linux. This pdf is very detailed about Linux dir:

https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/Linux-Filesystem-Hierarchy.pdf

Below info is copied from here: https://www.howtogeek.com/117435/htg-explains-the-linux-directory-structure-explained/

/ => Everything on your Linux system is located under the / directory, known as the root directory.

Under root dir, we have these other subdir:

  • /bin => The /bin directory contains the essential user binaries (programs) that must be present when the system is mounted in single-user mode. Applications such as Firefox are stored in /usr/bin, while important system programs and utilities such as the bash shell are located in /bin. The /usr directory may be stored on another partition – placing these files in the /bin directory ensures the system will have these important utilities even if no other file systems are mounted. The /sbin directory is similar – it contains essential system administration binaries.
  • /sbin => The /sbin directory is similar to the /bin directory. It contains essential binaries that are generally intended to be run by the root user for system administration.
  • /lib => The /lib directory contains libraries needed by the essential binaries in the /bin and /sbin folder. Libraries needed by the binaries in the /usr/bin folder are located in /usr/lib.
  • /lib64 => The /lib64 contains 64 bit lib.

In CentOS, /bin, /sbin, /lib and /lib64 are all soft links to corresponding dir in /usr dir. So, all these dir are actually in /usr dir. eg. bin -> usr/bin (so when we do /bin, it's actually /usr/bin)

Modules: /lib/modules/<kernel-version>/ dir has all compiled drivers (aka kernel modules). Inside it is kernel/drivers/ subdir which has modules for wireless device, bluetooth device, usb device, etc.

lsmod => list all loaded modules

modinfo <module_name> => This gives detailed info about any of the modules that you got from lsmod.

i.e modinfo video => shows location of compiled kernel module (in /lib/modules/.../*.ko), and other info.

modprobe => useful cmd for loading or unloading modules

Linux directories;

  • /boot => The /boot directory contains the files needed to boot the system – for example, the GRUB boot loader’s files (in grub2 dir) and your Linux kernels (file vmliinuz*) are stored here. The boot loader’s configuration files aren’t located here, though – they’re in /etc with the other configuration files. They generate grub.cfg file in grub2 dir as explained in section below. /boot dir has very few files: inintramfs*, vmlinuz*, grub2 dir. initramfs* is the initial RAM file system. It is the 1st root file system that the m/c has access to. It is used for mounting the real rootfs which has all your data. This is introduced from Linux 2.6 kernel series, and serves same purpose as initrd.
  • /usr => The /usr directory contains applications and files used by users, as opposed to applications and files used by the system. For example, non-essential applications are located inside the /usr/bin directory instead of the /bin directory and non-essential system administration binaries are located in the /usr/sbin directory instead of the /sbin directory. Libraries for each are located inside the /usr/lib directory. The /usr directory also contains other directories – for example, architecture-independent files like graphics are located in /usr/share.
    • The /usr/local directory is where locally compiled applications install to by default – this prevents them from mucking up the rest of the system.
    • The /usr/src/ dir has src code for linux kernels inside "kernels" subdir. /usr/src/kernels/ has further subdir with Linux kernel version number (i.e: 3.10....x86-64). All linux src files along with Makefile are inside that dir.
  • /var => variable data dir. The /var directory is the writable counterpart to the /usr directory (/usr dir is read-only in normal operation). Log files and everything else that would normally be written to /usr during normal operation are written to the /var directory. For example, you’ll find log files in /var/log
  • /home => The /home directory contains a home folder for each user. For example, if your user name is bob, you have a home folder located at /home/bob. This home folder contains the user’s data files and user-specific configuration files. Each user only has write access to their own home folder and must obtain elevated permissions (become the root user) to modify other files on the system. ~ refers to the home dir of currently logged in user. So, if alex is logged in, then ~ refers to /home/alex. Each ~ dir conatins hidden files starting with ".", such as .bashrc, .emacs, etc. These files are configuration files that determine the look, feel or startup behaviour of bash, emacs or any other application for that user.
  • /etc => The /etc directory contains configuration files, which can generally be edited by hand in a text editor. Note that the /etc/ directory contains system-wide configuration files (/etc/bashrc, /etc/profile) – user-specific configuration files are located in each user’s home directory (eg: /home/bob/.bashrc).
  • /root => The /root directory is the home directory of the root user. Instead of being located at /home/root, it’s located at /root. This is distinct from /, which is the system root directory.
  • /dev => Linux exposes devices as files, and the /dev directory contains a number of special files that represent devices. These are not actual files as we know them, but they appear as files – for example, /dev/sda represents the first SATA drive in the system. If you wanted to partition it, you could start a partition editor and tell it to edit /dev/sda.
  • This directory also contains pseudo-devices, which are virtual devices that don’t actually correspond to hardware. For example, /dev/random produces random numbers. /dev/null is a special device that produces no output and automatically discards all input – when you pipe the output of a command to /dev/null, you discard it.
  • /proc => The /proc directory similar to the /dev directory because it doesn’t contain standard files. It contains special files that represent system and process information.
  • /media => The /media directory contains subdirectories where removable media devices inserted into the computer are mounted. For example, when you insert a CD into your Linux system, a directory will automatically be created inside the /media directory. You can access the contents of the CD inside this directory.
  • /mnt => Historically speaking, the /mnt directory is where system administrators mounted temporary file systems while using them. For example, if you’re mounting a Windows partition to perform some file recovery operations, you might mount it at /mnt/windows. However, you can mount other file systems anywhere on the system.
  • /tmp => Applications store temporary files in the /tmp directory. These files are generally deleted whenever your system is restarted and may be deleted at any time by utilities such as tmpwatch.
  • /opt => The /opt directory contains subdirectories for optional software packages. It’s commonly used by proprietary software that doesn’t obey the standard file system hierarchy – for example, a proprietary program might dump its files in /opt/application when you install it.
  • /lost+found => Each Linux file system has a lost+found directory. If the file system crashes, a file system check will be performed at next boot. Any corrupted files found will be placed in the lost+found directory, so you can attempt to recover as much data as possible.

 

Dir Permissions:

Every file on linux has permissions defined for 3 different owners - user, group and all others. User is the one who created the file, group is the group of the user to which he belongs, and others refers to all the other users. Each of these 3 owners have read, write and execute (rwx) permissions specified. You will see the user name and group name, as well as rwx permissions of each file when we run cmd:

ls -al file1

-rw-r--r-x. 1 user1 grp1 0 Feb 26 07:08 file1 => user "user1" in group "grp1". permissions are rw for user1, r for grp1 and rx for others.

groups are assigned based on 1st process that runs as login shell (it's run by login pgm in /bin/login). This login pgm runs as root, and calls a C function called initgroups to set up your groups (by reading /etc/group). Each line in /etc/group file has group_name:password:group_id(GID):Group_list(all users who are members of this group). ex: root:x:0: ...  grp1:x:1000:user1. NOTE: root has User id (UID) of 0, group id (GID) of 0. You will see a lot of other groups besides root, and username groups. Those groups are used by system processes. Once your groups are set, any processes run by you inherit those groups.

GRUB:

In linux mint,

/etc/default/grub => has GRUB bootloader related settings. HEre we can choose which OS to boot into by default, how many seconds the boot screen remains up, etc.

/boot/grub/grub.cfg => This is the final file that is automatically generated when grub-mkconfig is run. It uses templates from /etc/grub.d and settings from /etc/default/grub

To change default OS in grub:

1. In Linux mint, open a terminal and login as root. This can be done by typing " su -" to become root user.

2. Change value of GRUB_DEFAULT from 0 to 2 (or whatever number windows loaded is listed at, numbers start from 0 for 1st entry, and so on) in /etc/default/grub.

3. Now run "update-grub". This will update file /boot/grub/grub.cfg. Now, restart your computer and asterisk will appear infront of "windows" in the boot menu, indicating that's the default OS.