Linux Tips & Tricks

[2019-05-28] Quick Recovery of Lost Firefox Logins/Passwords

One of the worst nightmares I have encountered after upgrade to the newer version of Firefox. Backup copy of my profile folder was many months old. Here is what to do in this unfortunate case.

1) In the location bar, type “about:config” without quotes. Press enter and ignore warning (click “I accept the risk” button).
2) From search bar, find and select variable named “signon.importedFromSqlite” (without quotes). Right click mouse button, choose “Reset” from menu.
3) From rightmost menu “Help” select “Troubleshooting Information“. Click on the button “Open Directory” right to the “Profile Directory” title, then open current profile directory itself (usually named something like xyzabracodabra.default). Or just navigate to this directory manually in file manager.
Delete file named “logins.json” and restart Firefox.

Few recent entries may be lost, yet major part of login/password database will be restored.

 

[2019-05-28] How to Scan and List Top 10 Largest in a Directory (Recursively)

Install “tree” RPM or DEB, in most cases it is not installed by default. Then run

tree -ihafF /home | tr '[]' ' '| sort -k1hr | head -10

Replace “/home” with whatever directory you want to scan to. Script was recorder from “commandlinefu.com“.

 

[2018-04-26] How to Fix “Missing Index” Warnings after NextCloud Upgrade

NextCloud upgrade often results in these warnings, which are not fatal, yet need to be fixed.

Missing index "twofactor_providers_uid" in table "oc_twofactor_providers". Missing index "version" in table "oc_whats_new". Missing index "cards_abid" in table "oc_cards". Missing index "cards_prop_abid" in table "oc_cards_properties".

Run this command in terminal (on other Linux flavors except Ubuntu you may need to change “www-data” user)

sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices

 

[2018-12-12] How to Track Unexpected PyUNO Errors after LibreOffice 4.0x -> 4.2x Upgrade

LibreOfice upgrade from 4.0x to 4.2x resulted in unexpected PyUNO errors at startup. It appeared in quite complex spreadsheet with LibreOffice Basic and Python macros, which have been used for years without any problem.

Quite strange, problem emerge only when document was opened, after this any re-calculation went without any error. Finally I found a source of this glitch. My spreadsheet consisted of many sheets, one of which was obsolete and kept for historical (logging) purposes. Some numbers were erased from this old sheet. LibreOffice 4.0x (and earlier) do recalculation (at document open) of only current (active) sheet, while 4.2x – in all sheets within spreadsheet. Complete removal of obsolete stuff solves startup errors.

 

[2019-03-30] Fixing Zypper Segmentation Fault Errors on SuSE Linux Tumblweed

Need to update curl and libcurl4 manually: zypper up curl libcurl4

 

[2018-12-12] Fixing Webmin Install Error on SuSE Linux Leap 15.0 and Tumblweed

Webmin official RPM isn’t fixed yet on Open SuSE Leap and Tumblweed even at the end of 2018. Install (with rpm -Uvh or zypper in) abort with error: Error: Subprocess failed. Error: RPM failed: warning: /var/cache/zypper/RPMS/webmin-1.900-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 11f63c51: NOKEY grep: /etc.defaults/VERSION: No such file or directory Unable to identify operating system error: %prein(webmin-1.900-1.noarch) scriptlet failed, exit status 2 error: webmin-1.900-1.noarch: install failed This happens because version information is now stored in “/etc/os-release” instead of “/etc/SuSE-release“, and even format of these 2 files is different. So, create new file as root with “nano /etc/SuSE-release“, and paste this content: For Leap 15.0 openSUSE Leap 15.0 (x86_64) VERSION = 15.0 for Tumblweed openSUSE Tumbleweed (x86_64) VERSION = Tumbleweed CODENAME = Tumbleweed After this everything will work as expected.

 

[2018-11-15] Fixing Network Woes After Upgrade SuSE Linux Leap 42.x -> 15.0

