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.

 

 

 

    History:

First generation (1945-55): These computers were made of vacuum tubes and had plugboards. Machine language was directly wired using plugboards.

Second generation (1955-65): These computers were made of transistors. Program could be written on paper (in fortran or assembler), and jobs were submitted in batch. There were compiler and rudimentary Operating system (OS). OS is layer of Software (SW) whose job is to manage all the devices in a computer system (processor, memory, disk, keyboard, I/O devices, etc) and provide user programs with a simpler interface to hardware.

Third generation (1965-80): These computers were made of ICs. IBM developed the 360 series which used common OS/360 SW. These computers introduced Multiprogramming where multiple jobs could run at the same time. Timesharing was also introduced where multiple users could login. MULTICS system was developed at Bell Labs whose SW was written in PL/I. It wasn't a success as the compiler for PL/I was buggy.

One of the scientists at Bell Labs, Ken thompson, found a small PDP-7 computer and sat down to write stripped down, one user version of MULTICS, which subsequently developed into UNIX OS. 2 major versions of unix developed: System V from AT&T and BSD from UCAL, Berkeley. However, these were not free. S. Tanenbaum wrote a clone of unix, called minix, which was free, but was just for educational purposes. Desire for free production version of minix led a finnish student, Linus Tarvolds, to write Linux.

Fourth generation (1980-present): Personal computers came into existence. In 1974, Intel came out with 8080, the first general purpose 8 bit CPU. Gary Kildall from Intel, wrote a disk based OS called CP/M and formed a company Digital Research to further develop CP/M. It dominated the world of microcomputing for next 5 yrs.

In early 1980, IBM designed IBM PC and looked around for software to run on it. Kildall refused to provide his OS. Bill Gates bought DOS (disk OS) from a seattle company and sold IBM a DOS/BASIC package, since he was already licensing his Basic interpreter to IBM. IBM wanted some modifications, so Gates hired Tim Paterson, who wrote DOS, to do it. Revised system was named MS-DOS and came to dominate the IBM-PC market as Gates started selling MS-DOS to computer companies for bundling with their hardware.

MS-DOS was widely used on 80286, 80386 and 80486. However, all these early OS were based on users typing in commands from keyboard. However, all this changed Englebart invented GUI which was adopted by XEROX. One day, Steve Jobs of Apple computer visited PARC and saw this. He saw it's potential value and built Apple Macintosh based on GUI, which was a huge success.

When Microsoft decided to build a successor to MS-DOS, it also built a GUI based system called Windows, which originally ran on top of MS-DOS (it was more like a shell than a true OS). For about 10 yrs from 1985-1995, Windows was just a graphical environment on top of MS-DOS. For about 10 yrs from 1985-1995, Windows was just a graphical environment on top of MS-DOS. However, starting in 1995, a free standing version of Windows, Windows 95, was released that incorporated many new OS features, using underlying MS-DOS system only for booting and running old MS-DOS programs. In 1998, a slightly modified version called Windows 98 was released. However, both of these contained a large amount of 16 bit Intel Assembly language. So, a full 32 bit OS was written from scratch and was called Windows NT (New Technology), designed by David Cutler. Version 4 of Windows NT called Windows NT 4.0 became poular. Version 5 of Windows NT was renamed Windows 2000 in early 1999.

Powering up of PC:

When the system is first powered up, Reset signal is asserted until the power supply output voltages have stabilized. The values of various registers are forced on reset. Since CR0 contains 0x00000010h, processor starts in Real Mode, is not aware of FPU and paging is disabled. DS, ES, FS, GS, SS, ESP, IDTR, CR2 and CR3 contain 0. CS contains F000h and EIP contains 0000FFF0h.

Booting process: Good link is here .

Linux: It's freely distributed implementaion of unix like kernel. Linux is just a kernel, not an operating system (OS). Unix was an OS developed at Bell Labs. Many UNIX like OS were developed (like Solaris, FreeBSD, Linux, etc) which conformed to IEEE POSIX specs. Linux took inspiration from UNIX, but didn't include any proprietery code from Bell Labs.

