Showing posts with label GNU/Linux. Show all posts
Showing posts with label GNU/Linux. Show all posts

Saturday, September 14, 2019

Using GNU Parallel on Linux

Sometime ago I had created a C/C++ program to find the LAN machine/IP that is powered ON or OFF in our Departmental Computing Facility[DCF]. The local IPs have changed now.

The important thing was that program pings each machines/IP address one after another. It would take a lot of time. Recently, I have seen a cmd/package called parallel  that does it in one line linux command. Cool. I can add this to my bashrc which would need only 3 key stokes to find what I wanted.

If it is not installed already, do it

$ sudo apt-get install parallel


$ parallel --halt now,success=1 ping -c1 10.21.225.{1}{2} ::: 0 1 2 ::: 1 2 3 4 5 6 7 8 9 0

This is the one line cmd. Lets break it down and see what it says.

$ parallel echo {1}{2} ::: 0 1 2 ::: 1 2 3 4 5 6 7 8 9 0

what does the above command do. Prints all the numbers from 00 to 29. i.e echo 30 times.

echo 00
echo 01
...
echo 29

parallel does the same, but the order is immaterial.

But, to my purpose I used to check $? whether  0 or 1 or something in my old script. This is done smarter here.

--halt now,success=1 means stop running jobs even if one job is succeeded. WOW!


$ parallel --halt now,success=1 ping -c1 10.21.225.{1}{2} ::: 0 1 2 ::: 1 2 3 4 5 6 7 8 9 0 > /dev/null

I use the above line which prints only the IP I wanted. YAY!
Tata. See you. 

Thursday, April 25, 2019

LaTeX Tips for writing good research article.

// Purely out of my experience(learnt from friends and experts) of using LaTeX
// for writing a good research article collaboratively; good -- In my view!
// good - easy for others to edit;


- use multiple src files and input in the main tex.
- - do not write the everything in a single file.
- - Prior to Overleaf this is modular. But even after this. it is a good practice.
e.g

\input{0ABS.tex}
\input{1INT.tex}
\input{3ALG.tex}

or  keep everything in a folder as well
\input{src/0ABS.tex}
..


- Use Overleaf is plain, simple and speeds up writing .
- - Good for collab; two persons can edit the same file simultaneously.
- - Enough of messing around with errors in texmaker[TM]/texstudio[TS]; bored of it!
- - Double click the pdf it will take you to the line or para(most of the time)!
- - Auto spell check // Never worked well TM


- User labels at a appropriate place(section, figure, subsection) with some standard form; prefix code
     \label{ intro}
e.g
     \label{fig description figure}
      I use codes ={sec, ssec, fig, table, alg, line, etc}

- Using ref and cite
- - Use it ~\ref{} or ~\cite{} so that it stays together with previous word.
- - \cite{r1,r2,r3...} can hold more than one args

- Use separate folder for fig and plot you generate.
- - Include all the source for creating image in case you wanted edit later.
- - I use Latex draw and export as pdf+cropped and include it in figure.
- - I use  pgPlot and Libre office calc for generating plots.

- Use BibTeX; User STD form in
- - use  \bibliography{GlobalBibtex} for file name GlobalBibtex.bib
- - can add mutiple bib file \bibliography{file1,file2}
- - Last name of first author and initials of rest(if any)
- - User _ write the name of paper you will calls as or would like remember as
- - overleaf can match it when citing with the name(after _) as well
- - It is always good to have your own global bibtex file
- - You ca cumulatively add(and maintain!) it as you write more.
- - Aid sin searching for bib entry in the bib file of you previously written papers.
- - Use only Conference verion of the  bib rather than a arviv if you have both.
- - Use DBLB for collection because it is nice search. You coul use others as well - but be uniform.
- - It will be nice if the bib entry has a doi/url
- - So the reader can quickly go to the ref paper in single click from the ref section.
- - Saves a lot of time in googling and find the right version(if multiple (re)versions exist), etc, etc,
- - Sometimes the CAPS may not rendered properly either in title/author name. You would have enclose those inside braces {} to force the capitalization in tact.

// I am updating these over the course of time.
Last Update: 14-Sep-2019

Monday, March 18, 2019

How to make your commits signed or verified in Github

DIY Steps
========
1. Create a GPG key (public and private key) and add it into passwords and keys (seahorse).

