Tuesday, June 20, 2017

systemd external hard drive time-out problem during boot.

If you have an external hard drive that is plugged in all the time but on one fine day you boot your system without the external hard  drive and  your system drops to a maintenance shell after looking through the syslog i.e journald  you find out your system got into a loop trying to mount the external hard disk. So what is the solution?
It lies in  the fstab file. In the /dev/sdb line add nofail,x-systemd.device-timeout=1
and do not set it to zero it will go into infinte loop.

for more info check:
https://wiki.archlinux.org/index.php/fstab#External_devices

Thursday, February 18, 2016

Fixing NTFS partition in Debian using ntfsfix

Today my external hard drive suddenly become RAW meaning i couldn't mount it in windows or even in linux and worse I couldn't even run chkdsk utility in windows then i came across this utily called ntfsfix  while searching  for the solution.

The following is from the ntfsfix manpage:

ntfsfix  is a utility that fixes some common NTFS problems.ntfsfix is NOT a Linux version of chkdsk.  It only repairs some  fundamental  NTFS inconsistencies,  resets  the  NTFS  journal file and schedules an NTFS consistency check for the first boot into Windows. You may run ntfsfix on an NTFS volume if you think it  was  damaged  by Windows or some other way and it cannot be mounted.

so to run ntfsfix become root and give the following command

# ntfsfix -d /dev/sdb1

it will fix the most common errors in the NTFS partition.

sources:
1. http://askubuntu.com/questions/47700/fix-corrupt-ntfs-partition-without-windows
2. http://pclosmag.com/html/Issues/201205/page06.html

Iptables configuration for Debian Desktop

Iptables  is one of the best firewall  available today. It will do three things
a. ACCEPT
b. REJECT
c. DROP

It has many frontends like for example ufw, etc. So let's configure our firewall for our Debian Desktop.

#iptables -P INPUT -j DROP
#iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A INPUT -i lo -j ACCEPT
#iptables -A INPUT -p icmp -m limit --limit 1/second --limit-burst 5 -j ACCEPT
#iptables -A INPUT -p icmp -m icmp --icmp-type address-mask-request -j DROP
#iptables -A INPUT -p icmp -m icmp --icmp-type timestamp-request -j DROP
#iptables -A INPUT -p icmp -j DROP
#iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#iptables -A INPUT -p tcp --dport 10000:10020 -j ACCEPT
#iptables -A INPUT -p udp --dport 10000:10020 -j ACCEPT
#iptables -A INPUT -m state --state INVALID -j DROP
#iptables -P FORWARD -j DROP
#iptables -A FORWARD -m state --state INVALID -j DROP
#iptables -P OUTPUT -j ACCEPT
#iptables -A OUTPUT -m state --state INVALID -j DROP

BLOCKING PORT-SCANNING

#iptables -N port-scan
#iptables -A port-scan -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j RETURN
#iptables -A port-scan -j DROP

LOGGING

#iptables -N LOGGING
#iptables -A INPUT -j LOGGING
#iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "Iptables dropped: " --loglevel  7
#iptables -A LOGGING -j DROP

To save our configuration run
#iptables-save
#iptables-save > myrules
edit /etc/network/interfaces using nano and add the following lines at the bottom of the file.
pre-up /sbin/iptables-restore
and save. your firewall configuration is now finished.  your iptables log will be in /var/log/kern.log. If you want to have a custom logging file instead of kern.log then create a file in /etc/ryslog.d with the name iptables.conf
with the following content
:msg, contains, "Iptables dropped: "-/var/log/iptables.log  
& ~
and save the file. Create an empty file iptables.log in /var/log it will now begin to log in /var/log/iptables.log.

# - means root shell.

I gathered all these configuration from the internet and debian forums here are the links  for further information

1. http://forums.debian.net/viewtopic.php?f=16&t=117514
2. http://forums.debian.net/viewtopic.php?f=16&t=16166&hilit=firewall
3. http://sharadchhetri.com/2013/06/15/how-to-protect-from-port-scanning-and-smurf-attack-in-linux-server-by-iptables/
4. http://hakersparadise.blogspot.in/2012/05/using-ip-tables-in-linux-to-secure.html
5. http://unix.stackexchange.com/questions/88994/help-configuring-a-custom-log-file-for-iptables
6. http://www.thegeekstuff.com/2012/08/iptables-log-packets/