Brief history of Linux: Richard Stallman started Free Software Foundation (FSF) in 1985 to help develop GNU (GNU is not Unix) OS. It had a goal to develop an Open Source OS which could be installed on any computer hardware. A Unix-like operating system is very complex and includes a kernel, compilers, editors, text formatters, mail software, graphical interfaces, libraries, games and many other things. By 1990, almost all the components of GNU OS were written except the kernel.The kernel portion of GNU kept on getting delayed. Frustrated by the absence of a free open source OS, Linus Tarvolds, a young undergrad student developed a free open source kernel called Linux. This kernel could be used with other applications to create a full blown OS. GNU endorsed it and called it "GNU/Linux OS" which would have the Linux kernel and all GNU packages. They allowed anyone to download this GNU Linux system, and make their own GNU/Linux distribution by adding/removing/customizing stuff, as long as they followed guidelines put in place by GNU.

This should be your first link to find anything about GNU/Linux system => www.gnu.org

Very good doc for Linux is on tldp.org website: Good intro for novice: https://www.tldp.org/LDP/sag/html/index.html

To make GNU/Linux system, we need to install other software programs on it along with the kernel (Unix systems already came bundled together, so that end users didn't have to do the work). We can compile the Linux kernel, then install programs/utilies on it and make a system, however it's very cumbersome. Companies and people have put together "distributions" which contain not only kernel, but also many other programming tools and utilities (mostly GNU utilities). Most of Linux distro now come with X-window system, which is GUI instead of CLI. Terms Linux and Unix are used interchangeably, as almost all programs written for Unix will work on Linux, and most of the times, binary executable from Unix can be run directly on Linux.

Some well known Linux distro are as shown below. GNU/Linux doesn't endorse any of these as they contain proprietery code (or non open source code called blobs) in them. However all of these are developed from GNU/Linux project. The ones they endorse contain entirely open source code, but then those OS are difficult to handle as some critical hardware on your laptop may not have a open source binary for it, so 100% open source may not be an option.

1. SUSE: A German company. It maintains free version openSUSE, and a paid commercial version, SUSE Enterprise Linux, which is derived from openSUSE.

2. Red Hat: An American company. it maintains free version Fedora, and a paid commercial version, RHEL (Red Hat Enterprise Linux), which is derived from Fedora. CentOS and Mandriva Linux are Red Hat derivatives, that are free too. CentOS is pretty popular in enterprise as it's free, and works almost same as RHEL.

3. SLS (softLanding linux system): This was the oldest and earliest distro of Linux in 1992. It was very comprehensive, but short lived. It was not well maintained, so 2 new distro came out based off it:

  • Slackware in July, 1993. Slackware remained more Unix like, so is less popular than Debian
  • Debian in Dec, 1993. Debian became very popular. Almost all popular Linux distro are based off Debian.

Debian has a lot of derivatives as Linux Mint Debian Edition, Ubuntu, etc. Of these Ubuntu is most popular linux distro today, which itself has more derivatives sprung off it, as Kubuntu, Linux Mint, etc. Ubuntu is maintained by British compnay, Canonical Ltd, so it has financial/resources support system similar to Suse and RedHat. There are 1000's of Linux distro, and many of them are derivatives of derivatives of derivatives to power 6. But the core kernel comes from Linus Tarvolds Linux Kernel, and they all have similar shell, support unix cmds. They only differ in terms of look, feel, ease of use and what additional software/packages they come preinstalled with.

4. Misc: ArchLinux (and it's derivative Manjaro), Gentoo (and it's derivative Chromium OS), etc are many other distro, which are popular too.

 

Which Linux OS should you use?

Well, if you search on internet, you will find that Debian based distributions are among the most popular, as Ubuntu, Linux Mint, Debian, Elementary OS consistently get most page hits, as reported on distrowatch.com. Ubuntu is by far the OS with most support of all Linux OS. I've always installed it without any issues on a laptop running windows, as it has already been tried and tested on lots of laptops/desktops with differing configuration all over the world. Another Debian based distribution which is getting very popular is Raspbian OS for Raspberry Pi, which is the cheapest computer that you can make for under $10.

Fedora, CentOS and openSUSE are other popular distro based off non-Debian base. Linus Tarvolds himself uses Fedora, and considers Debian difficult to install and use. If you plan to use open source from RedHat, I would suggest using CentOS instead of Fedora, as CentOS is compiled from same source code as RHEL, and so is essentially a free version of RHEL. If you want a very light weight Linux distro (may be because you are using a very old laptop from 90's), PeeperMint, Lububtu, LinuxLite (all derivatives of Ubuntu) and TinyCore (sprung off from DSL=Damn Small Linux)  will serve well, but will require a lot of work to get internet, sound, graphics etc working.

So, to narrow it down, these should be your Linux options:

  1. Linux Mint: This is the most popular and most intuitive Linux OS for any newbie. It's based off ubuntu, but a more user friendly version of Ubuntu. This should be your first choice
  2. CentOS: This is a copy of RHEL, but I can't say how impressed I'm with it's functionality. It works for years without ever rebooting. It runs fast, you can install almost all software with ease. If you aren't really a newbie who has never heard of Linux, I would say try CentOS.
  3. Ubuntu: Ubuntu used to the first choice, but now a lot of it's derivatives are more popular. Apart from Linux Mint (), it has many other derivatives as Lubuntu (lighter version of Ubuntu), CentOS (copy of RHEL), OpenSuSE (support of SuSE, but not sure if they use same source code), Manjaro (more user friendly version of ArchLinux).

NOTE: documentation and help with any issues are the biggest challenges in adopting any OS, so go with these largest, most popular OS listed above. Going with any OS which doesn't have large user base is quickly get you frustarted, especially if you run into issues, and you can't find any support or answer.

Running Linux:

All linux distro are very small in size (compared to proprietary OS). They can can easily fit inside 16GB usb drive, so that means you can run any linux distro from usb pen drive. There are 2 ways to run Linux:

1. Installed on Hard Drive: This is where you install linux from usb pen drive or cd/dvd to your hard drive. Then on powerup, it starts running Linux.

2. Live Linux: This is live usb or live cd/dvd: here you do not install linux to your hard drive. Instead os runs from your pen drive without loading itself on hard drive. Anything you do on os is not written to anywhere on hard drive. There are again 2 options here: one is where nothing gets written in pen drive (i.e any files you write, etc are just written in volatile memory of computer, and not to permanent memory of usb, so anything new written is lost on taking powering down the system or taking usb out), and the other is where OS allows you to write new stuff permanently on usb drive, so that you can carry all new changes with you (aka persistent os). Ideally we would be looking for option 2 of option 2 (i.e os running from pen drive without installing on HD, but also allowing us to save files etc on usb)

The usb/cd/dvd option is very convenient as you do not have to install anything on your laptop. you can just keep running os from your flash drive, and take it with you anywhere. It's just like an extra software running on your machine, which is completely isolated from windows os. There are various options available to create bootable live usb/cd/dvd for linux os. I'go thru one such option.

Linux from Scratch:

So far, we downloaded binaries for Linux OS. If you want to build complete Linux OS from scratch (i.e from source files) for learning purpose, it's not too easy, but not impossible either. It may take couple of weekends. A very good website for that is => linuxfromscratch.org

Desktop Environment:

Each distro of Linux comes with it's own desktop environment (DE). DE is the GUI interface that you see on computer (icons, bars, etc). Without DE, you will have CLI, which is how unix computers in 70's used to be. Early 80's brought DE to computers.

DE is a bundle of programs running on top of OS, which share a common GUI, sometimes described as a graphical shell.  Desktop GUIs help the user to easily access and edit files. However, they usually do not provide access to all of the features found in the underlying operating system. Instead, the traditional CLI is still used when full control over the operating system is required.

In X window system (any Linux/Unix like system uses this), a desktop environment typically consists of several separate components, including a window manager (such as Mutter or KWin), a file manager (such as Files or Dolphin), a set of graphical themes, together with toolkits (such as GTK+ and Qt) and libraries for managing the desktop. All these individual modules can be exchanged and independently configured to suit users, but most desktop environments provide a default configuration that works with minimal user setup. KDE and Gnome were 2 most popular DE that came about in late 90's. Most popular linux distro use KDE or GNOME2, though lots of others have come up now. KDE Plasma Desktop is latest DE from KDE which is very powerful, and is the default on OpenSuse, Kububtu, etc. GNOME2 is the default on SuSE, RHEL, Fedora, Debian and many other derivatives of those (incl Ubuntu, CentOS, etc). GNOME3 is latest DE from GNOME but due to complete redesign, it wasn't liked by many users, 2 DE sprung out of GNOME2 - Cinnamon and Mate. Ubuntu switched to it's own DE "Unity", but then switched to GNOME3 starting from version 17 of OS. See wiki for various DE.

Linux installation:

Before we get into Linux installation, let's talk a little about Windows. It's a pity that you have to get your system to dual boot with both Linux and Windows present on the same machine. The reason you can't remove Windows OS is because many of the websites don't work on Linux browsers. Now with that info, let's try to get rid of as much as junk as possible.

Windows Changes:

The very first nuisance is that you can't use your laptop unless you have an account with microsoft, and they force you to sign in with that account. With Windows 10, you were able to avoid all of this by turning off internet, before setting up the laptop for the first time. Now, with Windows 11, it doesn't allow you to set up the computer if you are not connected to internet. I looked up tons of articles, but couldn't find anything reliable that works. So, I created my cheatsheet below based on what worked for me.

  • Switch to local account: Windows requires you to sign in with a microsoft account, basically how it's on all phones now. This is such a nonsense. We need to switch to local account. To remove online user account as your sign in option, search for settings. Go to settings->Accounts->Your info. Under there, you will see "Microsoft account" followed by a link to "Sign in with a local account instead". Click on that, enter minimal info (I think "user name" is required"), click next->next until done, and now your microsoft account will be switched with a local account. All of this is buried deep down on purpose
  • Remove Sign in option: Get rid of all PIN and any other sign in info. Some of should already be removed once you switch to local account. Go to settings->Accounts->sign-in options. Click on "PIN", click on "Remove PIN". Then under "Additional Settings", "choose "Never" for "When should Windows require you to sign in again". For account password removal, click on Password. It will ask for your current password and new password. Keep "New password" field blank. Now click ok, nd no more password required to login.
  • BitLocker Encryption: From Windows 10, there's this extra non-sense of BitLocker encrypting your hard drive to keep it safe. There's a recovery key associated with that, which is associated with your "Microsoft account" that was used for logging into your computer. Above, we switched to local account, but our online microsoft account is always associated with this laptop. This encryption causes a lot of grief during Linux installation, so disable it. Search for "encryption" in search box. It will show  "Device Encryption settings" which can also be accessed via settings->Privacy&Security->Device_Encryption. There you will need to turn it "off", if it's already "on". There's also an option to print or save "BitLocker Recovery Key" which is essential to have, if you ever do any BIOS changes. It's wise to keep a printed copy of this recovery key just in case something bad happens.
    • NOTE: There's a "Device Encryption" option  via Control panel->System&Security->Device_Encryption. This won't have anything in it to change, so don't end up here. This is NOT the right one.
  • Secure Boot: This is your last hurdle to getting Linux installed. You have UEFI in Windows 10, which has "secure boot" enabled. This prevents Linux OS from installing and will give error "Image could not be authenticated". To resolve this, you will need to change BIOS/UEFI settings. 2 ways to do this:
    • BIOS: You can directly get into BIOS settings. Press F2 (or some other function key depending on your laptop model) to boot into BIOS setup screen, while the laptop is just starting up (before it goes into the OS). Once the "boot window" comes, go to appr screen, and you will see "secure boot" option. Disable that.Then save changes and restart.
    • UEFI: Use this method when the BIOS method above doesn't work. Goto "change advanced startup options" in windows 10, From there, choose "Troubleshoot" -> Advanced options -> UEFI Firmware settings. The laptop will restart and will take you into "BIOS settings". Read through the list of options. There should be an option for "secure boot". Disable that.Then save changes and restart.
  • IMPORTANT: You need to do both steps: Disable "Bitlocker" first and then disable "Secure Boot". If you disable "Secure boot" first, the BIOS will keep asking for "Bitlocker" Key, and won't allow you to proceed. The only option will be to power down forcefully, and then powerup, go into BIOS and change "secure boot" to "on", and then it will allow you to log into Windows OS. So, the sequence of steps is very imp.

Now you are good to start with Linux installation process.

First need to find out a linux distribution that you like: https://www.howtogeek.com/313423/the-best-linux-distributions-for-beginners/

There are 3 basic steps in installing linux on a laptop, which already has windows 7, 8, 10, 11 installed.

  1. Dwnload linux iso, and burn it on a usb device or a dvd.
  2. Create an empty partition on windows with appr size on which we will install windows.
  3. Then from windows, choose the option to "restart and boot from usb efi device". Now on restart, laptop boots from usb. Follow the onscreen instructions for linux  from here on. Finally, you will have dual install with both linux and windows insalled.

Below are the 3 steps in more detail. I've explained specific steps for each OS later, but these are common ones for all OS.

1. Download and burn linux iso:

You need to download iso file from corresponding linux website (see choice of Linux OS in the section below), and have at least 16gb usb (you can get these 16gb usb for $2.99 on bestbuy very often). You need to follow the instructions in links below.

There are various ways to burn linux iso on a dvd or usb device. Many laptops do not have dvd drive anymore, so usb device is the only option available. However, installing via dvd can be life saver in cases where, linux fails to install via usb drives. In such cases, installing via dvd works just fine (one such example is ubuntu mate which installs via dvd only in my case).

There are 2 ways to burn linux iso files on usb. Both methods are detailed below:

NOTE: you will have to format your usb drive, before you burn iso files on it. On windows, you can do it by right clicking on that usb drive and clicking "format". Only FAT32 and NTFS are supported formats. If your usb drive is > 32GB, it will format it in exFAT instead of FAT32, which is not supported. If you burn iso files without formatting, the drive may not be bootable. In that case, reformat the drive with correct format, and then reburn the iso files. If your device already had something stored on it before, then there's no need to format it as it's already formatted.

Option 1: For WINDOW USERS: UUI installer, install on windows 10. => NOT RECOMMENDED.

This is needed for window users who don't have linux machine. Because of issues with this, I would recommend to go with option 2 below. Use this option at your risk.

Burn iso file on usb from within windows using UUI. We can't just copy and paste iso file from windows to usb drive, as the file doesn't get copied from start sector, so it won't be identified at all by the bootloader as having a valid OS. You need some 3rd party software, which in our case is UUI. UUI works flawlessly with most linux distro. However it does cause issues with some Linux distro which specifically ask not to use this UUI installator, We may also use the inbuilt burn option in windows that burns files to usb device. If you have a linux machine already, option 2 below will work flawlessly, so use that instead..

For people who can't use option 2 below and want to use UUI, here's the link for download:  https://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/.

On UUI installer, you will also see an option for formatting drive. I've never chosen any of those options (leave them unchecked). There are other ways to format device as I've mentioned above.

Option 2: ForLINUX USERS: using linux cp or dd cmd on Linux machine:

This option is the recommended one. However, this option does require access to a linux machine.If you don't have a linux machine, go with option 1 above.

There are lot of cmds in Linux to copy files from one source to other destination.

 Below are the steps:

A. STEP 1: From within linux, open a terminal and run "lsblk" to get device name for usb. First do it w/o usb inserted and then do it with usb inserted. You will see new "usb device" when doing it with usb inserted, It should be something like /dev/sdb (not using /dev/sdb1). part below means partition.

aarav@aarav-HP-Laptop-15-bw0xx:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk
├─sda1   8:1    0   260M  0 part /boot/efi
├─sda2   8:2    0    16M  0 part
├─sda3   8:3    0 471.5G  0 part /media/aarav/Windows
├─sda4   8:4    0   980M  0 part
├─sda5   8:5    0  13.9G  0 part
├─sda6   8:6    0  18.6G  0 part /
└─sda7   8:7    0  93.1G  0 part /home
sdb      8:16   1  14.5G  0 disk
└─sdb1   8:17   1  14.5G  0 part /media/aarav/UUI
sr0     11:0    1  1024M  0 rom  

B. STEP 2: This step to unmount device is NOT needed. It may be needed for "dd" cmd below, but NOT for "cp" cmd.

Ignore all steps below and proceed to step 3.

We need to unmount sdb1, so run cmd (NOT needed anymore):

sudo umount /dev/sdb1

Now, when we run lsblk, it will show sdb1 as "part", with nothing mounted on it.

sdb      8:16   1  14.5G  0 disk
└─sdb1   8:17   1  14.5G  0 part

C. STEP 3: Now run any of Linux cp cmds. i used to think dd was the program that copies and maintains the image integrity. From the link below, looks like any cmd will do. Infact, plain "cp" cmd will work just fine.

https://unix.stackexchange.com/questions/224277/is-it-better-to-use-cat-dd-pv-or-another-procedure-to-copy-a-cd-dvd/224314#224314

Some Linux distro do not work with UUI installer at all as I mentioned above. CentOS and Arch Linux are the ones that gave me errors when trying to boot with image copied on USB drive. When I used Linux "cp" cmd to copy image, they worked flawlessly. UUI is not the preferred method for any Linux distro. Even if you have Windows machine, try to find someone with a linux machine to copy iso image. It'll save you few headaches :)

cp cmd: Plain old vailla "cp" cmd works.

sudo cp /home/aarav/Downloads/CentOS-7-x86_64-Everything-1804.iso /dev/sdb => This copies from src iso file to destination drive (here /dev/sdb. Do NOT use /dev/sdb1). This is fast and only takes less than a minute. Note that no . is needed in dest (i.e /dev/sdb/. is not needed, though may be used)

dd cmd: dd cmd is not really needed, but I'm putting it here, since I already used it multiple times, got it into my notes, and feel wasted deleting it.

Ignore all steps below for dd cmd and go to step 2 below.

sudo dd if=/home/aarav/Downloads/CentOS-7-x86_64-Everything-1804.iso of=/dev/sdb status=progress oflag=sync

18354176+0 records in
18354176+0 records out
9397338112 bytes (9.4 GB, 8.8 GiB) copied, 3529.5 s, 2.7 MB/s

It will take couple of hours to burn the usb device, and progess will show on progress bar. Once done, run lsblk cmd. It will show 2 partitions under sdb: sdb1 and sdb2

sdb      8:16   1  14.5G  0 disk
└─sdb1   8:17   1  4.3G  0 part

└─sdb2   8:17   1  8.5M  0 part

Congratulations. Now, this usb device is ready to be used to install linux.

2. Create empty partition on windows:

search for "partition" on windows 8/10/11. In windows 8, you can search by taking your mouse to top right corner, and then search option will show up on right side. search for "format", and choose "create and format hard disk partition". In windows 10/11,  search for "format" in windows search bar (Windows 10 has it in bottom left of screen, while windows 11 has it in center), it will bring an option for "create and format hard disk partition", choose that. It will bring a "disk management" window. Under C drive, it will show the largest hard drive on which windows is installed. Right click, and select "shrink volume". Choose amount of space to shrink by, and it will create a new, unallocated partition with that size (choose any size greater than 20GB). When we say shrink by 50GB, it creates a new "unallocated" partition of 50Gb. This "unallocated" partition is what we will use to install Linux. This "unallocated partition" will have nothing in it, and is unreadable by windows.

3. boot from usb device:

Once partition is created, then from within windows 8/10/11, you can ask the OS to restart and boot from USB drive. This is the easiest way. Search for "startup" in windows 8/10 search bar as explained above. It will bring an option for startup under settings (usually called "change advanced startup options" in windows 10/11) , Choose that, click on advanced startup, and then from within there, goto boot from "efi usb" drive. Make sure you have your usb drive (with Linux iso file burnt on it) inserted in laptop. You will see your usb drive name, or linux distro name or something similar. Now laptop will start and it will boot from usb drive. It will show you various options when it's booting from usb drive, just choose the "Linux OS boot" option (do not choose OEM, advanced, repair or any such option). Once you are inside Linux OS, you will see "Install Linux Mint" or similar icon. Just click on it, and it will guide you through instructions. For some linux distro as "CentOS", installation starts right away, when you select "install CentOS". 

Troubleshoot Issues before Linux Installs:

There are multiple issues when you can run into when installing Linux distro in step 3 USB drive not showing up. Windows 11 has even more stringent requirements before it can dual boot, compared to windows 8/10.

1. USB drive isn't showing: Sometimes, usb drive is not recognized at all during powerup, (even after you have clicked on "boot from efi usb device" from within windows). Your laptop will boot into windows as it normally does, without showing the boot menu from usb drive. If that happens, then you will need to use some combination of Function key (F1, F2, ctrl + F1, etc) to get into BIOS, and from there ask it to boot from usb drive. This just depends on brand of your laptop. For dell laptops, F2 or F12 work (without the "fn" key, just keep hitting the F2 or F12 key repeatedly). It will work eventually, you will have to patiently search on internet for key combination to enter BIOS. This is usually not required on windows 8/10, as "booting from EFI USB device" works on most laptops with windows 8/10. Windows 11 is  different story.

2. Disable BitLocker Encryption: This needs to be turned off, as explained above.

3. Disable Secure boot mode: This needs to be turned off, as explained above. Now, on restarting and starting with step 3 again (as shown above), you shouldn't get that error message.

 

Linux Power up OS selection:

Once you have Linux installed alongisde windows, you can now now turn off your computer and restart. Now a new menu will come up right after powerup. This menu is from Linux GRUB, and it allows you to choose which OS you want to boot into. Sometimes, this GRUB menu doesn't show at all, and machine boots right into windows. This GRUB menu is there along with Linux OS, but for some reason, Windows OS still retains control. There are many ways to fix this. You will have to search on internet. One of the options that has worked for me all the times in the past is here:

https://www.partitionwizard.com/clone-disk/dual-boot-option-not-showing.html

Here, option 2 is what worked. You have to type this line exactly on the cmd prompt of windows machine (open command prompt as admin), and GRUB menu comes back during startup. On windows 10, it shows "windows Powershell" in menu. you do NOT want to use that. You have to search for "command prompt" in search field, and then you will see option for "Run as administartor" on right side. you have to click on that and that will open "Administartor: Command Prompt". If you see "Administrator: Windows power shell", you are in wrong place. It may mess up your system. Also note the spaces and slashes in the cmd below. It should say "operation completed successfully" on entering the cmd below.

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

NOTE: There are lot of articles on how to fix this issue in windows 10. None of them may work for you. The fix depends on the brand of laptop you have. If you are not able to find anything that works, you can manually boot into Linux everytime by getting into the boot option (when computer power up). You have to find right sequence of keys to press to bring up bootup option (again search on the internet to find the sequence of keys for your particular brand of laptop). You may not be able to get the boot menu, but atleast you'll be able to login to Linux. I always had a hard time with HP laptop into getting dual boot :(

Linux distro:

I've installed Linux Mint, Ubuntu, OpenSuse and CentOS successfully on different laptops. I'll go over the instructions for each of these below.  If there is any error during installation process, then it's best to remove the installation, start fresh with new installation. Some files may get corrupted if there is any error during installation process. Trying to get that installation to work next time w/o deleting it is a sure wastage of time. However, deleting a linux distro is nt staright forward, look in below section.

These are couple of inux distro that I installed personally, and would recommend. I've detailed section for each.

  • Linux Mint
  • CentOS
  • Ubuntu
  • Arch Linux
  • Opensuse
  • MX

 

Uninstall/delete Linux distro: 

Some times, the Linux distro will run into issues halfway thru installation. in such cases, it's best to uninstall Linux OS, GRUB and then reinstall fresh. To uninstall Linux, steps to be done in below sequence are: 

  1. remove grub boot loader
  2. remove linux partition by logging into windows OS => NOTE:don't do this step before removing GRUB, as that may make GRUB not see Linux partition, and will give pain trying to delete GRUB.

Link => https://itsfoss.com/uninstall-ubuntu-linux-windows-dual-boot/

 

DeskTop Environment (DE):

Display manager (dm), aka login manager is responsible for bringing up this graphical login screen, and sets up graphical environment once logged in. Window manager (wm) is responsible for windows once logged in. It controls the placement and appearance of windows within a windowing system. Both dm and wm together along with file manager, terminal, etc comprise a desktop environment (DE). many dm can automatically dtect isntalled DE, and can give a choice as to which DE we want to start once logged in. Variuos DE come with a default dm and wm. These are the DE for various distro:

Remember, KDE and GNOME were the only 2 DE in Linux in 1995. corresponding dm were kdm, gdm, xdm (x display manager), lightdm (light display manager). wm were twm (most common on gnome).

GNOME:  dm=gdm (GNOME display manager), /etc/gdm has all configuration files. latest GNOME is GNOME3. It has 2 options: GNOME shell, and GNOME classic. GNOME classic is what is favoured by most distributions, as GNOME shell is major departure from earlier GNOME DE. Earlier version is GNOME2, which was very popular. A branch is forked off GNOME2 and that DE is known as MATE. Another such branch of GNOME2 is Cinnamon. Cinnamon is default DE for LinuxMint, while GNOME classic is the default for CentOS. Although GNOME classic looks similar to GNOME2, and is advertised as GNOME2 compatible, it's very different than GNOME2 in how it can be configured. Many of the options are locked down in GNOME3 classic (i.e number of workspaces is fixed to 1, no way to get a panel menu by right clicking on top menu bar, etc). Best thing to do is to just switch to MATE (which looks very similar to GNOME2) or Cinnamon (which looks very similar to windows and is the most user friendly linux gui for any user).

KDE: dm=kdm (KDE display manager). But on latest KDE Plasma 5, kdm has been replaced by sddm. It's default DE for OpenSuse.

Xfce: This is very light weight DE. It started as common desktop environment (CDE). wm=xfwm

 

Which of these DE gets called at powerup is decided by /etc/X11/xinit/xinitrc (or other files for sysctl). The binaries for these DE are put in /usr/bin/ (As *session*, or as *mate*, *kde*, etc). We can put an optional .xinitrc file in user dir with cmd "exec mate-session" in it. Then at startup, when that user logs in, MATE would be started as GUI. "exec gnome-session" in  .xinitrc will start GNOME at startup. Other way would be by putting a .Xclients file in your home dir, with name of session you want to start. i.e to start "MATE", type "mate-session" in .Xclients, change permission to +x (executable), However, this may not work for distro that have switched to sysctl (i.e it doesn't work on CentOS 7). Most fool proof way to achieve the same result is by removing all *.desktop file from /usr/share/xsessions/ except the one that we want to be there by default. Then system will boot into that GUI session for which the desktop file exists (since there's no other desktop file to look for). You can move those unneeded *.desktop files to some temp dir, and then move it back when needed. That way we can change to whatever DE we want to.

 NOTE: Remember all of these changes above with regard to .xinitrc, .Xclients, etc may still work for "startx" as startx does call xinit, which eventually looks in xinitrc file. You can look thru the code of xinitrc to figure out what file to change to get a particular wm, when running startxx from CLI in any of the virtual terminal. For ex, from tty2, we may type "startx" and that will start a wm. 

systemctl:

Once you install these different DE in any linux distro, you will see these in /usr/share/xsessions/*.desktop. Each of these DE have a dm and a wm. We can change which dm to power up with by using systemctl cmd (with sudo preceeding the cmd, as it requires root privileges)

sudo systemctl enable gdm.service => Tells systemd to start gdm automatically at boot. "disable" disables this. "enable" creates symbolic links, while disable dremoves these links. "start" will start an application's systemd service, while "stop" will stop it in current session. /etc/systemd/system/display-manager.service decides what dm gets started at boot. If gdm is to be started at boot, then there will be a soft link to /usr/lib/systemd/system/gdm.service .

systemctl get-default => This shows us the default run level of system. Earlier, /etc/inittab file used to have runlevel info since we used "init" system, but now since we use systemd, it uses targets instead of run-level. multi-user.target is analogus to runlevel 3, while graphical.target is analogous to runlevel 5. Runlevel 3 is text based login, while 5 is gui (X11) based login. Target is determined by /etc/systemd/system/default.target which is a softlink to /lib/systemd/system/grahical.target (for GUI based login mode). This link can be changed by using "systemctl set-default multi-user.target". target determines what services will be run, as each target is dependent on services or other targets, which in turn are dependent on services

sudo systemctl list-dpendencies graphical.target => This list all dependencies for graphical target. One of the dependencies listed here will be gdm.service which shows that dm used is gdm. "ps -ef | grep gdm" will also show /usr/sbin/gdm as one of the processes if gdm was used as dm.

 

Install desktop environment (DE):

Each OS has it's own way to install DE. We talk about installing these in the respective "OS installtion" sections.
 


 

Desktop Icons:

Sometimes, we install a software, but it doesn't automatically put a desktop icon, that we can click on. Making aDesktop Icon in Linux is easy. Make a file with .Desktop, and inside it, provide the icon image (Icon=), the executable to run (Exec=), and the dir, where it should be run (Path=). That's it.

NOTE: putting a .Desktop extension is necessary, else the script won't run. Let's create a file in Desktop dir: Desktop/Vivado\ 2023.1.Desktop and put in the belw contents(\ is there since I have a space in the name of the Desktop entry. If I had Vivado_2023.1.Desktop, then no \ needed). This name is not what appears below the dsktop icon, it's the name provided below (Name=). All other options may be omitted.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=/tools/Xilinx/Vivado/2023.1/doc/images/vivado_logo.ico
Name[en_US]=Vivado 2023.1
Exec=/usr/local/bin/run-vivado
Path=/home/rajesh/Vivado_training
Name=Vivado 2023.1
StartupNotify=true

Now an icon will appear, as soon as the above file is saved. Now we can click on the icon and see if it runs our executable. Put a small script that prints "Hello World" in a file and check that the file appears in the dir indicated.