2. Add your GPG keys into Github
3. Create your SSH keys
ssh-keygen -t rsa -b 4096 -C "YOUR EMAIL@GMAIL.com"
// Remember the  passphrase it is essential to verified/sign
4. make sure that it is visible on your "passwords and keys"

5. Then On your terminal
cat ~/.ssh/id_rsa.pub

copy paste its content to Github

6. Set some git config if yor have not done earlier


7. That's it. Whenever you make a commit and push you will get a promt asking for pass phares (in step 3) and github credentials as usual respectively.

TADA

YOUR commits are now verified !!

Monday, December 10, 2018

Time synchronization issues in Dual boot Linux Mint/Ubuntu and Windows

I have always used to have the network time in my Linux Mint 19 or Windows 8. However when I switch between Linux and Windows[or vice versa] the time gets modified and wrong time would show up. This Time synchronization issues in Linux Mint/Ubuntu which can be solved by the following simple task.

Steps.
1. Use your favorite editor to edit the file as root [If file not found create a new one]. I am using xed here.

sudo xed /etc/adjtime

2. Make the file looks as below. For me, I had only the first line. I created the next two line and saved it.

0.0 0 0.0
0
LOCAL


3. Reboot!

The issues exactly what is happening in the background is very well explained in this reference article.

References: https://www.techgainer.com/fix-windows-showing-wrong-time-in-linux-windows-dual-boot-system/

Sunday, November 25, 2018

Install CUDA 10 on Linux mint 19 or Ubuntu 18.04

Assuming that you have nvidia GPU with cuda compatibility.
 
These are the steps for installing CUDA 10 on Linux mint 19 or Ubuntu 18.04
  • Install Linux mint 19/Ubuntu 18.04 fresh
  • Use the ppa nvidia drivers repo from lauchpad here
    • sudo add-apt-repository ppa:graphics-drivers/ppa
      sudo apt-get update
      
      
  • The version 410 is the current long term version as on date
  • From "Driver Manager" install the current stable version


  •  


    • Reboot; verify the driver installed from terminal using "nvidia-smi" command


    • Install these packages
      • sudo apt-get install build-essential dkms
        sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
        
    • Download the deb file and follow the below steps


    • sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
      sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
      sudo apt-get update
      sudo apt-get install cuda

    • That's it.
    • Default location of installation is /usr/local/cuda
    • "cuda-install-samples-10.0.sh ~/install" installs sample files
    • cd into the folder "NVIDIA_CUDA-10.0_Samples"
    • make -j2
    • Add the "PATH=$PATH:/usr/local/cuda/bin"  to your "~/.bashrc" as a last line.
      (or)
      PATH=$PATH:/usr/local/cuda/bin:/home/rajz/install/NVIDIA_CUDA-9.2_Samples/bin/x86_64/linux/release
    • run "deviceQuery" to verify the cuda installation.  And do the post installation formalities
    • sudo apt-get install g++ freeglut3-dev build-essential libx11-dev \
          libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
       
       
       
      References
      1. https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/
      2. https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-together-with-9-2-on-Ubuntu-18-04-with-support-for-NVIDIA-20XX-Turing-GPUs-1236/

Tuesday, August 1, 2017

Installing CUDA on Linux Mint and Hello CUDA Program

CUDA® is a parallel computing platform and programming model invented by NVIDIA. In case you wanted to write parellel programs that runs on GPU. CUDA will be helpful. 
 Things that are need for CUDA programming.
  1. A machine with Nvidia Graphics Card
  2. A Supported Linux, Kernel and GCC  [refer here]
  3. NVIDIA CUDA Toolkit
My System Specs is the following: 

Dell Inspiron. It has a Nvidia Geforce grapics card.


Installation steps:
WARNING- Read the step completely before starting. I ran into issues with some of these step. Only for expert users or else you may have to endup reinstalling you OS.

1. Go here and download NVIDIA CUDA Toolkit deb/runfile. I am using the deb file. It is about 2GB. So, be careful if you got lesser bandwidth or Internet quota.


2. To check if you have a CUDA compatible GPU, version of kernel and gcc.  
rajz@warriorwithin ~ $ lspci | grep -i nvidia
08:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 840M] (rev a2)
rajz@warriorwithin ~ $ uname -a
Linux warriorwithin 4.4.0-71-generic #92-Ubuntu SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
rajz@warriorwithin ~ $ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