Also check this tutorial it is based on iptables frontend called arno iptables firewall.
7. http://cosmolinux.no-ip.org/raconetlinux2/arno_iptables_firewall.html

Sunday, December 27, 2015

Installing a custom Latex .cls

You had recently installed Latex from the repo  or from the upstream iso image. Now you want your own custom latex class file to be installed in your system. So how to install it? Just follow these instructions.

Create a directory called texmf in $HOME. Create  a  directory called  tex inside an another directory called  latex and then another directory with a name of your choice. So finally it should resemble something like this

$HOME/texmf/tex/latex/New* 

* -- Directory name of your choice.

copy your .cls and the .tex files to that directory. Open the terminial and run

mktexlsr  $HOME/texmf

that's it you have installed your very own  Latex class file.

To check if the *.cls file is installed run  kpsewhich *.cls  in the terminal as a normal user it should return the location  of the *.cls file in the terminal.

DIY: Debian from Barebones

Have you ever  wanted to build your own linux system from the ground up like arch linux or LFS if yes then read on: You know debian offers variety of builds for their users there are cd images,DVD images and even a blue-ray image then there is also the small images like netinstall images. The netinstall images downloads the packages from the internet during installation and installs the packages and conigures it. But you don't want the bleeding edge software, you want the stability of debian with the attractiveness and the ease of use you get with the other distros. So with that in mind we'll build our own debian linux system.

1. Download the netinstall image from the debian website. Burn the image to a cd or an pendrive.

2.  Start the installer and partition your hard drives and install the base system.[I assume you can deal with this stuff.]

3. After apt asks you to choose the mirror it will ask for the desktop environment to install, at that time uncheck every thing even the standard system utilities if you are installing it in a laptop choose laptop-utilities and standard system utilities and continue.

4. Then it will install the Grub boot loader and will reboot.

5. After reboot you will be presented with the command line login prompt.

6. Login as user. Become root, edit the Sources.list file. In the sources.list file remove all the lines and replace it with this

deb http://httpredir.debian.org/debian/ jessie main contrib non-free
deb http://httpredir.debian.org/debian/ jessie-updates main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free

save the file.  use the nano editor it is the easiest. httpredir is a new method of choosing your debian mirror automatically and also it results in faster downloads you can read more about it in http://httpredir.debian.org/

7. After changing your sources.list  reload apt with apt-get update.

8. Install  Xorg, Xfce4 and pulseaudio. [I'm choosing the xfce desktop because of it's ease of use and attractiveness and being lightweight] but if you prefer an another desktop environment it is your  choice.

apt-get install xorg
apt-get install pulseaudio pavucontrol
apt-get install xfce4

If you don't want pulseaudio just skip that step.

9. Install login manager. there are different login managers of choice they are gdm,kdm,xdm,lightdm and slim. I'm going with slim login manager because it's independent,lightweight and easy to configure in a single file. So,

apt-get install slim

10. Reboot with the following command 

systemctl reboot

11. Slim will configure your desktop environment and you will be presented with a  graphical login prompt.Login as user.

12. Open up the terminal. Become root, install synaptic package manager and xfce4-goodies.

apt-get install synaptic 
apt-get install xfce4-goodies

13. So we have a very skeletal desktop environment. We need to install applications to make it more functional. First let's start with graphics section. There are lot of image viewers such as gpicview,shotwell,ristretto,feh,etc. for our image viewer we'll install Shotwell image viewer. since we have installed synaptic package manager you can search for shotwell package manager.

14. So in synaptic search for font manager and install it. If you have a collection of fonts in your system you can use it to install it in your system.

15. Install  Vlc player [Necessary], Exaile music player[optional].

16. Install openjdk-7 and iced tea plugin.

