Tag: linux

Sendmail conspiracy

Sendmail conspiracy

Perl error “isvstring is only available with the XS version of Scalar::Util” fix

I faced the subj error after updating Perl package. It appears, Scalar::Util package is shipped with C-compiled modules which are not properly updated by yum. The workaround is manual package reinstalling:

wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/Scalar-List-Utils-1.23.tar.gz && \
tar zxvf Scalar-List-Utils-1.23.tar.gz && \
cd Scalar-List-Utils-1.23 && \
perl Makefile.PL && \
make test install && \

Fedora LXDE UI Improvement Tips

Touchpad vertical scroll:

in file /usr/share/X11/xorg.conf.d/50-synaptics.conf

Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Option "VertEdgeScroll" "1"
EndSection

Option “VertEdgeScroll” “1” – adds vertical scrolling

Restart X to take effect.

Adding keyboard layouts:

In file /etc/X11/xorg.conf.d/00-system-setup-keyboard.conf

Section "InputClass"
Identifier "system-setup-keyboard"
MatchIsKeyboard "on"
Option "XkbModel" "pc105+inet"
Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:caps_toggle,grp_led:num,terminate:ctrl_alt_bksp"
EndSection

Define layouts to be used
Option “XkbLayout” “us,ru”

Define switching keys:
Option “XkbOptions” “grp:caps_toggle,grp_led:num,terminate:ctrl_alt_bksp”
grp – key to switch
grp_led – Keyboard LED to highlight a layout
terminate – shortct to kill X

Restart X to take effect.

The UNIX and Internet Fundamentals Howto

Being quite *nix experienced, I do not hesitate to go through some tutorials for beginners every now and then. It is a pleasure to discover a pieces fo fundamental wisdom hidden there. I want to explicitly remark that a hidden pieces if wisdom can be found only in *NIX tutorials. Most likely because the tutorials are written by a hackers in love in a subject they write about. If you want to know the difference, try to read some Microsoft books written by a so-called technical writers for money. The difference is notable.

Recently I went through The Unix and Internet Fundamentals HOWTO by Eric Raymond. That one is exceptionally good for a beginners. I’ll explain why. The structure of the tutorial’s content delivery is organized in a way every computer introduction should be organized. It starts from a low level and goes to an upper ones. But it’s not about a piece of some hardware or software in an imaginary or omitted infrastructure, it is about the infrastructure in a whole. A pieces of an infrastructure are not described in detail but their role is described. Instead, the tutorial describes the Internet as a whole. It concentrates on the pieces’ interrelation to each other and describes their relations in a detailed, but clear way. And it’s short. It’s takes for about 2-5 hours of reading.

If you have any gaps in your understanding of the patterns of computers and/or Internet operation, you must read it. Normally, it should build a picture out of a jigsaw puzzle for anybody interested. I highly recommend to bookmark the tutorial and to offer it to any fried of yours who is willing to learn more. It is strictly recommended to the ones who suddenly decided to install Ubuntu.

Finding repeating lines in a text file

Today I learned how to find all repeating lines in a text file. My goal was to find out all lines in a text which repeat more than once. A dirty, but efficient way is using sort(8) and uniq(8) combination (thanks to my boss for a pointer).

$ sort /var/log/messages | uniq -d

Do not try to pass a file directly to uniq(8) unless it is sorted. Uniq(8) can find only adjacent equal lines. If you think lines are randomly dispersed throughout the file, uniq will not return correct result. Be careful.

I hate VMware server

What is the location of the directory of C header files that match your running
kernel? [/usr/src/linux/include] /usr/src/kernels/2.6.34.6-47.fc13.x86_64/include

The directory of kernel headers (version @@VMWARE@@ UTS_RELEASE) does not match
your running kernel (version 2.6.34.6-47.fc13.x86_64).  Even if the module were
to compile successfully, it would not load into the running kernel.

What is the location of the directory of C header files that match your running
kernel? [/usr/src/linux/include] ^C
[root@hp ~]# uname -r
2.6.34.6-47.fc13.x86_64

Linux Tutorials for Newbies

When you learn something using practical approach, you can miss small fundamental bits of information. The bits can be useful or useless, but it’s always good to know them. That is the reason I scroll through many Linux tutorials every now and then. Most of them are casual, but I have to highlight a gem I recently found: the Linux basics from Daniel Robbins. They are perfectly structured and there were some points I missed during my self-education.

The articles in Linux Fundamentals series are focused on Linux basics and position themselves as tutorial for preparation to LPI exams. I wouldn’t consider the tutorials as robust exam preparation guide – exam topics are wider than the ones discussed in tutorial. But tutorials are still very good. They are written in a very good easy language with nice input of nerd humour.

http://www.funtoo.org/en/articles/linux/lpi/1

http://www.funtoo.org/en/articles/linux/lpi/2

http://www.funtoo.org/en/articles/linux/lpi/3

http://www.funtoo.org/en/articles/linux/lpi/4

There are few more topic oriented tutorials written by Daniel, like BASH, SED, AWK guides. There is a file system guide for the ones who does not know which file system to choose . I’m too lazy to publish all direct link to the articles here. Just open http://www.funtoo.org/ page and scroll down. You’ll find all you need.

Lingvo dictionaries in Linux. Stardict way.

There is a version of Lingvo dictionaries for Stardict available on the net. I do not think it’s legal, so do not forget to purchase you Lingvo license before proceeding with the following instructions.

At first, install stardict and archiver:

yum -y install stardict p7zip

At second, download the dictionaries. Beware that original Lingvo dictionaries shipped with product will not work. You have to use special ones“.
Copy downloaded folders to /usr/share/stardict/dic. Now unpack them:

 cd /usr/share/stardict/dic; 7za e \*.7Z;

