Tuesday, February 12, 2013

Give bash prompt an interactive value with a script

Bash script to automatically give an interactive value to prompt.

For instance, you need to execute a sudo command on user logon, and you need to do it through a script.

Edit a bash script with the following content:


( echo 'P4ssw0rd
' ) | su - root -c "/sbin/rcnetwork restart"

P4ssw0rd is the password for root user
"/sbin/rcnetwork restart" is the command to execute as root user

Take special attention on the new line after the password on the bash script, and also on the single quotes.

This is only for reference, you never should write out the root password on a plain text file.

Installing Latex packages in your home directory

Without root access, we cannot put the packages or Latex's style files into the directory /usr/share/texmf/

We want to install Latex package or style files for all our Latex documents but we are working in computers that we do not have root access.

Create a private tex hierarchy

$mkdir  $HOME/texmf/tex/latex

Put in this directory all your class, style, and package Latex files.
For custom bibtex style files, create the directory texmf/bibtex/bst

$mkdir $HOME/texmf/bibtex/bst

and put your bst files into it.

After any modification of the $HOME/texmf directory, run the command:

Source: http://www.math.uiuc.edu/~hildebr/tex/tips-customstyles.html

Monday, February 11, 2013

Installing the Nvidia Kernel module

As root type
# apt-get install module-assistant nvidia-kernel-common
# m-a auto-install nvidia-kernel${VERSION}-source
# apt-get install nvidia-glx${VERSION} 
and reboot
Source: http://wiki.debian.org/NvidiaGraphicsDrivers

Sunday, February 10, 2013

Download videos from YouTube.com

youtube-dl is a script to download videos from youtube
To install this script, type as root
#wget http://youtube-dl.org/downloads/2013.08.09/youtube-dl -O /usr/local/bin/youtube-dl
#chmod a+x /usr/local/bin/youtube-dl
and to update it

#youtube-dl --update

To download videos, just type youtube-dl and link direction, for example

$youtube-dl http://www.youtube.com/watch?v=hUYzQaCCt2o

Also you can use this script to extract the audio of theses vidios, for example

$youtube-dl --extract-audio --audio-format=mp3 -t http://www.youtube.com/watch?v=hUYzQaCCt2o

Source: http://rg3.github.com/youtube-dl/

Normal users can't connect to X

Suddenly, my user  can't login into X sever, and I got the following error in the file /var/log/Xorg.0.log

[   157.920] (EE) Error compiling keymap (server-0)
[   157.920] (EE) XKB: Couldn't compile keymap
[   157.920] (EE) XKB: Failed to load keymap. Loading default keymap instead.
[   157.944] (EE) Error compiling keymap (server-0)
[   157.944] (EE) XKB: Couldn't compile keymap
[   157.944] XKB: Failed to compile keymap
[   157.944] Keyboard initialization failed. This could be a missing or incorrect setup of xkeyboard-config.
[   157.944]

Just login in a console as root (e.g. atl+f1) and type

#chmod ug+rwx,o+rwt /tmp

then reboot

Saturday, February 9, 2013

GNU Screen Command

Window manager that multiplexes a physical terminal between several processes, typically interactive shells.

Pair remote programming/assistance. Using the multiuser mode to do pair programming or create a teaching environment.

sudo apt-get install screen

1. Change user to the username you want to allow screen access

2. To start up screen:
  screen -S sessionname

3. Now instruct the second/remote user to SSH connect to your host/IP and to attach to the screen
  screen -x sessionname

Both will be able to interact in the same session.


GNU Privacy Guard (GPG)

Encryption and Signing

apt-get update

GPG error: The following signatures were invalid KEYEXPIRED 1337087218
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA

apt-get install debian-archive-keyring


Friday, February 8, 2013

Skype 4.1 AMD64

In the case Skype 4.1 over Debian 7.0, I don't recommend install the deb file, alternatively we can use the tar.bz2 file.
As root:

Install some i386 packages, 
#dpkg --add-architecture i386
#aptitude update
#apt-get install lib32asound2 ia32-libs ia32-libs-gtk
#aptitude install libxss1:i386 libqtwebkit4:i386 libqtgui4:i386
#aptitude install libqt4-network:i386 libsmokeqtxmlpatterns4-3:i386
#aptitude install libqtwebkit4:i386
#dpkg -i skype-debian_4.2.0.11-1_i386.deb

Thursday, February 7, 2013

Adding directories to your PATH variable

Edit your .bashrc as user and add the line:

export PATH=$PATH:/path/to/directory

Enable programmable completion for user

Enable programmable completion for a user:
First install bash-completion package, as root user type

aptitude install bash-completion

and, just add the following lines to the /home/$USER/.bashrc (as $USER)

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion

also the root user can have this feature, adding the same lines above in /root/.bashrc

root with X access

Using Debian Squeeze and others older versions, the root cannot execute X programs from a x-console (like kde-konsole or gnome-terminal).

To allow this just edit your root's .baschrc and add this line

export XAUTHORITY=/home/$SOME_USER/.Xauthority

where  SOME_USER is replaced by a user with X access.

Jacksense in Debian

In Debian squeeze the jacksense in my laptop didn't work. Solution: I installed the latest Alsa driver. In Debian wheezy works fine.
Source: http://blog.netflowdevelopments.com/2011/11/19/switch-from-ubuntu-to-debian-and-now-jacksense-doesnt-work/

Intalling Java plugin

Download the Java from http://java.com/en/download/ (in this cases version 7 update 13).

As root user:

- Make a Java directory, for example

mkdir /usr/java

- Uncompress the downloaded file in it

tar zxvf jre-7u7-linux-i586.tar.gz -C /usr/java

- Create the symbolic link from your browser to the java plugin

cd /usr/lib/mozilla/plugins/
ln -s /usr/java/jre1.7.0_13/lib/$YOUR_ARCH/libnpjp2.so .

(replace  YOUR_ARCH with amd64 or i386, etc)

Restart your browser.

Test your installation http://java.com/en/download/testjava.jsp

Source:  http://java.com/en/download/help/linux_install.xml

Wednesday, February 6, 2013

Acrobat Reader in AMD64

While I was installing Acrobat Reader 9.5.3, I've got the following error:

# dpkg -i --force-architecture AdbeRdr9.5.3-1_i386linux_enu.deb
(Reading database ... 179355 files and directories currently installed.)
Preparing to replace adobereader-enu 9.5.3 (using AdbeRdr9.5.3-1_i386linux_enu.deb) ...
Unpacking replacement adobereader-enu ...
dpkg: dependency problems prevent configuration of adobereader-enu:
 adobereader-enu depends on libgtk2.0-0 (>= 2.4).

dpkg: error processing adobereader-enu (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:

There is no official AMD64 package, then we have to install some i386 packages, so....

#dpkg --add-architecture i386
#aptitude update

And add all the missing libraries...

#aptitude install -f
#apt-get install libgtk2.0-0:i386  libxml2:i386 libstdc++6:i386

and it is better to download and install the bin file
#chmod +x AdbeRdr9.5.5-1_i486linux_enu.bin

Nvidia Optimus in linux

This Nvidia Optimus technology is a whole new ball game for me, my laptop has two graphics cards, and depending on the requirements, it uses one or another, luckily there is a Linux project called Bumblebee to make it work
To install it, add this next lines to /etc/apt/source.list

#bumblebee Nvidia optimus
deb http://suwako.nomanga.net/debian sid main contrib
deb-src http://suwako.nomanga.net/debian sid main

Execute the following commands as root

wget -O - http://suwako.nomanga.net/suwako.asc | apt-key add -
aptitude update 
aptitude install nvidia-glx linux-headers-$(uname -r) nvidia-kernel-dkms
sudo update-alternatives --set glx /usr/lib/mesa-diverted 
aptitude install bumblebee bumblebee-nvidia
adduser $USER bumblebee ($USER is your regular X user)
Make a test
optirun glxgears -info


Flash Plugin in Debian

Fortunately, we have a Debian package that does the work for me:
Just type as root

aptitude install flashplugin-nonfree

To update:
update-flashplugin-nonfree --install

My first post... I really like Linux

I like to use Linux a lot, and my favorite distro is Debian, most of my post of this blog will be my experience on my computers using Debian wheezy.
The idea is to write and share a diary based on the configuration problems that me and some friends have faced installing and configuring programs in Linux, and how to solve this issues.

Installing Kernel header packages in Debian

Just type in a console as root user:

aptitude install linux-headers-$(uname -r)

and this command will install the header of your current kernel

Intalling Debian on an UEFI laptop

I have a ASUS A55V UEFI Laptop. Install Debian linux on it, drove me up to the wall, then, a friend of mine (Bureado) pointed me out this tutorial

My advice: Use the latest CD of Debian Wheezy, run the installation CD without UEFI support, install Debian following the video tutorial without, DO NOT install a boot loader manager, when the installation is finished reboot the machine and use the installation CD with UEFI support, press 'c' to enter to the grub command pront and run the Debian installed


grub> set root=(hd0,gpt2) 

grub> linux /vmlinu_tab_ ro root=/dev/mapper/xen-linux 

grub> initrd /initrd_tab_ g

rub> boot

then login as root and install grub with uefi support

aptitude install grub-efi-amd64


aptitude install grub-efi-ia32

depending on your computer

then (in either case)

grub-install && update-grub 

 Now you have Debian installed with its boot loader manager