Archive for the Linux Category
upgrade to Slackware-15.0
mkdir /packages
mount /dev/cdrom /packages
telinit 1 | 3
1. Upgrade your glibc shared libraries. This is important, or things
might go haywire during the next part of the upgrade:
upgradepkg --install-new /root/slackware/a/aaa_glibc-solibs-*.txz
2. Upgrade your package utilities and related tools:
upgradepkg /root/slackware/a/pkgtools-*.txz
upgradepkg /root/slackware/a/tar-*.txz
upgradepkg /root/slackware/a/xz-*.txz
upgradepkg /root/slackware/a/findutils-*.txz
3. Upgrade everything else (and install new packages):
upgradepkg --install-new /root/slackware/*/*.t?z
4. Remove obsolete packages. The CHANGES_AND_HINTS.TXT file should have a
list of these. You may also wish to go into /var/lib/pkgtools/packages
and take a look at the package list:
ls -lt | less
removepkg --terse ConsoleKit2 PyQt Thunar aaa_elflibs amarok amor ash \
automoc4 bigreqsproto calligra-l10n-bs calligra-l10n-ca \
calligra-l10n-ca@valencia calligra-l10n-cs calligra-l10n-da \
calligra-l10n-de calligra-l10n-el calligra-l10n-en_GB calligra-l10n-es \
calligra-l10n-et calligra-l10n-fi calligra-l10n-fr calligra-l10n-gl \
calligra-l10n-hu calligra-l10n-it calligra-l10n-ja calligra-l10n-kk \
calligra-l10n-nb calligra-l10n-nl calligra-l10n-pl calligra-l10n-pt \
calligra-l10n-pt_BR calligra-l10n-ru calligra-l10n-sk calligra-l10n-sv \
calligra-l10n-tr calligra-l10n-uk calligra-l10n-zh_CN \
calligra-l10n-zh_TW cargo cgmanager compositeproto damageproto db42 \
db44 dirmngr dmxproto dri2proto dri3proto eigen2 eject evieext \
fixesproto fontcacheproto fontsproto gcc-java getty-ps glade3 \
glibc-solibs glproto gnome-themes-standard gnu-cobol gst-plugins-base0 \
gst-plugins-good0 gstreamer0 gtk-xfce-engine herqq idnkit ilmbase \
imapd inputproto intel-gpu-tools js185 kaccessible kajongg \
kaudiocreator kbproto kde-base-artwork kde-baseapps kde-l10n-ar \
kde-l10n-bg kde-l10n-bs kde-l10n-ca kde-l10n-ca@valencia kde-l10n-cs \
kde-l10n-da kde-l10n-de kde-l10n-el kde-l10n-en_GB kde-l10n-es \
kde-l10n-et kde-l10n-eu kde-l10n-fa kde-l10n-fi kde-l10n-fr \
kde-l10n-ga kde-l10n-gl kde-l10n-he kde-l10n-hi kde-l10n-hr \
kde-l10n-hu kde-l10n-ia kde-l10n-id kde-l10n-is kde-l10n-it \
kde-l10n-ja kde-l10n-kk kde-l10n-km kde-l10n-ko kde-l10n-lt \
kde-l10n-lv kde-l10n-mr kde-l10n-nb kde-l10n-nds kde-l10n-nl \
kde-l10n-nn kde-l10n-pa kde-l10n-pl kde-l10n-pt kde-l10n-pt_BR \
kde-l10n-ro kde-l10n-ru kde-l10n-sk kde-l10n-sl kde-l10n-sr \
kde-l10n-sv kde-l10n-tr kde-l10n-ug kde-l10n-uk kde-l10n-wa \
kde-l10n-zh_CN kde-l10n-zh_TW kde-runtime kde-wallpapers kde-workspace \
kdeartwork kdegraphics-strigi-analyzer kdelibs \
kdenetwork-strigi-analyzers kdepim kdepim-apps-libs kdepimlibs \
kdesdk-strigi-analyzers kdevelop-php kdevelop-php-docs kdevplatform \
kdewebdev keybinder kgamma kio-mtp klettres korundum kplayer kppp \
kremotecontrol ksaneplugin ksnapshot ksysguard ktuberling ktux \
kuser kwebkitpart lha libXfont libart_lgpl libbluedevil libcroco \
libkdeedu libkgeomap liblastfm libmcs libmm-qt libmowgli libmsn \
libnm-qt libtermcap libva-intel-driver libwmf-docs mailx man \
mkfontdir mozjs52 mozjs60 mozjs68 mplayerthumbs nepomuk-core \
nepomuk-widgets notify-python openldap-client openssl10 \
openssl10-solibs orage oxygen-icons pairs perlkde perlqt \
phonon-gstreamer pm-utils presentproto printproto pth pykde4 pyrex \
python python-enum34 qca-qt5 qimageblitz qjson qt qt-gstreamer qtruby \
qtscriptgenerator randrproto raptor2 rasqal recordproto redland \
renderproto resourceproto rfkill rxvt scim scim-anthy scim-hangul \
scim-input-pad scim-m17n scim-pinyin scim-tables scrnsaverproto \
seamonkey-solibs sendmail sendmail-cf slocate smokegen smokekde \
smokeqt soprano strigi superkaramba tetex tetex-doc transfig trn \
urwid videoproto virtuoso-ose wicd-kde wireless-tools workbone \
xcmiscproto xextproto xf86-video-xgi xf86-video-xgixp xf86bigfontproto \
xf86dgaproto xf86driproto xf86miscproto xf86vidmodeproto xfractint \
xineramaproto xproto xv
5. IMPORTANT! *Before* attempting to reboot your system, you will need
to make sure that the bootloader has been updated for the new kernel!
First, be sure your initrd is up to date (if you use one). You can
build a new initrd automatically by running the geninitrd script:
6. Genereate initrd
edit /usr/share/mkinitrd/mkinitrd_command_generator.sh
USING_RAID="Y"
mkinitrd -c -k 5.15.19 -f ext4 -r /dev/md0 -m jbd2:mbcache:crc32c_intel:crc32c_generic:ext4 -R -u -o /boot/initrd.gz
genitrd
7. ln -s /lib64/libcrypto.so.1.1 /lib64/libcrypto.so.1
8. reboot
To recursively give directories read&execute privileges:
find /path/to/base/dir -type d -exec chmod 755 {} +
To recursively give files read privileges:
find /path/to/base/dir -type f -exec chmod 644 {} +
Or, if there are many objects to process:
chmod 644 $(find /path/to/base/dir -type f)
chmod 755 $(find /path/to/base/dir -type d)
Find files with permissions
find /path -perm 755
Change directories permissions from 750 to 755
chmod 755 $(find /path -type d -perm 750)
Change files permissions from 740 to 644
chmod 644 $(find /path -type f -perm 740)
.htaccess if statement
<If “%{REMOTE_ADDR} == ‘123.123.123.123’ || %{REMOTE_ADDR} == ‘456.456.456.456’”>
Options +Indexes
</If>
<Else>
Options -Indexes
</Else>
Resize mounted partition in Linux
You can resize only last partition at runtime
fdisk / gdisk
- Run sudo fdisk /dev/sda
- press p to list the partitions. Make note of the start cylinder of /dev/sda1 ex. 2048
- press d to delete existing partition
- press n to create new partition it is critical that the new partition starts at the same block as the old
- do not remove the signature
- press a and set boot flag
Reboot or use partprobe / kpartx to see new partition’s size
Resize filesystem
sudo resize2fs /dev/sda1
resize RAID partitions
Ensure that the RAID array is consistent and synchronized by entering
cat /proc/mdstat
If your RAID array is still synchronizing according to the output of this command, you must wait until synchronization is complete before continuing.
sudo mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
To succeed, both the fail and remove actions must be specified.
Increase the size of the partition, using a disk partitioner
Re-add the partition to the RAID array. For example, to add /dev/sda1
….
sudo mdadm -a /dev/md0 /dev/sda1
Wait until the RAID is synchronized and consistent before continuing with the next partition.
Repeat these steps for each of the remaining component devices in the array. Ensure that you modify the commands for the correct component partition.
If you get a message that tells you that the kernel could not re-read the partition table for the RAID, you must reboot the computer after all partitions have been resized to force an update of the partition table.
Remove second disk’s paritions from the RAID array:
sudo mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sdb1
sudo mdadm /dev/md1 --fail /dev/sda5 --remove /dev/sdb5
sudo mdadm /dev/md2 --fail /dev/sda6 --remove /dev/sdb6
sudo mdadm /dev/md3 --fail /dev/sda7 --remove /dev/sdb7
Check the size of the array and the device size known to the array by entering
sudo mdadm -D /dev/md0 | grep -e "Array Size" -e "Dev Size"
Increase the size of the array to the maximum available size by entering
sudo mdadm --grow /dev/md0 -z max --assume-clean
The array uses any space that has been added to the devices, but this space will not be synchronized. This is recommended for RAID 1 because the synchronization is not needed. It can be useful for other RAID levels if the space that was added to the member devices was pre-zeroed.
Recheck the size of your array and the device size known to the array by entering
sudo mdadm -D /dev/md0 | grep -e "Array Size" -e "Dev Size"
If your array was not resized as you expected, you must reboot, then try this procedure again.
You can increase the size of the file system to the maximum space available or specify an exact size. When specifying an exact size for the file system, ensure that the new size satisfies the following conditions:
- The new size must be greater than the size of the existing data; otherwise, data loss occurs.
- The new size must be equal to or less than the current RAID size because the file system size cannot extend beyond the space available.
Increase the size of the partition on second disk, using a disk partitioner
Re-add the partition to the RAID array. For example, to add /dev/sdb1..x enter:
sudo mdadm -a /dev/md0 /dev/sdb1
sudo mdadm -a /dev/md1 /dev/sdb5
sudo mdadm -a /dev/md2 /dev/sdb6
sudo mdadm -a /dev/md3 /dev/sdb7
Resize RAID partition to max size
sudo resize2fs -p /dev/md0
sudo resize2fs -p /dev/md1
sudo resize2fs -p /dev/md2
sudo resize2fs -p /dev/md3
WHEN ALL PARTITIONS ARE REBUILDED run:
mdadm --detail --scan >> /etc/mdadm.conf
OpenVPN + Google Authenticator MFA
apt install libqrencode3 libpam-google-authenticator
addgroup gauth
useradd -g gauth gauth
mkdir /etc/openvpn/google-authenticator
chown gauth:gauth /etc/openvpn/google-authenticator
chmod 0700 /etc/openvpn/google-authenticator
add line in /etc/openvpn/server.conf
plugin /usr/lib/openvpn/openvpn-plugin-auth-pam.so openvpn
create /etc/pam.d/openvpn
with content:
auth required /usr/lib/x86_64-linux-gnu/security/pam_google_authenticator.so secret=/etc/openvpn/google-authenticator/${USER} user=gauth forward_pass
-t : Set up time-based (TOTP) verification
-d : Disallow reuse of previously used TOTP tokens
–r3 : Limit logins to N per every M seconds
-R30 :
-f : Write file without first confirming with user
-l : Override the default label in “otpauth://” URL
-i: Override the default issuer in “otpauth://” URL
-s : Specify a non-standard file location
replace <username> with certificate_name
google-authenticator -t -d -r3 -R30 -f -l “<username>” -i “Company VPN” -s /etc/openvpn/google-authenticator/username
chown gauth:gauth /etc/openvpn/google-authenticator/username
KVM – VNC Server from remote host
<graphics type=”vnc” port=”5900″ autoport=”yes” listen=”SERVER_IP” passwd=”SECRET_PASSWORD”>
<listen type=”address” address=”SERVER_IP”/>
</graphics>
RRDTools
./configure –enable-perl-site-install