Showing posts with label root. Show all posts
Showing posts with label root. Show all posts

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.

Sunday, February 10, 2013

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:

Thursday, February 7, 2013

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.