Friday, May 25, 2018

Understaning Linux : /lib /mnt

/lib  

The /lib directory contains kernel modules and those shared library images (the C programming code library) needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin. Libraries are readily identifiable through their filename extension of *.so. Windows equivalent to a shared library would be a DLL (dynamically linked library) file. They are essential for basic system functionality. Kernel modules (drivers) are in the subdirectory /lib/modules/'kernel-version'. To ensure proper module compilation you should ensure that /lib/modules/'kernel-version'/kernel/build points to /usr/src/'kernel-version' or ensure that the Makefile knows where the kernel source itself are located.

Examples:
/lib/modules/'kernel-version'
The home of all the kernel modules. The organisation of files here is reasonably clear so no requires no elaboration.

 /mnt

This is a generic mount point under which you mount your filesystems or devices. Mounting is the process by which you make a filesystem available to the system. After mounting your files will be accessible under the mount-point. This directory usually contains mount points or sub-directories where you mount your floppy and your CD. You can also create additional mount-points here if you wish. Standard mount points would include /mnt/cdrom and /mnt/floppy. There is no limitation to creating a mount-point anywhere on your system but by convention and for sheer practicality do not litter your file system with mount-points. It should be noted that some distributions like Debian allocate /floppy and /cdrom as mount points while Redhat and Mandrake puts them in /mnt/floppy and /mnt/cdrom respectively.


  $ mount /dev/hda2 /home 
  $ mount /dev/hda3 /usr
  $ 

Understanding Linux : /home

Linux is a multi-user environment so each user is also assigned a specific directory that is accessible only to them and the system administrator. These are the user home directories, which can be found under '/home/$USER' (~/). It is your playground: everything is at your command, you can write files, delete them, install programs, etc.... Your home directory contains your personal configuration files, the so-called dot files (their name is preceded by a dot). Personal configuration files are usually 'hidden', if you want to see them, you either have to turn on the appropriate option in your file manager or run ls with the -a switch. If there is a conflict between personal and system wide configuration files, the settings in the personal file will prevail.
Dotfiles most likely to be altered by the end user are probably your .xsession and .bashrc files. The configuration files for X and Bash respectively. They allow you to be able to change the window manager to be startup upon login and also aliases, user-specified commands and environment variables respectively. Almost always when a user is created their dotfiles will be taken from the /etc/skel directory where system administrators place a sample file that user's can modify to their hearts content.
/home can get quite large and can be used for storing downloads, compiling, installing and running programs, your mail, your collection of image or sound files etc.

Understanding Linux : /etc

This is the nerve center of your system, it contains all system related configuration files in here or in its sub-directories. A "configuration file" is defined as a local file used to control the operation of a program; it must be static and cannot be an executable binary. For this reason, it's a good idea to backup this directory regularly. It will definitely save you a lot of re-configuration later if you re-install or lose your current installation. Normally, no binaries should be or are located here.

Examples:
etc/apt
This is Debian's next generation front-end for the dpkg package manager. It provides the apt-get utility and APT dselect method that provides a simpler, safer way to install and upgrade packages. APT features complete installation ordering, multiple source capability and several other unique features, see the Users Guide in /usr/share/doc/apt/guide.text.gz
/etc/apt/sources.list
 External Link:

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

Understanding Linux : /dev

/dev

dev is the location of special or device files. It is a very interesting directory that highlights one important aspect of the Linux filesystem - everything is a file or a directory. Look through this directory and you should hopefully see hda1, hda2 etc.... which represent the various partitions on the first master drive of the system. /dev/cdrom and /dev/fd0 represent your CD-ROM drive and your floppy drive. This may seem strange but it will make sense if you compare the characteristics of files to that of your hardware. Both can be read from and written to. Take /dev/dsp, for instance. This file represents your speaker device. Any data written to this file will be re-directed to your speaker. If you try 'cat /boot/vmlinuz > /dev/dsp' (on a properly configured system) you should hear some sound on the speaker. That's the sound of your kernel! 

A file sent to /dev/lp0 gets printed. Sending data to and reading from /dev/ttyS0 will allow you to communicate with a device attached there - for instance, your modem.

The majority of devices are either block or character devices; however other types of devices exist and can be created. In general, 'block devices' are devices that store or hold data, 'character devices' can be thought of as devices that transmit or transfer data. For example, diskette drives, hard drives and CD-ROM drives are all block devices while serial ports, mice and parallel printer ports are all character devices. There is a naming scheme of sorts but in the vast majority of cases these are completely illogical.

List Block Devices in the system:
arun@Arun:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda         8:0    0 465.8G  0 disk   
├─sda1   8:1    0   350M  0 part
├─sda2   8:2    0 119.7G  0 part
├─sda3   8:3    0     1K  0 part
├─sda4   8:4    0   290G  0 part
├─sda5   8:5    0   8.6G  0 part [SWAP]
├─sda6   8:6    0  28.6G  0 part /
└─sda7   8:7    0  15.3G  0 part /home
sr0     11:0    1  1024M  0 rom 







To summarize then, the best way to list anything out in Linux is to remember the following ls commands:
  • ls - list files in the file system.
  • lsblk - list the block devices (i.e. drives)
  • lspci - list the pci devices.
  • lsusb - list the USB devices.
  • lsdev - list all the devices.

 Devices are defined by type, such as 'block' or 'character', and 'major' and 'minor' number. The major number is used to categorize a device and the minor number is used to identify a specific device type. For example, all IDE device connected to the primary controller have a major number of 3. Master and slave devices, as well as individual partitions are further defined by the use of minor numbers. These are the two numbers precede the date in the following display:

Tuesday, May 22, 2018

Installing Opencv 3.4.1 in Anaconda Python 2.7.14 in WINDOWS 10

1. Go to opencv website and download the latest package:

                   https://opencv.org/opencv-3-4-1.html

2. Extract the folder to C:\Opencv_3_4_1

3. Find cv2.pyd (Python DLL ) in : "C:\Opencv3_4_1\opencv\build\python\2.7\x64" and copy it.

4. Open Anconda folder and go to site-packages and  paste the cv2.pyd :
                                             
                                E:\MachineLearning-Conda\Lib\site-packages
                             (and/or)   E:\MachineLearning-Conda\envs\opencv\Lib\site-packages

5. Open Environment variable editor: system properties -----> Environment Variables

   In user Variable:

               Variable Name : %OPENCV_DIR%
                Variable Value : C:\Opencv3_4_1\opencv\build\x64\vc14

  In System Variable: Add
         
                path : %OPENCV_DIR%\bin

  step 5 has to be done to make use of ffmpeg.

Check:

External Link:

https://stackoverflow.com/questions/23119413/how-do-i-install-python-opencv-through-conda