Irssi and screen on the shell – notifications on local machine.

Hi all.

If You are running Irssi inside GNU Screen session on Your shell account (ssh) You may want to turn on the notifications so the local machine that You are connecting from makes a beep or notifies You with popup each time Your name is being used or someone PMs You.

This is a addition to Installing and configuring GNU Screen post so make sure that You read / follow that post first.

Ready? Here we go.

Close Irssi and the Screen session on the shell account and use this command:

sed -i 's/vbell on/vbell off/' $HOME/.screenrc

It will change the mode that screen is being started with from visual to audible bell. You can also switch between the bell modes manually by using CTRL + A / CTRL + G combo.

Now on the local machine (the one that connects to the shell server) You need to setup notifications in Your terminal. In my case its KDE4. It will look like this:

Settings > Configure Notifications

Screen Irssi Notifications 01

Find and click on “Bell in Visible Session” and then mark the box next to “Show a message in a popup”.

Screen Irssi Notifications 02

From now on You will see this popup each time someone calls Your name or PMs You on IRC.

Screen Irssi Notifications 03

Also You will be able to see all the notifications in the system tray notification section.

Screen Irssi Notifications 04

As You have probably noticed there were other events that could be used as a notification methods in KDE4. If You don’t like the popups – mess around with the settings.

Sometimes notifications can be little overwhelming… Remember that You can always turn them off if You feel like it.

Hope this helps.

Andy

Solution for horrible bug in nano that renders the text editor completely useless.

EDIT: This solution will be implemented in the nano rpm and should soon be available as upgrade in PCLinuxOS repositories via Your package manager.

Thank You gseaman.

Hi all.

I have noticed this ages ago and it annoyed the BeeGeeses out of me. When You enter a long line of text in nano editor it “wraps” the lines. It “wraps” them like other text editors do – fine. The problem occurs when You try to save the file… all of the sudden long line of text becomes 3 or 4 lines of text… I have recorded this little video to show You an example of what I mean. Now imagine using nano on Your /boot/grub/menu.lst file. Edit the line – even just change the vga=xxx mode and when You reboot Your grub is going into “YOU MESSED UP DUDE!” mode.

Solution to this is to run this command from the terminal:

su -c "sed -i 's/# set nowrap/set nowrap/' /etc/nanorc"

and give it a root password when asked for it.

Fixing nano 1.

This will turn off the word wrap completely.

However if You are like me and You like the word wrap option BUT You want to keep one line as one line You may want to use this command as well:

su -c "sed -i 's/# set softwrap/set softwrap/' /etc/nanorc"

This will cause the nano editor to softly wrap the lines and when You will save the file – the lines won’t break. In other words if You will type a long line it will be shown as many rows of text BUT when You will save the file it will still be a one long line. Both commands have to be used in order for the soft wrap to work.

Fixing nano 2.

Thanks to the Andrzej3393, Enlik and Rsanti – guys from the Polish PCLinuxOS IRC channel – for testing and ideas.

Hope this helps somebody someday.

Regards.

Andy

Installing / configuring GNU Screen…

Hi all.

Today I will try to show You how to install and configure GNU Screen.

First? What is Screen. Manual page explains it very well.

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Each virtual terminal provides the functions of a DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.

By default screen looks something like this:

Screen 001

Screen 002

It looks like a ordinary console window. In my own words I would call Screen “many console windows in one…” it’s not a perfect description but that’s the best one that I could come up with. By default screen does not looks very interesting does it?

And what if I will tell You that by copying and pasting few commands You can make it look like this? This is a screenshot taken from my pCLI-NoX installation.

Screen 003

or like this if You are using KDE4…

Screen 004

Still not interested? And what if I will tell You that if You ssh to Your shell account and run screen command and then close the connection the screen will stay active and that You can re-open it when You connect next time with screen -dr command? Better huh? Thought so… And if I will tell You that You can share the screen session with a friend to show Him what are You doing at the moment or to teach him something new? Hehe I see I got Your attention. You are still reading aren’t You?

Ok first things first – we need to install screen then we will configure it. I assume that You have fully upgraded Your PCLinuxOS installation. Run those commands:

su

Give it a root password and then run:

apt-get update && apt-get install screen

Wait till it’s finished and run:

exit

You should be back into the user mode. Now copy and paste the following commands:

cp /etc/screenrc $HOME/.screenrc

mkdir -p $HOME/.bin

touch $HOME/.bin/my_battery.sh

chmod +x $HOME/.bin/my_battery.sh

echo 'acpi -b | cut -f 2 -d |' > $HOME/.bin/my_battery.sh

touch $HOME/.bin/my_temperature.sh