17. Install Iceweasel,Icedove if you want email client,Transmission bit torrent client,Chromium web browser, flashplugin-nonfree and pepperflashplugin- nonfree. You may ask why you might need two browsers, one word: Flash.Since adobe is phasing out support for flash in linux platform and only Google is supporting flash with their own plugin you may as well get used to chromium. Chromium is the open source version of the google chrome web browser.

18. Install rar,unrar,lzma,lzip,zip and numlockx.

19. Install Atril document viewer, Fbreader. For office work you can use the kingsoft wps office  else you can install abiword for word processing and gnumeric for spreadsheet and for presentation install libreoffice-core and libreoffice impress.

20. Install Gparted for managing your partition and Ntfs-config for configuring your ntfs partition or your external hard drive.

21. If you open the VLC player at this point  it will look something that came from the  windows 98, its because VLC was written using qt library so to make it look beautiful go to tools->Preferences->force window style -> choose GTK+.

22. Install qt4-qtconfig and Gtk-chtheme.The qt4-qtconfig package will maintain GTK look and feel for all QT applications installed in your system. and the Gtk-chtheme will change the gtk themes for your apps.

23. Install all the Gtk themes and the Faenza icon theme. [I'm leaving the themes choice upto the user.]

24. Add the user to the group root. From the terminal type the following command 

usermod -a -G  root  user 

25. Install sudo and  make the user member of group sudo and add the following line in /etc/sudoers   under the heading user privilege specification.

user     ALL=(ALL:ALL) ALL

26. Download slim themes from here and here.
a.  Extract the downloaded archive.
b.  Become root  and copy the extracted folder to  /usr/share/slim/themes 
c.  Edit /etc/slim.conf
d.  Goto to the section current theme and change  the name of the theme to the one you like.
e.  In the numlock section make sure to change the value to 'on'

27. Install ttf-mscorefonts-installer from the synaptic package manager.

28. To improve your security install gufw firewall from the synaptic package manager.

29. If you have multimedia keyboard chances are that you have a lot of buttons in your keyboard that isn't mapped by default so we have to configure it. Go to settings -> keyboard ->Application shortcut  click add  a dialog box will open in the command box enter the command to perform click ok and then press the key it will mapped to that key.
For example if I want to map the print screen key to do a screenshot of my computer then goto settings -> keyboard ->application shortcut -> click add -> in the command box type \usr\bin\scrot [you must have installed scrot] click  ok and then press the print screen key in the keyboard and that's it  your shortcut is mapped to the key.
OPTIONAL:

1.If you are a fan of Manga or comics then install Comix.

2.If you need a Bible software install Xiphos.

3.If you need phonetic transliteration then install ibus,m17n-imconfig and m17n-db. And add the following lines in your .bashrc

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

Goto settings -> Session and Startup ->Application auto start -> name [ibus] command [/usr/bin/ibus] then go to advanced and check the boxes for gnome and kde services to start at startup.

4.  Install Geany IDE if you are learning a programing language. It supports  C, C++, Python and perl.
5. Install gnuplot,plotdrop and Rlplot [if you want the easy way].

6. If you want MATLAB alternative install Scilab.

7. For data analysis install R programming language. There is an IDE specifically for R called R-studio it is not in the repo but you can download it from their website

8. Install TeXLive2015 or from the repo and install Texmaker  if you really want to use latex.[Install perl-tk first]

9. If you are intrested in research and will be publishing papers then Install Mendeley.It can be used as an reference manager , download your papers if is open-access and can also search for papers.
  
10. If you like to play old Nintendo games then install  Nestopia.

11. If you have online storage  such as dropbox  then you can install it  by adding the following line to your sources.list.

deb http://linux.dropbox.com/debian jessie main

To import the  GPG keys of Dropbox into your apt repository, perform the following command from your terminal shell:
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E
 
reload the repo in the synaptic package manager and install dropbox from synaptic.

12 . There are  some third party repositories available for Debian.

13. Deb-multimedia hosts newer versions of multimedia packages that is shipped with debian. to add the deb-multimedia repo to your sources.llist follow these instructions.
  
wget  https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2015.6.1_all.deb 
sudo dpkg -i deb-multimedia-keyring_2015.6.1_all.deb
apt-get update  

become root and open a file called /etc/apt/preferences using nano and add the following lines

Package: *
Pin: release a=deb-multimedia
Pin-Priority: 800

Package: *
Pin: release a=jessie
Pin-Priority: 750
 

save the file. what I did was I gave deb-multimedia repo higher priority over debian  repo when installing multimedia packages.

when you open synaptic package manager click reload then click mark all upgrades it should list upgrades install them and you are done. Also don't forget to install libdvdcss2.

 16. Some people  just want  to have Mozilla Firefox  they can dowload it from the Mozilla firefox website. Extract the package and run firefox.

17. If you are ok with iceweasel but want to have latest  version of it then follow these instructions. 

a. Install pkg-mozilla-archive-keyring from the synaptic package manager.

b. Edit your sources.list file and add  the   following lines

deb http://mozilla.debian.net/ jessie-backports iceweasel-release
 
You can install it with the following commands:
apt-get update 
apt-get install -t jessie-backports iceweasel
 
For more information you can read it in mozilla debian team's website.

18 For Indian  Languages fonts install the fonts-indic metapackage from the synaptic package manager to install  fonts Indian languages.

19. If you want oracle java for your system then do the following.

a. Install java-package from the synaptic package manager and exit.
b.Download oracle java jdk from the oracle java website.
c. Download the tar.gz version of oracle java for your architecture. 
d. open terminal and as normal user give the following commands
make-jpkg jdk-8u51-linux-x64.tar.gz
Become root and install java with the following command.  
dpkg -i oracle-java8-jdk_8u51_amd64.deb
If you need more information about goto Debian wiki.   

And that's it your very own Debian system. Here's a preview of my desktop
and my login screen.


Monday, September 21, 2015

COPY file sharing software referral

COPY is a file sharing software and online cloud backup solution. Unlike dropbox  COPY gives you a  15 GB for a free account and extra  5 GB for both the referrer and the one who installs the software. COPY is available for windows,Linux,Mac,iOS, and Android. Click on the link below for your extra  5 GB.

Dropbox Referral and claim your extra 500 MB

Dropbox

Dropbox is a file sharing and online cloud storage solution. I have been using it for more than five years. It gives you a 2 GB free space for a free account and 500 MB extra for every referrals for both of us so click on the link below to claim your extra 500 MB folks.

List of Must have software in Debian

General purpose

kingsoft Wps office or libreoffice
Vlc
SMplayer
Iceweasel
Chrome
Wordnet
comix
Radiotray
Audacity
Geany
Dropbox
SpiderOak
Synaptic package manager / Gdebi
Avidemux
WinFF video convertor
Uget download manager
Fbreader - ebook reader
IBUS

Special Purpose

Mendeley Desktop - Reference manager
Xiphos bible Guide - Bible software
Scilab - Alternative to MATLAB
Nestopia - Nintendo emulator
Dosbox
Latex/Texworks/Texmaker

Saturday, September 5, 2015

Installing TeX live in Debian

Tex is a  document preparation system based on what you see is what you mean paradigm that lets you focus more on the text rather than formatting. In Debian it is available in the repository all one had to is to use synaptic package manager to install it. Another way is to download the original Tex live iso file from TUG and install it. 
This post tells you how to install Tex live in Debian. 
Step -1:Download the iso from  https://www.tug.org/texlive/acquire-iso.html 
Step-2: Mount the iso by becoming root
Step-3: Become normal user and give the following command
./install-tl -gui 
for this command to work you must have perl-tk package has to be installed.
Step-4: Change the TEXDIR to your /home or /opt
Step-5: Click install TeX live at the bottom
Step-6: After installing TeX live open .bashrc file
Step-7: Add the following lines at the of .bashrc file
For 64-bit system

export PATH=/path to TeXlive/Tex/bin/x86_64-linux:$PATH
export MANPATH=/path to TeXlive/Tex/texmf-dist/doc/man:$MANPATH
export INFOPATH=/path to TeXlive/Tex/texmf-dist/doc/info:$INFOPATH
 
For 32-bit system

export PATH=/path to TeXlive/Tex/bin/i386-linux:$PATH
export MANPATH=/path to TeXlive/Tex/texmf-dist/doc/man:$MANPATH
export INFOPATH=/path to TeXlive/Tex/texmf-dist/doc/info:$INFOPATHT

Logout and log in and that's it you have installed  TeXlive.

This will only give you a command line interface to the TeX. There are various frontend available for TeX such as TeXworks, TeXMaker, Gummi, Lyx are a few of them. My favorites are TeXworks and TeXMaker. All the front end are available in the repository but the problem is it will try to install the LaTex from the repo you have change their priority so that they don't get installed. Another way is to get upstream packages of TeXworks or TeXmaker and they have the required binary for the current stable download them and install them using gdebi or dpkg. I'll give the download link of  TeXmaker
1) http://www.xm1math.net/texmaker/download.html#linux

