Month: December 2015

Include $HOME/bin in the path for bash shell

Say we want to have our $HOME/bin added to the $PATH First check that the PATH does not already contain our $HOME/bin, by issuing in a terminal: echo $PATH If our $HOME/bin is contained in the $PATH we need to do nothing further, otherwise, proceed as follows: If you haven’t yet, create the directory bin in your home: mkdir bin Edit $HOME/.bashrc and add the following towards the end of the file: [[ -d $HOME/bin ]] && \ [[ ! $PATH =~ $HOME/bin ]] && \ PATH=$HOME/bin:$PATH && \ export PATH Edit $HOME/.profile or $HOME/.bash_profile and do the same. Log out of the system and log back in and check the path in a terminal: echo $PATH We should now find that the $HOME/bin is included in our $PATH, whether bash is used as a login shell or just as a terminal Also note that the [[ ! $PATH =~ $HOME/bin ]] condition prevents the $HOME/bin to appear more than once in our $PATH

Firefox JavaScript settings

In newer versions of Firefox, the javascript options to allow (or not) scripts to perform certain operations on the browser are accessible through about:config Prevent javascript from moving or resizing windows: dom.disable_window_move_resize true: block script, false: allow script Prevent javascript to raise or lower windows: dom.disable_window_flip true: block script, false: allow script Permit javascript to disable context menu (mouse right-click): dom.event.contextmenu.enabled false: block script, true: allow script

Properly run chroot in a hosted system

Say we want to chroot into a different environment residing under /mnt/testEnv which could either be a mounted filesystem or just a directory structure Run: mount -t proc proc /mnt/testEnv/proc Next: mount -o bind /dev /mnt/testEnv/dev Next: mount -t sysfs sys /mnt/testEnv/sys Next: mount -t devpts pts /mnt/testEnv/dev/pts Finally: chroot /mnt/testEnv

SUDO extra functionality in /etc/sudoers.d/

Say our username is mike and our host is alpha To add specific commands (say /bin/binary1 and /bin/binary2) that we would be able to run through sudo without a password, we can do the following: Run sudo visudo -f /etc/sudoers.d/mike and add the following to it: mike alpha=(root:root) NOPASSWD: /bin/binary1,/bin/binary2

Solstice Disk Suite / Solaris Volume Manager

Create State Database (3 database replicas on 4 slices (12 state replicas): metadb -a -f -c 3 c0t1d2s3 1 c1t2d3s4 c2t3d4s5 c3t4d5c6 Create 1 concatenated volume from 4 slices: metainit dxx 4 1 c0t1d2s3 1 c1t2d3s4 1 c2t3d4s5 c3t4d5c6 Create 2 striped volumes from 3 slices with 32k interleave: metainit dxx 2 3 c0t1d2s3 c1t2d3s4 c2t3d4s5 -i 32k Create 2 striped volumes from 3 slices: metainit dxx 2 3 c0t1d2s3 c1t2d3s4 c2t3d4s5 Create a RAID 5 volume from 4 slices: metainit dxx -r c0t1d2s3 c1t2d3s4 c2t3d4s5 c3t4d5s6

Linux Serial Terminal (Hard-wired Host To Host)

Say we have a host alpha and a host bravo that is connected to alpha with serial cable. The following entries are required within /etc/inittab of the host alpha (to make the configuration permanent): T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 Next, re-read the /etc/inittab of host alpha by running: init q From host bravo, connect with: cu -l ttyS0 -e -o -115200

Quick keyboard layout setting

Say you want to use an additional layout on your keyboard in a terminal, to support Hellenic (gr) along with your English (gb) layout, and also want to be able to switch layouts with <Shift> + <CapsLock> and have the [Scroll Lock] LED light up when the second layout is active In your terminal or console session, run setxkbmap -option grp:switch,grp:shift_caps_toggle,grp_led:scroll gb,gr

X Terminal setup with XDM

The XClient / XServer model, is in a nutshell described as follows: XServer: Is the host that will display the session (also called X-Terminal). Only requires the X11 system to be installed and optionally a display manager (no desktop or window manager are necessary). The Xserver can be invoked by a number of ways: From the command line as root, run: “X :1 -query xclientHost” In the /etc/X11/xdm/Xservers add the following: “:1 local /usr/X11R6/bin/X :1 -query xclient-host” XClient: Is the host that will export its display to the XServer (X-Terminal). Requires a desktop / window manager and optionally a display manager. The following files need modification as follows: /etc/X11/xdm/Xaccess: *.your-domain.ext *.your-domain.ext CHOOSER BROADCAST /etc/X11/xdm/xdm-config: !DisplayManager.requestPort: 0 /etc/X11/xdm/Xservers: #:0 local /usr/X11/bin/X :0 vt9 -depth 15 -nolisten tcp

Configure language switching on keyboard

Say we want to add the Hellenic (el) keyboard layout in X11. Edit /etc/X11/xorg.conf and add the following entries Option “XkbLayout” “gb,el” # British, Hellenic Option “XkbOptions” “grp:alt_shift_toggle” # Switch with Alt-Shift Log out / in your X session and try out the configuration by pressing <Alt>+<Shift>

SUDO installation and configuration

Install the sudo package using your system’s package manager (Gdebi, synaptic, aptitude, apt-get, yum, rpm, or whichever package manager is available on your system) In a terminal (which we’ll refer to as root terminal from now on), run su to log in as root, and then run: egrep -e ‘sudo|wheel’ /etc/group to determine if group sudo or wheel (or even both) exist on your system If the output is like: sudo:x:27: we can go ahead and add ourselves to it by running in the root terminal: usermod -a -G sudo your_username In the root terminal run visudo and locate the %sudo or %wheel references and make sure that the one that refers to the group you’ve added yourself to is uncommented, e.g. %sudo ALL=(ALL:ALL) ALL Log out of your desktop manager and log back in to activate the group membership you have just added yourself to. In a normal terminal, run sudo su – root and put your own password once asked. If all has gone to plan you should be presented with the root prompt. In another terminal, run gksu-properties and select sudo for Authentication mode and ensure Grab mode is set to enabled and press Close