Upgrading several servers and desktops with SuSE 42.3 to Leap 15.0 brought me a lot of trouble. First, there was a problem with Intel Gigabit Ethernet driver (igb kernel v4.12 module). Running “rcnetwork status” shows “wicked [788]: eth0 setup-in-progress”, and this continues for forever. Log entry “wickedd-nanny[795]: eth0: state=device-up want=network-up, wait-for=link-up” at first sight pointed to broken wire link, yet it wasn’t the case. This is clearly a problem with wicked and “igb” kernel module combo, because USB AX88772 Ethernet adapter works with the same PC with same cable and switch. Subsequently it was fixed, yet few months later same kind of upgrade failed again. Network was up and and down in endless cycle. Quick check revealed, that networking was switched to wicked, which conflicted with Gnome/MATE NetworkManager applet (latter tried to configure networking on its own in a timed interval). Removing “NetworkManager-applet” fixed this problem.

 

[2018-11-01] LibreOffice Calc 6.1.x Scrolling Crash on Linux

Today made a spreadsheet with a several 3D bar graphs and found that scrolling in LibreOffice Calc results in sudden application shutdown without any error message and loss of unsaved changes in document. Tested on different Linux distributions (SuSE Leap 15.0 and SuSE Tumblweed) and various hardware (nVidia GeForce and Intel GMA). Crashes were so often that app could be considered close to unusable in this particular case. After some tweaking problem was solved. Tools -> Options -> LibreOffice -> View -> Graphics Output / Use anti-aliasing should be off. Changing hardware acceleration options in LibreOffice doesn’t affect this crash.

 

[2018-10-31] Checking disk space usage on file/backup server

Assuming file/backup dirs located inside /home directory:

du /home -h --max-depth=1 | sort -hr
It may take some time if you have a lot of data.

 

[2018-09-10] Activating BFQ scheduler

BFQ (budget fair queuing) kernel scheduler allows much better GUI response under heavy IO loads, especially on relatively slow/old systems. This is done by means of assigning certain budget to the amount of traffic to each block device within each scheduling cycle. Algorithm is pretty complex and smart, details go beyond scope of this article. Here is how to activate it on Linux system. 1) Add scsi_mod.use_blk_mq=1 to the kernel boot parameters. 2) Create/edit config file /etc/udev/rules.d/61-bfq-scheduler.rules

### Rule start ###
#SSD
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq"
#Rotating
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
### Rule end ###

3) Restart system. Run this in terminal as root:

cat /sys/block/sdxxx/queue/scheduler If everything is OK, then output will look like this: mq-deadline kyber [bfq] none

For SuSE Linux in particular full article available here.

 

[2018-09-09] Logging malicious crack attempt passwords with Dovecot and ISPConfig 3.x

It really great and useful feature to log malicious crack attempt passwords. However, by default ISPConfig server only bans bad IPs for a short period of time.

tail -n 1000000 /var/log/mail.log | grep pop3-login | grep failed
shows failed entries, however

tail -n 1000000 /var/log/mail.log | grep mismatch
shows nothing – no recorded bogus passwords. Options in /etc/dovecot/conf.d/10-logging.conf were:

auth_verbose = yes

auth_verbose_passwords = plain


auth_debug_passwords = yes

As I’m was explained by ISPConfig support team, everything in /etc/dovecot/conf.d/ is being ignored, so one need to modify main Dovecot configuration file like this.

/etc/dovecot.conf

auth_verbose_passwords = plain

Please note: 1) dovecot.conf will be overwritten with next ISPConfig update. 2) smtp Postfix passwords will not be recorder. I’m still looking for solution.

 

[2018-09-09] Better script to wipe out e-mail content on ISPConfig 3.x

This command does brute force cleanup of all mail dirs on destination ISPConfig 3.x install. Unlike previous version below posted on 2018-03-29, it leaves intact Dovecot directory structure. After launching this script go to ISPConfig web control panel and run Tools -> Resync -> Maildomains, Mailboxes and Mailfilter in order to restore some setting like quota.

find /var/vmail/ -name '*' -type f -exec rm -v {} \;

However, even better solution is to use one of these dovecot commands:

doveadm -Dv purge -A doveadm expunge -A mailbox "*" all

 

[2018-08-26] Script to quickly kill frozen TeamViewer 13

Since TeamViewer 13 freezes endlessly on SuSE Leap 15, and older version of this application simply don’t work, this handy script will kill dead TeamViewer. Save at somewhere as bash script. I copied it into /bin as 11kill_teamviewer.sh, for quick typing 11 -> tab -> enter.

