Saturday, 29 November 2014

All-In-One Linux-Mint & Ubuntu Packages

All-In-One Linux-mint & Ubuntu Offline Packages (LTS)

Just you need to Extract Packages directory or mount The iso file and Change working Directory to packages and run following command:
dpkg -iEG *.deb
Note: It is recommended that install these packages of your fresh Install of linux( No other packages installed  manually) to avoid unwanted problem due to change in packages version.

Other Linux Offline Packages:

Thursday, 6 November 2014

Soft link and Hard link

What is a Soft Link or Symbolic Link or Symlink ?

Soft links or Symlinks  are very similar to what we say “Shortcut” in windows, is a way to link to a file or directory. Symlinks doesn’t contain any information about the destination file or contents of the file, instead of that, it simply contains the pointer to the location of the destination file. In more technical words, in soft link, a new file is created with a new inode, which have the pointer to the inode location of the original file. This can be better explained with a diagram:
Soft Links on Linux
Symbolic links are created with the “ln” command in linux. The syntax of the command is:
$ ln -s
-s = This flag tells to create a symlink (if you don’t use this it will create a hard link, which we will talk about soon).
For Example, if you want to create a soft link of one fo your favorite application, like gedit, on your desktop, use the command like this:
$ ln -s /usr/bin/gedit ~/Desktop/gedit
I hope now the concept of Soft Links should be clear.

What is a Hard Link ?

Hard link is a bit different object when compared to a symlink. In softlink a new file and a new Inode is created, but in hard link, only an entry into directory structure is created for the file, but it points to the inode location of the original file. Which means there is no new inode creation in the hard link. This can be explained like this:
Hard Links in Linux
So, in hard link, you are referencing the inode directly on the disk, which means that there should be a way to know how many hard links exist to a file. For the same, in the inode information, you have an option for “links”, which will tell how many links exists to a file. You can find the same information by using this command:
$ stat <file name>
$ stat 01
Size: 923383 Blocks: 1816 IO Block: 4096 regular file
Device: 803h/2051d Inode: 12684895 Links: 3
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-09-07 01:46:54.000000000 -0500
Modify: 2012-04-27 06:22:02.000000000 -0500
Change: 2012-04-27 06:22:02.000000000 -0500
In this example, it means that the specific file have 2 hard links, which makes the count to 3.
You can create a hard link with the same command “ln” like this
# ln
So, to create a hard link of gedit program on your desktop, you will use the command like this:
# ln /usr/bin/gedit ~/Desktop/gedit
Now, the bigger question is, who will decide what is better and when to use soft link or hard link

Differences between symbolic link and hard link

  1. Hard link has same inode number as original file while Sym link has new(different) inode number with respect to original file.
  2. Hard link  cannot be created for directories (folders). Hard link can only be created for a file.
  3. Symbolic links or symlinks can link to a directory (folder).
  4. Removing the original file that your hard link points to does not remove the hardlink itself; the hardlink still provides the content of the underlying file.
  5. Removing the original file does not remove the attached symbolic link or symlink, but without the original file, the symbolic link is useless (the same concept like Windows shortcut).
  6. If you remove the hard link or the symbolic link itself, the original file will stay intact.
I

When to use Soft Link:

  1. Link across filesystems: If you want to link files across the filesystems, you can only use symlinks/soft links.
  2. Links to directory: If you want to link directories, then you must be using Soft links, as you can’t create a hard link to a directory.

When to use Hard Link:

  1. Storage Space: Hard links takes very negligible amount of space, as there are no new inodes created while creating hard links. In soft links we create a file which consumes space (usually 4KB, depending upon the filesystem)
  2. Performance: Performance will be slightly better while accessing a hard link, as you are directly accessing the disk pointer instead of going through another file.
  3. Moving file location: If you move the source file to some other location on the same filesystem, the hard link will still work, but soft link will fail.
  4. Redundancy: If you want to make sure safety of your data, you should be using hard link, as in hard link, the data is safe, until all the links to the files are deleted, instead of that in soft link, you will lose the data if the master instance of the file is deleted.
The above points gives you a small idea where to use what, but doesn’t tell you that those are the only options. Everything depends on your setup.