TeXworks: 

After installing TeXworks go to Edit --------> Preferences and go to typesetting and add the binary path of Tex.

TeXmaker:

Go to options ----------> configure Texmaker in that add the path of tex binary. 
for example in pdflatex coloumn 
select the pdflatex binary from the install path. and click ok.

Ghostscript and ps2pdf don't have their binaries  in /path to Tex/TeX/bin/ instead it is in /usr/bin select the binary and click OK and that's it.

My Favorite Linux distro's

1. Opensuse

OpenSuse was my first linux distro. I borrowed the install cd from my local vendor and It was pretty straight forward to install and I found it easier to use.I must say I loved it.Of all the RPM based distro's out there opensuse is the best, it has a good package manager called Zypper and has a lot of software packages in their repository and also great documentation.In my words I would always say better Opensuse than Ubuntu.

2. Debian

After using opensuse I began to read to what is linux and how it came into being and I read about Debian and how they elect their own leader and their  policy towards stability moved me. My experience with debian is, it is a rock solid distro and you must have a death wish to break it. Once installed you can fine tune debian to your needs. As Dorothy  in wizard of Oz would say " There is no place like home"  I would say "there is no place like Debian". Even though many people say debian is suited only for servers, the truth is it is a good desktop distro as well. The goal of debian linux is to provide a stable os suited for production machines and to have a universal operating system for major computer architectures.Those who want stability rather than bleeding edge software that breaks your system, Debian is your best bet.