kill -9 $(ps aux | grep '[T]eamViewer' | awk '{print $2}')

 

[2018-03-29] Wipe out all mail dirs/messages on ISPConfig 3.x

This command does the cleanup of all mail dirs on destination ISPConfig 3.x install. Missing dirs will be re-created by Dovecot.

find /var/vmail/*/ -type d -name "Maildir" -print0 | xargs -0 rm -rf

 

[2018-03-29] ISPConfig 3.x on Debian 9 Stretch and IPVv6

Disabling IPv6 on Debian 9 Stretch results in non-functional mail server. Don’t do it ! Error messages in /var/log/mail.log usually look like this:

************************************
Mar 29 18:15:21 mail systemd[1]: Stopped LSB: Starts amavisd-new mailfilter. Mar 29 18:15:21 mail systemd[1]: Starting LSB: Starts amavisd-new mailfilter... Mar 29 18:15:22 mail amavis[10692]: starting. /usr/sbin/amavisd-new at mail.mydomain.com amavisd-new-2.10.1 (20141025), Unicode aware, Mar 29 18:15:22 mail amavis[10697]: (!)Net::Server: 2018/03/29-18:15:22 Can't connect to TCP port 10024 on ::1 [Cannot assign request Mar 29 18:15:22 mail amavis[10683]: Starting amavisd: amavisd-new. Mar 29 18:15:22 mail systemd[1]: Started LSB: Starts amavisd-new mailfilter.

************************************

Mar 29 18:36:06 mail postfix/smtp[1616]: 46E803C2BE7: to=<user.zzz@gmail.com>, relay=none, delay=0.06, delays=0.06/0/0/0, dsn=4.4.1, status=deferred (connect to 127.0.0.1[127.0.0.1]:10026: Connection refused)

 

[2018-03-04] Firefox on Linux don’t play some videos on Youtube and Facebook

Common problem with OpenSuSE Linux and Firefox, from both SuSE repository and binary from mozilla.org – some videos on Youtube and Facebook don’t play with message “Your browser does not currently recognize any of the video formats available”. This tool https://www.youtube.com/html5 detects H264 as unsupported format. Googling lead to this link https://support.mozilla.org/en-US/questions/1146825 which suggested this solution. https://forums.gentoo.org/viewtopic-p-7991240.html?sid=38ed7080bf31ac898795875a04c62f4e However, I don’t have any third-party packages which install its own copy of libavcodec.so.57 rpm -qf /usr/lib64/libavcodec.so.57 libavcodec57-3.4.2-10.1.x86_64 (from openSUSE:Leap:42.3:Update) Solution (as suggested on SuSE mailing list): you need to install libavcodec57, libavformat57 and libavutil55 from the Packman community repository.

 

[2017-11-19] Shorewall suddenly stops working with “interface eth0 is not usable”

On my OpenSuSE Leap 42.2 Linux system running as router/firewall with Shorewall 5.x restart resulted in stubborn error – “Interface eth0 is not usable. Provider LTC1 is not started. Interface eth1 is not usable. Provider BTC2 is not started.” After all. this sequence working.

rm /var/lib/shorewall/eth0.status shorewall enable eth0 rm /var/lib/shorewall/eth1.status shorewall enable eth1 shorewall reload

 

[2017-07-06] Preventing excess disk space usage with systemd/journal logs

On my OpenSuSE Leap 42.2 Linux system with SSD drive (and limited space) systemd journal logs took over 3.2GB. journalctl –disk-usage -> Archived and active journals take up 3.2G on disk. These variables need to be changed in “/etc/systemd/journald.conf":

[Journal]
SystemMaxUse=100M
SystemMaxFileSize=10M

[2015-10-06] Installing Python module for specific version of Python

Here is a sample for Python 2.7. 1) Download and unzip module archive, cd into unpacked archive directory. 2) Run in terminal as root:

python2.7 setup.py install

[2015-09-18] Lost LibreOffice Basic macro modules after upgrade  4.x -> 5.x

It was really awkward, annoying and hard to solve problem. For whatever reason (I think its a bug or glitch), new LibreOffice 5.x on first start simply overwrites XML config file with the list of registered LibO Basic macro modules. Go to /home/your_user_name/.config/libreoffice/4/user/basic/Standard/ and open file named script.xlb in any text editor. Then replace its content with the one below, changing macro modules name (like main BA_mag_gen) to yours.

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> <library:library xmlns:library="http://openoffice.org/2000/library" library:name="Standard" library:readonly="false" library:passwordprotected="false"> <library:element library:name="BA_mag_atrafo"/> <library:element library:name="BA_mag_gen"/> <library:element library:name="BA_mag_geom"/> <library:element library:name="BA_mag_test"/> </library:library>

[2014-04-05] OpenSUSE – hassle-free KDE upgrade

Upgrading KDE may be an irritating experience due to large number of inter-dependent packages. Failing to comply with these dependencies may result misbehaved desktop environment. Here is a simple way to do the upgrade. 1) Add repositoreis “KDE SC” and “KDE SC Extra” (more information here). 2) Run in terminal as root:

zypper dup --from KDE_SC && KDE_SC_Extra

[2013-10-09] ISPConfig3/Postfix mail queue stuck – solution

I’ve got this problem a couple of times with ISPConfig3 server- mail queue stuck for no apparent reason. First, I deleted all stuff from /var/vmail/mydomain.com, it didn’t help. Here is a solution (run as root):

postsuper -d ALL

[2013-09-23] Installing OpenSuSE on Intel server m/b S1200BTL E98681-352 and LSI 3Ware 9750-4i RAID L5

After assembling new server with Intel server m/b S1200BTL E98681-352 (BMC Firmware 1.13.2825, ME Firmware 02.02.00.036) Intel Xeon E3-1230 3.3GHz 8GB ECC RAM LSI 3Ware 9750-4i RAID L5 with 4x1TB WD hard drives I’ve got nasty problem – server won’t boot, just blinking cursor after BIOS prompt. OS (OpenSuSE 12.3 x64 with EFI partition/GRUB2-EFI, secure boot off) was installed on hardware RAID5. Quite strange, since OS installer was loaded from USB stick with EFI partition, and no problem were encountered during installation process. As some people suggested, I flashed latest available Intel m/b firmware (BMC Firmware 1.16.4347, SDR 0.14, ME Firmware 2.2.0.49), switched on / off EFI Optimized Boot in BIOS (tried both possibilities). Looks like I moved one step backward – server just hang at BIOS prompt. Quite strange, in EFI command prompt “map -r” don’t list EFI boot partition on LSI/3Ware RAID. This moved me to the conclusion that LSI 3Ware 9750-4i BIOS and Intel EFI don’t play nicely together. I have removed EFI boot partition and installed GRUB2 instead of GRUB2-EFI. Now everything worked fine. Additionally, please be aware, that although LSI 3Ware 9750-4i theoretically supports RAID 6 (which can survive failure of 2 hard drives simultaneously without data loss), it has only one SFF-8087 4-lane connector, and therefore, requires SAS expander to connect more then 4 SATA drives. This expander costs more then 9750-4i, making it economically unattractive option, one should purchase 9750-8i with 2 x SFF-8087 ports instead in order to use RAID L6 option.

[2013-09-07] Installing MS fonts on OpenSuSE

sudo zypper install fetchmsttfonts

[2013-08-18] upowerd failure on SuSE Linux 12.3 x64

If upowerd daemon fail to start on your system with this message:

systemd[1]: Starting Daemon for power management... upowerd[8289]: /usr/lib/upower/upowerd: symbol lookup error: /usr/lib/upower/upowerd: undefined symbol: g_type_class_adjust_private_offset systemd[1]: upower.service: main process exited, code=exited, status=127/n/a systemd[1]: Failed to start Daemon for power management. systemd[1]: Unit upower.service entered failed state

Do the following: 1) Add Gnome 3.8 repository: http://download.opensuse.org/repositories/GNOME:/STABLE:/3.8/openSUSE_12.3/ 2) Update glib2-devel and glib2-tools from this repository.to 2.36.4 or above. Then run: systemctl restart upower.service systemctl status upower.service

[2013-06-14] Compiling latest FreeCAD on SuSE Linux

Once I needed FreeCAD I noticed that RPM version in SuSE repositories is quite old and outdated. It didn’t took much time to compile latest version. Actually there is a how-to buried on FreeCAD wiki, but it needs some updates.

1) Add these repositories to YaST sources:

http://download.opensuse.org/repositories/science/openSUSE_12.3/ for OCE and OCE-devel http://download.opensuse.org/repositories/home:/drevilt:/python/openSUSE_Factory/ for python-pycollada http://download.opensuse.org/repositories/home:/scalpel4k/openSUSE_Factory/ for Coin-devel

2) Install these packages:

sudo zypper install gcc gcc-fortran git cmake rpm-build doxygen  checkinstall swig OCE-devel libXerces-c-devel libode-devel  libeigen3-devel libqt4-devel libQtWebKit-devel Coin-devel SoQt-devel  boost-devel python-devel python-qt4 python-pivy python-pycollada libspnav-devel

Make sure that you have gcc, fortran, and other develoment tools installed. Create subdirectory in home/your name/bin, e.g. FreeCAD. then “cd” to this path.

Download latest sources from FreeCAD git:

git clone git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad

Make another dir for compilation:

# build configuration cmake ../free-cad # build FreeCAD make

Compiled binaries will be located in FreeCAD-Build_git/bin

[2013-06-06] Delete empty directories – recursively

Once I run into problem – I had a large archive containing a LOT of empty directories. Here is a shell commands to clean things up (actually made by someone else).

while [ -n "$(find . -depth -type d -empty -print -exec rmdir {} +)" ]; do :; done

[2012-08-30] Fix – Python macros don’t work anymore after upgrade LibreOffice 3.4 -> 3.5/3.6

Really annoying issue which could be somehow documented, or even better, avoided altogether with simple startup check procedure. In short, LibreOffice V3.4 and earlier stored Pyton scripts inside “/home/~user/.libreoffice/3-suse/user/Scripts/python/” and starting from V3.5 in “/home/~user//.config/libreoffice/3-suse/user/Scripts/python/” Just copy your Python scripts manually, and everything will be fine again.

[2010-11-30] Fix – ISPConfig 2.x doesn’t start properly on SuSE 11.x

I have noticed strange behavior of ISPConfig 2.x software running on OpenSuSE 11.x – after restart it starts with OK status but doesn’t work properly – at least BIND had to be restarted. I watched startup sequence and noticed a culprit – for whatever reason “ispconfig_server” “rc.init.d” script was launched before network service! No surprise system didn’t worked as expected. Fix is quite simple. First remove “ispconfig_server” from the list of startup scripts (with YAST for example). Second, open “/etc/init.d/ispconfig_server” with any text editor and these lines right at the beginning:

### BEGIN INIT INFO
# Provides:       ispconfig_server
# Required-Start: $network $syslog
# Should-Start:   
# Required-Stop:  $network $syslog
# Should-Stop:    
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description:
# Description:   
### END INIT INFO

It will tell OpenSuSE to run “ispconfig_server” only after network service is up and running. Then, add again “ispconfig_server” to the list of active startup scripts.

[2009-10-21] Mounting Remote Directory via SSH

You need to install fuse package to have secure shell filesystem support.

 sshfs remoteuser@remotehost:/path/to/remote_dir local_mountpoint

Then, use this command to unmount remote directory:

fusermount -u local_mountpoint

[2009-10-21] Quick & Dirty Comparison of 2 Directories

Today I had a rather daunting task. I recovered a directory with important documents from my hard drive with damaged partition map. Although files should be OK, who really knows if that is true (there are over 5000 of them). On the other hand, I have a backup made some time ago. So I wish to stay with recovered version which has all new stuff (which I can check manually), but verify if any of older files (last modified more then 1 month ago) may become corrupt. So, basically, I am need to recursively compare 2 directories. Its simple as 1-2-3. Just run in terminal “diff -r -q folder-1.1/ folder-2.2/”. “-r” means “recursive”, “-q” – brief, report only whether the files differ, not the details of the differences. Sample:

diff -r -q folder-1.1/ folder-2.2/
 Only in folder-2.2/: 1.txt
 Only in folder-1.1/: 1.txt~
 Only in folder-1.1/: .emacs2
 Files folder-1.1//kitchin.txt and folder-2.2//kitchin.txt differ

PS. I have a number of interesting topics in the old version of this site. Old tips and tricks will not be moved here since I would like to keep new stuff separately from the old one.

Leave a Reply