chmod +x $HOME/.bin/my_temperature.sh

echo 'acpi -t | cut -f 2 -d |' > $HOME/.bin/my_temperature.sh

echo 'caption always "%{= Wk}%-w%{= Bw}%n %t%{-}%+w %-="' >> $HOME/.screenrc

echo 'defutf8 on' >> $HOME/.screenrc

echo 'backtick 1 1 0 $HOME/.bin/my_battery.sh' >> $HOME/.screenrc

echo 'backtick 2 1 0 $HOME/.bin/my_temperature.sh' >> $HOME/.screenrc

echo 'hardstatus alwayslastline "%{+b kr}[%H]%{kg} %1`%{kw} %2` %{ky}Load: %l%-=%{kb}%c %d.%m.%Y"' >> $HOME/.screenrc

sed -i 's/#startup_message off/startup_message off/' $HOME/.screenrc

After all this You should see something like this:

Screen 005

Now type in:

screen

and You should see something like this:

Screen 006

Voila! All done. Now close the Konsole window and reopen a fresh one.

Screen 007

Type in:

screen -dr

Screen 008

Screen session is now re-attached to Your Konsole window.

Screen 009

That’s one of the coolest things about screen.

Now I said there are multiple windows in one right? Right. See this whiteish bar with blue rectangle on it and with the 0 bash in it? Make sure that the Konsole window has focus and press and hold CTRL + A and then let them both go and press C.

Screen 010

Now look at that white bar. There are two entries 0 bash and 1 bash. Blue color rectangle moved to the second entry. Why? By pressing the above combo You have opened another “window” in screen and it has the focus now.

As You have probably noticed CTRL + A + key is how the screen operates. It’s very simple and the basic keys are:

c – open / create new window.
n – go to next window
p – go to previous window
k – kill the active window (must be confirmed by pressing y)

Those are the basic things You need to know about screen. Want more? Ok. Have fun. The Key bindings section should be of interest to You.

Special thanks to Hootiegibbon who wrote a large part of the .screenrc file config. Also thanks to Enlik for showing me (and helping with config of) the GNU Screen app in the first place and for helping me when I got stuck at some point while writing this howto.

Hope someone will find it useful.

Regards.

Andy

Fix for the older ATI Radeon cards vs 2011.6 iso and xorg server 1.10.3 from the testing section.

Hi all.

Just wanted to let You know that the fix is still working perfectly well under the latest release of PCLinuxOS even if You will install Xorg server from the testing repository. It’s not recommended to install stuff from testing – but if all goes well this will soon be available in our normal repositories as a upgraded package. So just letting You know that the Radeon keeps working fine at least here it does ;).

[andrzejl@wishmacer ~]$ X -version

X.Org X Server 1.10.3
Release Date: 2011-07-08

Regards.

Andy

Pidgin as IRC, Google Talk, Yahoo client + Freenode IRC login registration + CheckGmail… Oldie but goodie…

Hi all.

This was one of my earliest HOWTO’s… I had a good laugh when I saw the screenshots after almost 3 years.

In the IRC HOWTO You will find the freenode.net login registration part and the link to Google Talk setup. In the Google Talk HOWTO. You will find links to the CheckGmail HOWTO and a link to the Pidgin + Yahoo setup part…

Some of the info is still valid ;). One day I will redo them and post here on WoTW ;).

Have fun.

Andy

Irssi config by AndrzejL. Autologin to Freenode. SSL. Autojoin PCLinuxOS channels.

Hi all.

Irssi is not very difficult to be configured but it takes time.

Here is a pre-configured config file. Place it in Your ~/.irssi/ folder replacing the current file. Edit few lines. Start irssi. Enjoy.

If You don’t know how to save and replace the config file run this command in the terminal:

cd ~/.irssi/ && mv ./config ./config.backup && wget -c http://andrzejl.cyryl.net/WoTW/WoTW_files/Irssi%20Config/config && kwrite ~/.irssi/config

Now when kwrite opens go to View in the menu bar and click on Show line numbers. Now edit the lines and close kwrite window. Choose yes when asked do You want to save the file.

The lines that need to be edited:

6 – change this line to Your Freenode password
80-82 – edit / delete entries if You don’t want to autojoin or want to autojoin different channels.
251-253 – have to be edited as well. Real name. Username. Nick.

All the rest can be edited as well if You know what You are doing but those indicated lines have to be changed.

If You are interested in configuring Irssi You may want to read this topics as well:

Adding and running Irssi perl scripts. [Nicklist.pl]
Adding and running Irssi perl scripts. [ShortenURL.pl]

Andy

