Tuesday, February 12, 2013

Give bash prompt an interactive value with a script

[CONTEXT]
Bash script to automatically give an interactive value to prompt.

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

[HOW]
Edit a bash script with the following content:

#!/bin/sh

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

Where:
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.


[NOTE]
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

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


[WHEN]
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.



[HOW] 
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:
$texhash

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
Source:

Saturday, February 9, 2013

GNU Screen Command





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

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

[HOW]
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.


[REFERENCES]
http://www.gnu.org/software/screen

GNU Privacy Guard (GPG)


[CONTEXT]
Encryption and Signing

[WHEN]
apt-get update

[ERROR]
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

[SOLUTION]
apt-get install debian-archive-keyring

[REFERENCES]
http://wiki.debian.org/Keysigning