You’ll get a list of files and dirs. dirs are not needed, delete them:

for dir in *; do if [ -d $dir ]; then rm -rf $dir; fi  done

At last, kill all instances of Stardict and star one up. Go to “Manage dictionaries”: you shall see a list of added dictionaries there. If you see no any new dictionary, it means you have done something wrong. Go to the second tab (Manage Dict), choose query dict group, press [+] button, select all available (needed to you) dictionaries and press enter. Now you have to have the full list of dictionaries searchable.
Test it. Enjoy.

Linux random passwords generation

This post is more a note to myself than a message I want to deliver to me struggling readers. There are two utilities for generating random passwords and one hack-around.

pwgen

Generates MANY passwords simultaneously. Very handy if somebody is behind your back watching you.

[root@hp ~]# pwgen
OVo4jiev Cohkah0r Iesev0ec thefuz0F asho6Zai em3tok5I Quoogh2k leeRuhi1
Eica7gie aew1ieTh Ukeewie3 Tee3aesa zasiCie7 iey9Ugho Eex5phae aip2ohHe
uL8AGee2 bux8rohX Aiv1voo2 AeS5thie uli1Shai aeWee0ai sha6aeV2 ni2Oong4
ahji7AiW rei0za9A uK1eih8a phoo4Aih taiGh0ab uod2ho8I tooX9coh jeeC5pie
ohxiCh7u oluif8Co OhTieC7e Phuro0sh eeca7Atu yee3Aeve Iwi1nige aiyu3Ein
AiCee0ba eC5Saehi voa2Aina ge4eiWee che8EeD2 Ait5ohth aQuahp4o oosou2Si
wa3aitiZ fah2oGhu do8oor5A Ied9Erob Caizei5a meeFai6b roh8WooW Lah8ieph
Eixoh6zi Cee8eidi eeChah6I eMohrij7 Zeisu0ha oech6Ae9 cioreT6p ee2Ohsha
Uu6yae5V zohShea8 Eizubo9r Reek2eiv Aak0veb7 phei3Ife onaeh7Oo jaiMopi9
Phohm9vi Ai3EeYie aequeeN8 eCiug9ei keiRee6I Aikei9wo tugh5Pae yie4maTu
eiH5Jei4 aeChia4I ahs3seeS eeg6Pa7M pei8Jooy ih1phiDu jee1ai4U uuY6eRai
wee5si4I ui2AhSoa Shee9EeB ahV4oof9 cei3pheZ iB5daw3u saegh4Lo Waroo1ah
aeth1Loo ohReesh4 Saidae7o meB7tha6 Eetae9Oh meiyiR5e AeTooc3c Bu0ou0se
Ahree5Of eiwuJie9 Cuogh7ae eekeeB8V ruu0Yoqu angie1Ki Oang3eeb Oobe9jiP
Loo3Oova yieNee0n moo2aiSh aem6ooD3 Paehoh2w xee6Ooph acahph2A kooGu5Ie
hag2Buon chah4Bii xaequ4In Ooy9Lohk oophoh4N Oo5Roh4a Phe8choo xa2Thoo4
XahBoo4j eeHah2ai Quaico6D Lauh0eiF Eiv9ga9c ih9pooPh aedeLaS3 ohleiGo2
aPh7wivi le4Xah9d lahl4Hei shu2Kuch OhfeDi7z Aengaej7 Phie4oom eige6Fae
Xaesh2Ju iN7Coh3S The8Ij4z kae0OGhi Shei6ohp RooReim6 Pheih3Ai Aikah8sh
taiph4Ei kaoRoh1f om0moh3S uaphee7E lab4Xu9k kahh3saZ ain8Zeic Uu1fohvo

apg

Generates few random passwords.

[root@hp ~]# apg
johebud6
VuwejThig1
TegtuIdNi
FlabEpNeec
bytjeewk
voyHatadd5

Unix hacker’s way.

This way is considered to be insecure, but Jesus! Who would know you have used this freaking way!

for ((n=0;n<10;n++)); do dd if=/dev/urandom count=1 2> /dev/null | base64 | sed -ne 2p | cut -c-8; done

Fast appending files to tar archive is impossible.

Eventually, tar is very slow for appending files to the existing tarball. I’m particularly talking about following options:

-r – append files to the end of an archive
-u – only append files newer than copy in archive

Logically thinking, for -u to work, it should accomplish linear search through the archive. Than bigger the archive, than slower the search. Moreover, if you’ll try to append in the loop, it will accomplish search as many times as many iterations you loop has. I would advice to use in the most exceptional case ONLY. Try avoiding

# -u. slow inefficient approach of taring multiple files
for file in $(ls -A)
do
    tar -uf tarball.tar $file;		#traverses all archive to append the file.
done

You’d think that -r option usage forces tar application to append files to the end of the archive, getting the position of the archive’s end from archive’s index. It doesn’t. Tar format is designed in a way that it has no index.

# -r approach is also slow and inefficient
for file in $(ls -A)
do
    tar -rf tarball.tar $file;		#traverses all archive to append the file.
done

However, TAR supports several formats for its archive. But they are not well-documented. I had a brief overview of them, and looks like
–format=gnu is the most recent and featured one. And It still has no index. I no longer understand why tar is even used. Despite of that, below is a workaround, allowing for packing unlimited amounts of files right instant. I recommend to never use append function with tar format. Instead, get to know what are you going to archive, prepare necessary files, and archive them all.

# faster approach for taring multiple files. No appending
ls -A >> list.txt
tar -cT list.txt -f backup.tar