Recently I had a problem while working with SLES - Suse Enterprise Linux.
During reboot it just hanged same thing was going on while shutting down with halt -p.
From the messages appearing on screen I have seen that it has trouble with un mounting nfs shares.
The problem was that Suse was first bringing down network interfaces than trying to umount nfs shares.
I could either spend time trying to fix os (add umount somewhere to pre halt operations) or I could do:
- umount -a (so all resources that are not being used will be unmounted) and then halt -p or reboot
- do reboot -f instead (reboot with force does not care if nfs resources are mounted)
So I have decided not to spend time on fixing SUSE/SLES and do umount or reboot -f.
Overall my experience with SLES/SUSE is that they did really nice installer ... but apart from that things that should work out of the box don`t.
sobota, 19 września 2015
My attemp to fight with Carpal tunnel syndrome (CTS)
If you spend a lot of time in front of a computer sooner or later you will get Carpal tunnel syndrome.
I remember time when I used to laugh at it and say "Keyboard and mouse can not cause any injuries", I guess I was wrong.
After quite a few years working in IT i started feeling pain in my wrists - I could no longer do push ups on palms the only option was to do it on fists. Also I felt pain during normal day to day tasks.
I have decided to something about it.
So I went kayaking for about a week at least 5 hours a day and it cured me for about half a year, but after that time pain came back.
I did some digging in internet and decided to buy two gadgets:
- microsoft natural ergonomic keyboard 4000
- logitech wireless trackball m570
Advantages of ergonomic keyboard are that wrist rest is higher then the rest of the keyboard.
In some reviews I read that quality of that keyboard is poor - I can not say that (i have been using it for few weeks I it does not feel cheap if you know what I mean).
Colleagues at work say that I look funny with it but some of them have already first symptoms of CTS so we shall see who will look funny after surgery.
As to logitech wirelles trackball m570 it is my first day of using is (my wife likes it). I read quite a lot about it and someone suggested in comments that if you are going to buy a trackball because of CTS than buy one controlled with thumb.
Another good thing about that trackball is that you get with it logitech unifying adapter nano, so you can connect multiple Bluetooth devices to it (keyboard, mouse, headphones).
In few months time I will update this post so you will know if it worked.
I remember time when I used to laugh at it and say "Keyboard and mouse can not cause any injuries", I guess I was wrong.
After quite a few years working in IT i started feeling pain in my wrists - I could no longer do push ups on palms the only option was to do it on fists. Also I felt pain during normal day to day tasks.
I have decided to something about it.
So I went kayaking for about a week at least 5 hours a day and it cured me for about half a year, but after that time pain came back.
I did some digging in internet and decided to buy two gadgets:
- microsoft natural ergonomic keyboard 4000
- logitech wireless trackball m570
Advantages of ergonomic keyboard are that wrist rest is higher then the rest of the keyboard.
In some reviews I read that quality of that keyboard is poor - I can not say that (i have been using it for few weeks I it does not feel cheap if you know what I mean).
Colleagues at work say that I look funny with it but some of them have already first symptoms of CTS so we shall see who will look funny after surgery.
As to logitech wirelles trackball m570 it is my first day of using is (my wife likes it). I read quite a lot about it and someone suggested in comments that if you are going to buy a trackball because of CTS than buy one controlled with thumb.
Another good thing about that trackball is that you get with it logitech unifying adapter nano, so you can connect multiple Bluetooth devices to it (keyboard, mouse, headphones).
In few months time I will update this post so you will know if it worked.
sobota, 29 sierpnia 2015
looking for wireless laser printer that will work on Linux - Brother HL-1210WE is the way to go
Few years back I was using brother printer (it had LPT cable, yes it was that old), what I did like about it was that there were drivers for Linux.
So when I was searching for small home printer I decided to choose Brother HL-1210WE, and it was the right choice - print via wifi on windows 7 and Linux Debian without any problem.
Setup was not complicated, when I first connected it via usb cable pop up appeared and I clicked look for drivers, selected brother hl-1230 and was ready to print.
Wireless setup was easy as well, I went to System >> Administration >> Printing >> Add Printer >> IPP protocol.
In computer section pasted printers ip address, clicked next and selected appropriate drivers, and was ready to print.
Setup on windows was easy as well I did not have to supply network settings, printer took it from windows (password, ssid, and the rest from DHCP).
After that I decided to reserve ip address on my access point for printer - so it will not change.
So once again brother proved to be right hardware/software supplier for Linux users.
So when I was searching for small home printer I decided to choose Brother HL-1210WE, and it was the right choice - print via wifi on windows 7 and Linux Debian without any problem.
Setup was not complicated, when I first connected it via usb cable pop up appeared and I clicked look for drivers, selected brother hl-1230 and was ready to print.
Wireless setup was easy as well, I went to System >> Administration >> Printing >> Add Printer >> IPP protocol.
In computer section pasted printers ip address, clicked next and selected appropriate drivers, and was ready to print.
Setup on windows was easy as well I did not have to supply network settings, printer took it from windows (password, ssid, and the rest from DHCP).
After that I decided to reserve ip address on my access point for printer - so it will not change.
So once again brother proved to be right hardware/software supplier for Linux users.
niedziela, 10 maja 2015
How to check which command line parameters kernel was booted with
Good solution is to display file /proc/cmdline for example:
cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-2.6.32-5-amd64 root=UUID=eec16201-b3de-4f50-8536-930ec2f78152 ro quiet
When checking /proc/cmdline is useful?
When we want to check if parameters given during boot worked properly if e.g memmap worked properly.
cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-2.6.32-5-amd64 root=UUID=eec16201-b3de-4f50-8536-930ec2f78152 ro quiet
When checking /proc/cmdline is useful?
When we want to check if parameters given during boot worked properly if e.g memmap worked properly.
środa, 14 stycznia 2015
bash script for changing password
I have seen a lot of articles describing how to change password via a script, some of them work most of them don't.
Below I present option that works very well.
On a local machine can perform command:
echo -e "user:password" | chpasswd
If we are not happy with pasting in password in plain text then we use mkpasswd to encrypt the password and modify slightly command for changing password:
root@debian:/var/www# mkpasswd
Password:
TqDuqPhgvp7pM
Then we use our encrypted password in command:
echo -e "user:TqDuqPhgvp7pM" | chpasswd -e
What about running this command remotely on a server:
ssh root@IP_ADDRESS 'echo -e "user:password" | chpasswd'
encrypted version works almost the same
ssh root@IP_ADDRESS 'echo -e "user:encypted_password" | chpasswd -e'
What if I want to change password on multiple servers at once:
create a file (list.txt) with a list of ip addresses one under another
212.77.100.101
212.77.100.102
...
and run a command in a loop:
for i in $(cat list.txt); do ssh root@$i 'echo -e "user:password" | chpasswd' && echo $i ; done
This post might be little bit outdated because everyone should be using keys instead of passwords.
At my work we use both this is why I wanted to do it almost automatically.
Below I present option that works very well.
On a local machine can perform command:
echo -e "user:password" | chpasswd
If we are not happy with pasting in password in plain text then we use mkpasswd to encrypt the password and modify slightly command for changing password:
root@debian:/var/www# mkpasswd
Password:
TqDuqPhgvp7pM
Then we use our encrypted password in command:
echo -e "user:TqDuqPhgvp7pM" | chpasswd -e
What about running this command remotely on a server:
ssh root@IP_ADDRESS 'echo -e "user:password" | chpasswd'
encrypted version works almost the same
ssh root@IP_ADDRESS 'echo -e "user:encypted_password" | chpasswd -e'
What if I want to change password on multiple servers at once:
create a file (list.txt) with a list of ip addresses one under another
212.77.100.101
212.77.100.102
...
and run a command in a loop:
for i in $(cat list.txt); do ssh root@$i 'echo -e "user:password" | chpasswd' && echo $i ; done
This post might be little bit outdated because everyone should be using keys instead of passwords.
At my work we use both this is why I wanted to do it almost automatically.
sobota, 10 stycznia 2015
Compile kernel on CentOs 7 (should be very similar on RedHat and Fedora)
For me the reason why I decided to compile kernel was that in work I am testing software that is not included in default release.
Steps required to compile your own kernel:
Download kernel from https://www.kernel.org/.
Extract kernel by command tar -xvzf archive_name
Copy configuration file to location where you have extracted kernel:
cp /boot/config-3.10.0-123.el7.x86_64 your_extracted_archive_location
Prerequisites (install packages required):
yum groupinstall "Development Tools"
yum install bc.x86_64
yum install ncurses-devel
Configure what you want to be compiled to your new kernel:
- make menuconfig (choose option load file that you took earlier from /boot/config*, make modifications, choose save )
- make bzImage -j your_number_here (-j stands for the number of jobs (commands) to run simultaneously, I usually set one job per one core of processor)
- make modules -j your_number_here
- make modules_install -j your_number_here
- make install
The reason why I decided to choose configuration file from /boot/config* is that to do it manually properly would take much time, there is also less chance that I will make an error which will make machine to be unable boot. It is much easier and faster to edit existing proper configuration file.
Make install does all the magic, modifies grub but does not set new kernel as default.
In order to use compiled kernel during next boot modify file /etc/default/grub.
[root@localhost ~]# cat /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
#GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.keymap=pl2 crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
As you can see I've added GRUB_DEFAULT=0 and commented out "#GRUB_DEFAULT=saved".
I have read some articles that compiling kernel does not necessarily make Linux work faster but I have this strange filling that it does (even login via ssh takes less time).
A proof that it went through successfully:
[root@localhost ~]# uname -r
3.18.0-rc1
Steps required to compile your own kernel:
Download kernel from https://www.kernel.org/.
Extract kernel by command tar -xvzf archive_name
Copy configuration file to location where you have extracted kernel:
cp /boot/config-3.10.0-123.el7.x86_64 your_extracted_archive_location
Prerequisites (install packages required):
yum groupinstall "Development Tools"
yum install bc.x86_64
yum install ncurses-devel
Configure what you want to be compiled to your new kernel:
- make menuconfig (choose option load file that you took earlier from /boot/config*, make modifications, choose save )
- make bzImage -j your_number_here (-j stands for the number of jobs (commands) to run simultaneously, I usually set one job per one core of processor)
- make modules -j your_number_here
- make modules_install -j your_number_here
- make install
The reason why I decided to choose configuration file from /boot/config* is that to do it manually properly would take much time, there is also less chance that I will make an error which will make machine to be unable boot. It is much easier and faster to edit existing proper configuration file.
Make install does all the magic, modifies grub but does not set new kernel as default.
In order to use compiled kernel during next boot modify file /etc/default/grub.
[root@localhost ~]# cat /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
#GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.keymap=pl2 crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
As you can see I've added GRUB_DEFAULT=0 and commented out "#GRUB_DEFAULT=saved".
I have read some articles that compiling kernel does not necessarily make Linux work faster but I have this strange filling that it does (even login via ssh takes less time).
A proof that it went through successfully:
[root@localhost ~]# uname -r
3.18.0-rc1
niedziela, 23 listopada 2014
Wyliczanie mediany w bashu :).
Ostatnio miałem okazję napisać skrypt do wyliczania mediany w bashu, więc postanowiłem się nim podzielić.
Skrypt jest dość ciekawy, ponieważ korzysta z różnych narzędzi dostępnych w systemie operacyjnym Linux.
Zawartość skryptu:
#!/bin/bash
a=`cat $1 | wc -l `
echo "Lista składa się się z $a elementów"
if [ `expr $a % 2` -ne 0 ]
then
echo "$a jest nieparzystą liczbą elementów"
b=`expr $a / 2 + 1` ### Zmienna zawierająca środkową wartość
echo "Element, którego wartości poszukuję to $b "
echo "Jego wartość to `cat $1 | sort -n | sed -n "$b"p`"
else
echo "$a jest parzystą liczbą elementów"
### Ustawienie zmiennej lista elementów podzielona na dwa oraz lista elementów podzielona na dwa i plus jeden.
c=`expr $a / 2`
d=`expr $a / 2 + 1`
echo "Poszukiwane są wartości elemntu $c oraz $d"
### Ustawienie wartości dla zmiennych c oraz d
cc=`cat $1 | sort -n | sed -n "$c"p`
dd=`cat $1 | sort -n | sed -n "$d"p`
ee=`expr $cc + $dd`
echo "Które mają nastepujące wartości $cc oraz $dd"
echo "Wynik dla parzystej ilości liczb wynosi:"
echo "`echo $ee 2 | awk '{print $1/$2}'`"
fi
Wzory na wyliczenie mediany znalazłem na stronie http://www.matmana6.pl/tablice_matematyczne/liceum/statystyka/44-mediana_wariancja_i_odchylenie_standardowe .
Są dostępne dwie jego wersje pierwszy dla nieparzystej ilości analizowanych liczb, drugi dla parzystej liczby analizowanych liczb.
Dla nieparzystej ilości liczb medianą jest środkowa liczba ze wzoru.
Dla parzystej ilości liczb medianą jest średnia wyciągnięta z dwóch liczb najbliżej środka.
Rozbicie skryptu na czynniki pierwsze :):
a=`cat $1 | wc -l ` ### Tworzymy zmienną "a" i sprawdzamy ile ma elementów (przydatne do późniejszego sprawdzenia czy mamy do czynienia z parzystą czy też nieparzystą ilością liczb).
if [ `expr $a % 2` -ne 0 ] ### Sprawdzamy czy ilość elementów jest nieparzysta "% 2" oznacza że dzielimy przez dwa i jest zwracana reszta z dzielenia, jeżeli wynik jest równy 0 to wówczas mamy do czynienia z liczbą parzystą, jeśli nie to jest to liczba nieparzysta (stosujemy pierwszy wzór).
b=`expr $a / 2 + 1` ### Tworzymy zmienną b, dzielimy ilość elementów na dwa (expr auto-magicznie zaokrągli wynik w dół) i dodajemy jeden aby znać numer elementu ze środka przedziału.
echo "Jego wartość to `cat $1 | sort -n | sed -n "$b"p`" ### Rozpoczynam działania na pliku który podałem podczas uruchomienia skryptu (przykładowe wywołanie skryptu "./skrypt.sh lista.txt"), sortuje po numerach liczby umieszczone w pliku lista.txt i wyświetlam za pomocą sed zawartość środkowego wiersza z pliku. Ta dam i mamy medianę :).
c=`expr $a / 2` ### Tworze dwie zmienne odpowiadające elementom listy najbliżej środka ( np. dla listy 1 2 3 4, będzie to 2 i 3)
d=`expr $a / 2 + 1`
cc=`cat $1 | sort -n | sed -n "$c"p` ### Przypisuję wartości dla elementów najbliżej środka przedziału
dd=`cat $1 | sort -n | sed -n "$d"p`
ee=`expr $cc + $dd` ### Dodaję wartości obu zmiennych
echo "`echo $ee 2 | awk '{print $1/$2}'`" ### Ten fragment jest trochę przekombinowany dlatego, że expr nie chciał podawać wyników z dokładnością do dwóch miejsc po przecinku. Przekazałem więc dwa argumenty do programu awk i je przez siebie podzieliłem.
Zawartość przykładowych plików na których testowałem skrypt:
cat lista.txt
1
7
3
5
8
cat lista2.txt
1
3
5
6
10
8
Wynik wykonania skryptu na obu listach:
pawel@debian:~/mediana$ ./skrypt.sh lista.txt
Lista składa się się z 5 elementów
5 jest nieparzystą liczbą elementów
Element, którego wartości poszukuję to 3
Jego wartość to 5
pawel@debian:~/mediana$ ./skrypt.sh lista2.txt
Lista składa się się z 6 elementów
6 jest parzystą liczbą elementów
Poszukiwane są wartości elemntu 3 oraz 4
Które mają nastepujące wartości 5 oraz 6
Wynik dla parzystej ilości liczb wynosi:
5.5
Zdaję sobie sprawę z tego, że wykonywanie obliczeń statystycznych w bashu trochę mija się z celem ale i tak postanowiłem ten skrypt opublikować.
Może komuś przyda się, któraś z metod np. wyświetlanie wiersza o specyficznym numerze za pomocą sed.
Skrypt jest dość ciekawy, ponieważ korzysta z różnych narzędzi dostępnych w systemie operacyjnym Linux.
Zawartość skryptu:
#!/bin/bash
a=`cat $1 | wc -l `
echo "Lista składa się się z $a elementów"
if [ `expr $a % 2` -ne 0 ]
then
echo "$a jest nieparzystą liczbą elementów"
b=`expr $a / 2 + 1` ### Zmienna zawierająca środkową wartość
echo "Element, którego wartości poszukuję to $b "
echo "Jego wartość to `cat $1 | sort -n | sed -n "$b"p`"
else
echo "$a jest parzystą liczbą elementów"
### Ustawienie zmiennej lista elementów podzielona na dwa oraz lista elementów podzielona na dwa i plus jeden.
c=`expr $a / 2`
d=`expr $a / 2 + 1`
echo "Poszukiwane są wartości elemntu $c oraz $d"
### Ustawienie wartości dla zmiennych c oraz d
cc=`cat $1 | sort -n | sed -n "$c"p`
dd=`cat $1 | sort -n | sed -n "$d"p`
ee=`expr $cc + $dd`
echo "Które mają nastepujące wartości $cc oraz $dd"
echo "Wynik dla parzystej ilości liczb wynosi:"
echo "`echo $ee 2 | awk '{print $1/$2}'`"
fi
Wzory na wyliczenie mediany znalazłem na stronie http://www.matmana6.pl/tablice_matematyczne/liceum/statystyka/44-mediana_wariancja_i_odchylenie_standardowe .
Są dostępne dwie jego wersje pierwszy dla nieparzystej ilości analizowanych liczb, drugi dla parzystej liczby analizowanych liczb.
Dla nieparzystej ilości liczb medianą jest środkowa liczba ze wzoru.
Dla parzystej ilości liczb medianą jest średnia wyciągnięta z dwóch liczb najbliżej środka.
Rozbicie skryptu na czynniki pierwsze :):
a=`cat $1 | wc -l ` ### Tworzymy zmienną "a" i sprawdzamy ile ma elementów (przydatne do późniejszego sprawdzenia czy mamy do czynienia z parzystą czy też nieparzystą ilością liczb).
if [ `expr $a % 2` -ne 0 ] ### Sprawdzamy czy ilość elementów jest nieparzysta "% 2" oznacza że dzielimy przez dwa i jest zwracana reszta z dzielenia, jeżeli wynik jest równy 0 to wówczas mamy do czynienia z liczbą parzystą, jeśli nie to jest to liczba nieparzysta (stosujemy pierwszy wzór).
b=`expr $a / 2 + 1` ### Tworzymy zmienną b, dzielimy ilość elementów na dwa (expr auto-magicznie zaokrągli wynik w dół) i dodajemy jeden aby znać numer elementu ze środka przedziału.
echo "Jego wartość to `cat $1 | sort -n | sed -n "$b"p`" ### Rozpoczynam działania na pliku który podałem podczas uruchomienia skryptu (przykładowe wywołanie skryptu "./skrypt.sh lista.txt"), sortuje po numerach liczby umieszczone w pliku lista.txt i wyświetlam za pomocą sed zawartość środkowego wiersza z pliku. Ta dam i mamy medianę :).
c=`expr $a / 2` ### Tworze dwie zmienne odpowiadające elementom listy najbliżej środka ( np. dla listy 1 2 3 4, będzie to 2 i 3)
d=`expr $a / 2 + 1`
cc=`cat $1 | sort -n | sed -n "$c"p` ### Przypisuję wartości dla elementów najbliżej środka przedziału
dd=`cat $1 | sort -n | sed -n "$d"p`
ee=`expr $cc + $dd` ### Dodaję wartości obu zmiennych
echo "`echo $ee 2 | awk '{print $1/$2}'`" ### Ten fragment jest trochę przekombinowany dlatego, że expr nie chciał podawać wyników z dokładnością do dwóch miejsc po przecinku. Przekazałem więc dwa argumenty do programu awk i je przez siebie podzieliłem.
Zawartość przykładowych plików na których testowałem skrypt:
cat lista.txt
1
7
3
5
8
cat lista2.txt
1
3
5
6
10
8
Wynik wykonania skryptu na obu listach:
pawel@debian:~/mediana$ ./skrypt.sh lista.txt
Lista składa się się z 5 elementów
5 jest nieparzystą liczbą elementów
Element, którego wartości poszukuję to 3
Jego wartość to 5
pawel@debian:~/mediana$ ./skrypt.sh lista2.txt
Lista składa się się z 6 elementów
6 jest parzystą liczbą elementów
Poszukiwane są wartości elemntu 3 oraz 4
Które mają nastepujące wartości 5 oraz 6
Wynik dla parzystej ilości liczb wynosi:
5.5
Zdaję sobie sprawę z tego, że wykonywanie obliczeń statystycznych w bashu trochę mija się z celem ale i tak postanowiłem ten skrypt opublikować.
Może komuś przyda się, któraś z metod np. wyświetlanie wiersza o specyficznym numerze za pomocą sed.
Subskrybuj:
Posty (Atom)