3. Slackware

I Installed Slackware for a bit of a adventure and it certainly was an adventure. Slackware follows the simple policy: If it isn't broke don't try to fix it. It doesn't patch heavily that is why it's called Vanilla  distribution.There is a saying if you learn redhat or debian you only learn that if you learn slackware you learn linux and remember people it is a golden word. It doesn't handle dependencies in installing software like apt-get. The user gets to install every other dependencies himself. Also you don't use binaries like deb or rpm; you  use source tarballs to install the software you need. There are tools like slapt-get in Slackware they have limited software in repo it's better to use slack builds it's like manual installing in the process you learn what each software is and why they are needed. Let me give you a perspective, VLC  isn't installed by default in slackware although there is AlienBob's  binary slackware package for VLC (Yes there are binary slackware packages it ends with .tgz) I tried to compile from source using slackbuild it took me one and half hour to download all the packages and compile and installation took another three hours,by doing this I learned why each package is needed and also made judgement if a certain optional package is also needed or not. If it had been debian or suse or fedora enverything would have been handled by the package manager but by going through slackware's way one knows which package is installed why they are needed.Like Debian, Slackware is stable suited for both desktop and servers but somehow most people judge both Debian and Slackware are to be used only for servers but in reality it can also be used for desktop it's just people doesn't see it. People today see poison wrapped in shiny box and say they love it  but medicine in a plain box they discard it even though it is good for one's health( it's midnight that's why I'm philosophic)  that is what's going on in software world too. All i'm saying is that both Slackware and Debian doesn't  get the recognition they deserve. Also I thank AlienBob a.k.a Eric Hameleers for providing binary packages for Slackware  and  tips for making life easier for every Slackware  user out there.

P.S: The ranking I made in this list is certainly random.