How file is deleted having hard links:

Hard links are just the reference to the main file location, and even if you delete one link, the data will still be intact. So, to remove a hard link, you need to remove all the links, which are referring to the file. Once the “link count” goes to “0″, then the inode is removed by the filesystem, and file is deleted.

FAQs:

Q. What is the one line answer to the question “What is the main difference between hard links & soft links” ?
A. A softlink will have a different Inode number than the source file, which will be having a pointer to the source file but hardlink will be using the same Inode number as the source file.
Q. How can I find all the Soft Links in my system ?
A. Use this command for the same “find /etc -type l -exec ls -li {} \;”
Q. How can I find all the files having Hard Links in my system ?
A. Use this command for the same “find / -links +2 -type f -exec ls -li {} \;”
Q. How to find whether a file is a softlink ?
A. Simply using this command “ls -l” will tell you whether a file is pointing to some other file or not.
Q. How to check whether a file have any softlink pointing to it ?
A. Till now, I am not aware of any way to do that. If I will find any, I will surely update my post.
Q. How can I find out the source file of a hard link ?
A. No, you can’t find out the source file of a hard link. Once hard link is created, there is no way to tell which was the first file created.
Q. Can I make a Soft link to a Hard link and Vice Versa ?
A. Yes, both soft links and hard links acts as normal files of the file system, so you can do both.
References:
  1. Inodes in Linux Filesystem
  2. Techthrob.com
  3. maxi-pedia.com
  4. lwn.net

Wednesday, 5 November 2014

Ubuntu 14.04 installation problem inside Windows

Ubuntu-14.04 64 bit installation inside windows

  1. Get the iso image of ubuntu-14.04-desktop-amd64
  2. Get the wubi.exe. You can extract it from above iso file also.
  3. Keep ubuntu-14.04-desktop-amd64.iso & wubi.exe both in same directory
  4. Run wubi.exe and follow instructions, you can do it easily.
  5. Restart windows.
  6. Wait for completing installation till  restart by itself
  7. When Prompted to select Operating System you want to boot, Select ubuntu Now, Time to solve the Problem
    Serious errors were found while checking the disk for /

  8. As soon as Grub Menu appears, Press 'E' or 'e' 
    • Now you will see contents of grub.cfg
    • Find the line something like "linux /boot/vmlinuz-3.13.0-24-generic root=UUID=[bunch-of-numbers] loop=/ubuntu/disks/root.disk ro rootflags=sync quiet splash"
    • Now Replace ro with rw  
    • Press ctrl+x to boot
  9. Log In to your Ubuntu & Open Terminal.
  10. Run following coomand in terminal
    • sudo su
    • gedit
  11. Now using gedit window opened by terminal, open file '/boot/grub/grub.cfg'
  12. Now search for first occurrence of
     menuentry "Ubuntu........."{
    ...........................

    linux /boot/vmlinuz-3.13.0-24-generic root=UUID=[bunch-of-numbers] loop=/ubuntu/disks/root.disk ro rootflags=sync quiet splash }
  13. Here too, Replace ro with rw  .
  14. You can do same for next two entries of  menuentry "....."{} as they are also to boot ubuntu in advanced mode which is rarely used.
  15. Now save and close gedit window.
  16. That's all.

Ubuntu-14.04 32 bit installation inside windows

wubi.exe is configured to insatll 64 bit ubuntu only, so when we run wubi.exe with ubuntu-14.04-desktop-i386.iso it tries to download ubuntu-14.04-desktop-amd64.iso.
  1. First of all download any Ubuntu iso , may be old, which can be installed inside windows without any problem, and install it But don't Resatrt.
  2. Now copy ubuntu-14.04-desktop-i386.iso to  C:\ubuntu\install  , if installed in C-drive, other wise in X:\ubuntu\install where X is the drive letter.
  3. Now remove the installation.iso from C:\ubuntu\install and Rename ubuntu-14.04-desktop-i386.iso to installation.iso
  4. Mount new  installation.iso and copy vmlinuz  & initrd files(name may slightly differ) to  ubuntu\install\boot. If it ask to replace both files then replace & ignore next line.
  5. Edit  ubuntu\install\boot\grub.cfg  and replace the name of vmlinuz & initrd (old name of kernel files) with new one copied. Infact need to change in three place only, 
    • line with  search ....  vmlinuz...
    • linux ...../boot/vmlinuz...
    • initrd .../boot/initrd....
  6. Now reboot  windows & if needed follow instruction of above article.