3. If nouveau is enabled, then we need to disable it. If the below command prints details which means that it is active. So, just disable it by doing the steps below.
rajz@warriorwithin ~ $ lsmod | grep nouveau
rajz@warriorwithin ~ $ sudo vi /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
add above two lines and run the below command.
sudo update-initramfs -u
4. Reboot!!
5.  lsmod | grep nouveau to check if it is active.
6.  Then run the following command based on your file in Step 1. Mine was the following
rajz@warriorwithin ~/install $ dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
7. Run this sudo apt-get update
8. Run this sudo apt-get install cuda
9. Reboot!!
10. Open  ~/.bashrc file and Add the two lines at the end of file
11. Created a folder under Documents(or wherever you wish) to Install sample files and Run the below
rajz@warriorwithin ~/Documents $ cuda-install-samples-8.0.sh cuda-samples/
12. cd into ~/Documents/cuda-samples/NVIDIA_CUDA-8.0_Samples and do make
13.  Then do the following



14. If it shows up like in the figure. Then it is all fine. 
15. So, far so good. Next up is Hello World CUDA program  


I am unsure if the step 3, 4, 5 are really necessary. But still did it for completeness sake.

ALERT!!!
After Doing these steps. My system went blank after a restart!!!!!
I figured it out that My display is by Intel Graphics Controller.  Where as after NVIDIA Driver installation it set nvidia as my default display or card. So, I was getting a blank screen; Grub loaded. Linux mint Logo appeared. Even login happened. but I can't see any thing. even TTY didn't work. 

Workaround to fix this.
1. During Grub loading. Press 'e'. search a line and prefix nomodeset before quick splash and press enter.
2. It will take you to login. But cinnamon may crash. 
3. Using terminal Uninstall all drivers of nvidia sudo apt-get remove nvidia** 
4. reboot. I reverted the changes I did in step 3,4 of prev installation.
5. Get to know you GPU model from lspci cmd
6. Download http://www.nvidia.com/Download/index.aspx?lang=en-us your driver based on your MODEL, and OS; Mine was this
7. Go to TTY by pressing CTRL+ALT +F1
8. Use cmd to stop display using Card[on Linuxmint] using sudo service mdm stop 
8.1 For ubuntu OS; use sudo service lightdm stop 
9. sudo ./NVIDIA-Linux-x86_64-384.59.run --no-opengl-files
 follow instruction
9.1 I said no only for 32 bit libs; Rest say positively. IMPORTANT.!
10. sudo service mdm start will get you back to GUI mode.
11. Reboot! huh! Hoping that it won't go blank!

Cheers,

Let me know if these steps doesn't work or even if it works! Hope it helps!

References
[1] - www.docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
[2] - https://askubuntu.com/questions/799184/how-can-i-install-cuda-on-ubuntu-16-04
[3] - https://kislayabhi.github.io/Installing_CUDA_with_Ubuntu/

Monday, November 23, 2009

E: Couldn't find package on #apt-get install update

warrior:/home/rajz# apt-get install

Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Couldn't find package

This is may work by doing
#apt-get install update
but if the above error repeats for this command too.. then.
System>Administration>Software  sources (need root password)
In third party software tab click add
deb http://http.us.debian.org/debian/ lenny main
In Debian software make sure download from  is 'Main Server'
close it. click Reload. (This is important)
Open a new terminal window (close the existing terminal if any)
run the apt command again. It will work !

Sunday, November 22, 2009

mount windows partitions on Linux (Debian)

Install the necessary pakages (both are *important*)
#apt-get install libfuse2

#apt-get install ntfs-3g
 to find the drive use:
#fdisk -l | grep NTFS
/dev/sda1               1        5222    41945683+   7  HPFS/NTFS
/dev/sda5            5223        7833    20972826    7  HPFS/NTFS
/dev/sda6            7834       10444    20972826    7  HPFS/NTFS
/dev/sda7           13056       15013    15727603+   7  HPFS/NTFS

then mount the drive using command: (assuming that /home/rajz/disk folder exists. If not create it . mkdir /home/rajz/disk )
#mount -t ntfs-3g /dev/sda1 /home/rajz/disk
To unmount a drive (remember its umount & not unmount )
#umount /dev/sda1
To auto mount a dive at start up u have to edit /etc/fstab add following lines. Assuming that if i want to auto-mount  /dev/sda1 on /home/rajz/disk. You have to be a root user to edit that file. Use your favorite editor. I'm using gedit for now.
#gedit /etc/fstab
make changes like:

/dev/sda1       /home/rajz/disk           ntfs-3g    defaults        0       2