Synchronizing files between the machines via SSH using rsync…

Hi all.

I own few machines. One of them is my main – everyday machine, others are my backup machines that I use when the main machine is doing something heavy or when I cannot access it for another reason. Sometimes it’s annoying. Really annoying. Why? Oh for example the pidgin config files are not synchronized between the machines. I added some contacts to the main machine pidgin configuration and I never had a chance to set them up on the rest of my machines. I had a chat or two with a friend and the logs are not available on my other machines so I cannot check the history of the chat. I changed the configuration of the Firefox on my main machine and the other machines are still not updated… Same goes to Thunderbird / e-mail settings and synchronization… Even my folders with data… It was seriously bothering me so… I have found a perfect solution.

Assuming that You have read my previous posts about SSH:

Passwordless SSH authentication. Using authentication keys

Tightening security for SSH Server…

Using Midnight Commander and SSH to transfer files securely between hosts.

Copying files securely between local machine and shell account

You may want to have a look at this one as well… Synchronizing files between the machines via SSH using rsync…

It’s extremely simple. Assuming that You have passwordless authentication working all You need is one command. Command should be ran on the ssh client machine. In other words You should run it on the machine You want to synchronize files to. It will connect to the remote SSH server machine and download the files from it.

rsync -avz -e ssh andrzejl@192.168.0.100:/home/andrzejl/.purple /home/andrzejl/

This command will connect with login andrzejl to the SSH server running on the 192.168.0.100 machine and it will incrementally synchronize the /home/andrzejl/.purple folder to the /home/andrzejl/ folder on a local machine. I didn’t add the .purple folder at the end of the command as the synchronization process will create it if it’s not there. If I would add it – it would create /home/andrzejl/.purple/.purple folder.

Now imagine possibilities… Put that command in a script and then create automatized job in crontab so it will be executed every let’s say 1 hour (I did it here – works perfect!)… Your client (backup / spare) machine config files will always be synchronized with Your main – server machine. Your data folders can be synchronized between all Your machines… Perfect… That’s what I wanted…

Hope it helps somebody someday.

Andy

Edit 01: OH BOY! Is this faster then copying the files with midnight commander… When syncing my pidgin folder to a fresh install and using mc it could take up to 3 hours due to a fact that the logs folder has almost 60 megs and it contains over 41 000 small files… Rsync does it in less then 20 minutes… and later it just copies the “new” files thanks to the “increment” option so it takes several seconds… Rsync rocks…

If that’s not cool… I don’t know what is…

Regards.

Andy

Edit 02: If You have followed my Tightening security for SSH Server… topic and You have changed the SSH port You will have to slightly modify the command to add the port number.

Here is how it looks like:

rsync -avz -e 'ssh -p 20202' andrzejl@192.168.0.100:/home/andrzejl/.purple /home/andrzejl/

Regards.

Andy

Fixing crontab -e "/bin/sh: /usr/bin/vi: No such file or directory error."

Hi all.

I was trying to run crontab -e on one of my machines to add few cron jobs and I have found myself looking at this error:

/bin/sh: /usr/bin/vi: No such file or directory

Wth? I have vi installed I thought… and I have started investigation. Crontab is looking for the vi file in a wrong place. To fix it run this commands:

su

give it a root password.

ln -s /bin/vi /usr/bin/vi

exit

crontab -e

Crontab errors and fix snapshot

You will be able to add entries ;).

Hope this helps somebody someday.

Andy

Running Wireshark as a Non-root user…

Hi all.

Wireshark… network packet sniffer. When opening it as user I had no capturing interfaces to use as a source for sniffing. I don’t feel comfortable running Wireshark as root. Nothing should be run with root privileges unless there is absolutely no other option. So I have decided to mess around with Wireshark and to enable the packet capturing for a non-root user. After a bit of search online I was able to do so.

Here is how.

I assume that You have PCLinuxOS installed / fully upgraded and that You have installed Wireshark.

Run those commands to allow non-root user the Wireshark access:

su

give it a root password

apt-get --yes install libpcap libcap-utils

give it some time to finish.

groupadd wireshark

usermod -a -G wireshark andrzejl

You need to change andrzejl to Your login.

chgrp wireshark /usr/bin/dumpcap

chmod 750 /usr/bin/dumpcap

chmod o+x /usr/bin/dumpcap

setcap cap_net_raw,cap_net_admin=eip /usr/sbin/dumpcap

getcap /usr/bin/dumpcap

after that You can run:

exit

wireshark

This will start Wireshark from Your user account. You should now have access to the capturing interfaces.

Wireshark as a non-root user.

Hope this helps somebody someday.

Andy