Note: It can be used for any linux based on Debian, which has nearly same directory structure in iso. I have used it for Linux Mint 17 x86 & x64, Elementry-x64  and Zorin.

Tuesday, 4 November 2014

Centos 6.5-x64 Package Management Offline

Centos 6.5-x64: Install Important Packages Easily.

Developers Essentials:  g++, jdk, strace, traceroute, finger, coreutils,ftp etc.
Developers IDE: Codeblocks, Emacs,Geany, Bluefish etc
Debugger: GUI for gdb, Nemiver, DDD.
Other: NTFS mounter, Dia, Firefox latest, Google-chrome, chm viewer, rar etc
Multimedia: Important codecs, vlc, kmplayer etc


1.Install Centos 6.5 64 bit

2.Download Packages for 64-bit 

      3.Extract Downloaded Package

      4.Open Terminal in the Directory

       Go to the Directory(Centos-6.5_x86-64_Packages) containing all packages.

      5.Change user mode to super user

      su 

      6.Install Packages

      Run following command in each directory (dev, selinux, important, firefox, vlc, repo) 

      go to each directory using cd command and run Following command.
      rpm -Uvh *.rpm

      That's all.

      ##################### rpm options #######################

      Options: -Uvh

      U: install/upgrade as needed

      v: Verbose mode

      h: print hash marks as the package archive is unpacked.

      ######################################################

      PCLinuxOS-2014 Package Management Offline

      PCLinuxOS: Install Important Packages Easily.

      Developers Essentials:  g++, jdk, strace, traceroute, finger etc.
      Developers IDE: Codeblocks, Geany, Bluefish, Aptana Studio etc
      Debugger: GDB
      Other: Google-chrome, chm viewer, rar, Wine(.exe installer for linux)

      1.Install Centos 6.5 64 bit

      2.Download Packages for accordingly

          3.Extract Downloaded Package

          4.Open Terminal in the Directory

           Go to the Directory containing all packages.

          5.Change user mode to super user

          su 

          6.Install Packages

          Run following command in each directory (current directory and important, wine) 

          go to each directory using cd command and run Following command.

          apt-get install *.rpm
          or
          rpm -Uvh *.rpm

          That's all.

          ######################rpm options ######################

          Options: -UvhU: install/upgrade as neededv: Verbose modeh: print hash marks as the package archive is unpacked.

          #######################################################

          Linux Mint-17 Package Management Offline

          Linux Mint: Install Important Packages Easily.

          Developers Essentials:  g++, jdk, strace, banner, traceroute, finger etc.
          Developers IDE: Anjuta, Geany, Python ILDE etc
          Debugger: GUI for gdb, Nemiver, DDD.
          Other: Dia, Synaptic PAckage Manager, Google-chrome, Putty, dcpp etc


          1.Install Linuxmint-17-cinnamon

          2.Download Packages according to Your Ubuntu( 32 bit or 64 bit)

              3.Extract Downloaded Package

              4.Open Terminal

               Go to the Directory(Ubuntu-14_x64 or Ubuntu-14_x86_Packages) containing all packages.

              5.Change user mode to super user

              su 

              6.Install Packages

              Recomended:
              dpkg -iEGR *
              It will install all .deb Packages from current directory recursively(including sub-directory).
              or,
              Manually: Not recommended, go to each directory using cd command and run Following command.
              dpkg -iEG *.deb

              7.Check status 

              Run following command to check status whether, packages installed correctly.
              apt-get -f install
              That's all.

              ######################### dpkg options ####################

              Options: -iEGR

              i: install/upgrade/downgrade as needed

              E: Skip installed same version

              G: Don't allow old version

              R: install recursively .deb files 

              ########################################################

              Ubuntu 14.04 Package Management Offline

              Ubuntu: Install Important Packages Easily.


              Developers Essentials:  g++, jdk, strace, banner, traceroute, finger etc.
              Developers IDE: Anjuta, Geany, Python ILDE
              Debugger: GUI for gdb, Nemiver, DDD.
              Multimedia: mp3, mp4, avi, mkv, wmv & flv codecs And VLC
              Other: Dia, Synaptic PAckage Manager, Google-chrome, Putty


              1.Install Ubuntu 14.o4

                2.Download Packages according to Your Ubuntu( 32 bit or 64 bit)

                  4.Open Terminal

                   Go to the Directory(Ubuntu-14_x64 or Ubuntu-14_x86_Packages) containing all packages.

                  5.Change user mode to super user

                  sudo su 

                  6.Install Packages

                  Recomended:
                  dpkg -iEGR *
                  It will install all .deb Packages from current directory recursively(including sub-directory).
                  or,
                  Manually: Not recommended, go to each directory using cd command and run Following command.
                  dpkg -iEG *.deb

                  7.Check status 

                  Run following command to check status whether, packages installed correctly.
                  apt-get -f install
                  That's all.

                  ####################### dpkg options #######################

                  Options: -iEGR

                  i: install/upgrade/downgrade as needed

                  E: Skip installed same version

                  G: Don't allow old version

                  R: install recursively .deb files 

                  #########################################################

                  Saturday, 4 October 2014

                  Umask: The user file-creation mode mask

                  Default umask Value

                  The user file-creation mode mask (umask) is use to determine the file permission for newly created files. It can be used to control the default file permission for new files. It is a four-digit octal number. A umask can be set or expressed using:
                  • Symbolic values
                  • Octal values

                  Procedure To Setup Default umask

                  You can setup umask in /etc/bashrc or /etc/profile file for all users. By default most Linux distro set it to 0022 (022) or 0002 (002). Open /etc/profile or ~/.bashrc file,

                  Append/modify following line to setup a new umask:
                  umask 022
                  Save and close the file. Changes will take effect after next login.

                  All UNIX users can override the system umask defaults in their /etc/profile file, ~/.profile (Korn / Bourne shell) ~/.cshrc file (C shells), ~/.bash_profile (Bash shell) or ~/.login file (defines the user's environment at login).

                  Explain Octal umask Mode 022 And 002

                  If the default settings are not changed, files are created with the access mode 666 and directories with 777. In this example:
                  1. The default umask 002 used for normal user. With this mask default directory permissions are 775 and default file permissions are 664.
                  2. The default umask for the root user is 022 result into default directory permissions are 755 and default file permissions are 644.
                  3. For directories, the base permissions are (rwxrwxrwx) 0777 and for files they are 0666 (rw-rw-rw).
                  In short,
                  1. A umask of 022 allows only you to write data, but anyone can read data.
                  2. A umask of 077 is good for a completely private system. No other user can read or write your data if umask is set to 077.
                  3. A umask of 002 is good when you share data with other users in the same group. Members of your group can create and modify data files; those outside your group can read data file, but cannot modify it. Set your umask to 007 to completely exclude users who are not group members.

                  But, How Do I Calculate umasks?

                  The octal umasks are calculated via the bitwise AND of the unary complement of the argument using bitwise NOT. The octal notations are as follows:
                    • Octal value : Permission
                    • 0 : read, write and execute
                    • 1 : read and write
                    • 2 : read and execute
                    • 3 : read only
                    • 4 : write and execute
                    • 5 : write only
                    • 6 : execute only
                    • 7 : no permissions
                  Now, you can use above table to calculate file permission. For example, if umask is set to 077, the permission can be calculated as follows:
                  BitTargeted atFile permission
                  0Ownerread, write and execute
                  7GroupNo permissions
                  7OthersNo permissions

                  To set the umask 077 type the following command at shell prompt:
                  $ umask 077
                  $ mkdir dir1
                  $ touch file
                  $ ls -ld dir1 file

                  Sample outputs:
                  drwx------ 2 vivek vivek 4096 2011-03-04 02:05 dir1
                  -rw------- 1 vivek vivek    0 2011-03-04 02:05 file

                  Task: Calculating The Final Permission For FILES

                  You can simply subtract the umask from the base permissions to determine the final permission for file as follows:
                  666 - 022 = 644
                  • File base permissions : 666
                  • umask value : 022
                  • subtract to get permissions of new file (666-022) : 644 (rw-r--r--)

                  Task: Calculating The Final Permission For DIRECTORIES

                  You can simply subtract the umask from the base permissions to determine the final permission for directory as follows:
                  777 - 022 = 755
                  • Directory base permissions : 777
                  • umask value : 022
                  • Subtract to get permissions of new directory (777-022) : 755 (rwxr-xr-x)

                  How Do I Set umask Using Symbolic Values?

                  The following symbolic values are used:
                  1. r : read
                  2. w : write
                  3. x : execute
                  4. u : User ownership (user who owns the file)
                  5. g : group ownership (the permissions granted to other users who are members of the file's group)
                  6. o : other ownership (the permissions granted to users that are in neither of the two preceding categories)
                  The following command will set umask to 077 i.e. a umask set to u=rwx,g=,o= will result in new files having the modes -rw-------, and new directories having the modes drwx------:
                  $ umask u=rwx,g=,o=
                  $ mkdir dir2
                  $ touch file2
                  $ ls -ld dir2 file2

                  Sample umask Values and File Creation Permissions

                  If umask value set toUser permission Group permissionOthers permission
                  000allallall
                  007allallnone
                  027allread / executenone
                  all = read, write and executable file permission

                  Limitations of the umask

                  1. The umask command can restricts permissions.
                  2. The umask command cannot grant extra permissions beyond what is specified by the program that creates the file or directory. If you need to make permission changes to existing file use the chmod command.

                  umask and level of security

                  The umask command be used for setting different security levels as follows:
                  umask valueSecurity levelEffective permission (directory)
                  022Permissive755
                  026Moderate751
                  027Moderate750
                  077Severe700
                  For more information about the umask read the man page of bash or ksh or tcsh shell:
                  man bash
                  help umask
                  man chmod


                  Referrence:
                  http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
                  by on January 31, 2007 · 97 comments· LAST UPDATED January 25, 2012 in , ,

                  Sunday, 5 January 2014

                  Install libgraph in Linux

                  Install libgraph library in GCC

                  Step #0. Go to Super User Mode in Terminal
                  Use sudo for Ubuntu, Zorin, Uber Student, Ultimate...
                  su for others.
                  Step #1.Install the following in Synaptic Package Manager

                  • build-essential
                  • libsdl-image1.2
                  • libsdl-image1.2-dev
                  • libsdl-ttf2.0
                  • guile-1.8-dev
                  • guile-1.
                  In Debian based linux It can be done by running following command line in terminal:
                  sudo apt-get install  build-essential libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libsdl1.2debian-all libart-2.0-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev libslang2-dev libasound2 libasound2-dev


                  Step #2. Download and Extract libgraph then run inside libgraph... directory in Super User Mode 
                  • ./configure
                  • make
                  • make install
                  Step #3  Include graphics.h in your C program . Initialize the graphics system by

                  • int gd=DETECT, gm=VGAMAX;
                  • initgraph(&gd, &gm, NULL);

                  Step #4 you need to copy all the libgraph shared files from /usr/local/lib to /usr/lib


                  • cp /usr/local/lib/libgraph.* /usr/lib



                  Compile : gcc filename.c -lgraph

                  Example:

                  #include<stdio.h>
                  #include<graphics.h>

                  int main()
                  {
                   int gd=DETECT,gm;
                   initgraph(&gd,&gm,NULL);
                   int i,x=10;
                   char str[3]="0"; 
                   setbkcolor(WHITE);

                   setcolor(12);            //outline heart
                   circle(50,50,40);
                   circle(110,50,40);
                   line(22,80,80,140);
                   line(80,140,138,80);
                      
                   floodfill(50,50,12);     //fill heart 
                   floodfill(110,50,12);
                   floodfill(80,50,12);
                   floodfill(80,100,12);

                   getch();
                   closegraph();
                   return 0;
                  }

                  Comment

                  Feel free to comment/suggest/criticize.

                  My Blog List