After making changes to file (if u want mount it after unmounted ). use simply. (lengthy command is not needed now as linux knows about sda1 & its filesystem, its mount point or target)
#mount /dev/sda1
Thanks to beginlinux.wordpress.com

Thursday, October 8, 2009

Install flash player 10 on Debian/Ubuntu

Install Adobe flash player 10 for Firefox/Iceweasel on Debian/Ubuntu

1. Uninstall the existing plugin using
# apt-get autoremove flashplugin-nonfree
2. Close all Firefox/Iceweasel windows (must)

3. Download the flash 10 plugin from here (or try this)

4. Use this command to install
#dpkg -i install_flash_player_10_linux.deb         
5. If you encounter this error
dpkg: error processing adobe-flashplugin (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
adobe-flashplugin
user this to resolve the dependencies
#apt-get -f install

6.That it check whether flash player has installed correctly here. Also note your version.

Sincere thanks to cyberciti.biz.

Wednesday, September 23, 2009

How to install themes on Ubuntu/Debian

Well well! This is my first Linux How TO.





If you get bored of looking at you default desktop theme and wallpaper then here is my suggestion. Now , I am going to demonstrate u how to change ur Linux(mostly all distros but i tried in Debian/Ubuntu) into a colorful looking one. As i have already installed my favorite collection (Slickness theme-MashupMaXo icons-minimalisticea wallpaper). I would demonstrate to you with a simple collection

For this tutorial i have used the following
Darker theme
Erectus icons
minimalisticea wallpaper

Download list
Download from here for Debian/Ubuntu (gnome-look.org/www.debian-art.org)
1.Download GTK themes (panel color & look of each window)
2.Download icons (for iconic view of folder/disks)
3.Download wallpapers (obvious)
4.Download GDM theme (for login screen)

Procedure
1.Downloaded GTK theme package.
2.Right click on desktop select change background. Select theme tab and click install select the downloaded theme pakage
3.After installation success.select the theme to visualize/apply it
4.Downloaded icon package/files
5.Extract the package you will get a folder. Copy & paste inside /home/rajz/.icons folder? (user address bar /home/user/.icons folder or else try using cp/mv command in terminal)
6.Right click on desktop select change background. Select theme tab and click customize option, icons tab then select the name of downloaded icon package
7.Similarly right click on desktop select change background. Select background tab and click image u want (even browse for your favorite image through add button)
8.Right click on desktop select change background. Select theme tab and click save as option. Give the suitable name and save it.
9.Download GDM theme
10.Now we go for login screen selection.System> Administration> Login Window. Select local tab. Click add button & select the package
11.After that select radio button of your added theme

Thats it every thing is done !
Show it t our friends and amaze them. Make them ask "Is this Linux ? Is this Debian/Ubuntu?" end of my 1st how to

Monday, September 21, 2009

Met stylesen & c0le on FStival' 09

I know that I am blogging after a long period of time. There is a valid reason for it because yesterday (09/19/2009) FStival'09 was conducted by CSE department in our college. There are many situations i have felt for not being a CSE student. Because, they have sophisticated lab (practically see all the kinds of server there) more importantly labs that don't close at 4:30. Great passion developed in me due to FStival'07 which i attended during my 2nd year. That made me to use only GNU/Linux based software's for almost all my day today works. Their is no turning back from then on. I still use Hardy Heron in my Laptop.

Well Let's get to point. I had an opportunity to talk with most important and prominent persons behind TCENet project (an award winning project of our college). I found Senthil Kumaran and Joe Steeve were still (remotely) working on this TCENet project which i came to know from TCEwiki and tce's mailing list Archives (i spent a whole night reading all old mails). I have heard about the version control systems like Subversion, CVS, GIT but never used it. TCENet is maintained using Subversion (a product of CollabNet) and these people are still contributing to it remotely. Also I found that any one interested can contributed to TCENet project, for that you need not be CSE student or need not go to Unix lab even. I hope that i will contribute to it too. Also joined most of the TCE's mailing list.

I have talked with them and i also shared my interest with them. stylesen anna advised me to startup with a simple project(i.e writing docs for pidgin). I was wanting for support from the staff members which they advised me not expect such. I grasped all those ideas given by them and will act accordingly. These moments with those great people was one of the happiest moments of my life. Taking to stylesen anna was one my long term desire...I am very happy today :-).

Last Post !! Moved to new site

As I am getting old 😋, it seem like I can not remember many of my earlier tech encounters. This is the place I was logging so that I refer ...