Linux

LVM Shenanigans

Making a larger partition from new disk space

Enlarge the partition with parted

parted (select disk)
resizepart #
100%

LVM: we need to tell the LV subsystem about the new disk space; we do this by first extending the physical volume which occupies the partition:

pvresize /dev/sdX#

then the logical volume

lvresize -r -l 100%PVS /dev/mapper/XXXXXXXX

If df -h still shows the wrong size then the above command didn't expand the FS as it should. This could be due to version issues of the tools. Run resize2fs on the mapped volume.


Moving disk space around

File system check the volume to be shrunk, then shrink it by several GB more than you will be reclaiming. It will be enlarged later. Shrink the volume by your desired amount.

Assuming an end goal of 200G

e2fsck -f /dev/foo/roo
resize2fs /dev/foo/roo 180G
lvreduce -L 200G /dev/foo/roo

Enlarge your target voume to take all now free space

lvresize -r -l 100%PVS /dev/foo/boo

Fix the filesystems

resize2fs /dev/foo/roo
resize2fs /dev/foo/boo

Discline

Available here, this terminal app provides a simple way to access discord in a minimal or covert fashion.

The docmentation is relatively straight forward, the only issue I encounted was aqcuiring the token. I used a YouTube video because the guide on the git page didn't seem to work for Chromium derivatives. This guides says hit F12, then go to your networking tab. Reload the discord page and look for the "application" field that was returned. The long string following "authorization" is your token, it can look very diffrerent from the one provided on the git page.

You can do some fun things with this, like setting your active game.

From what I can see, all basic commands are based on the client, there are not global commands that are interpreted by the server. All functionality used by the CLI client will need to be bot based.

Issues:

I have noticied that commands to switch servers and channels can be iffy, needing to be entered multiple times.

SELinux Debugging

I was looking to debug SELINUX on a new server and kept finding complex specialty commands, like here but all of those utilities are huge or not existent in default repos of Centos7, so I found more native ways to troubleshoot.

cat /var/log/audit/audit.log | grep type=AVC
getsebool -a
setsebool <bool> <on/off>

Through the logs I found that I was having issues with httpd write to a directory, cache was also in that error so I applied

semanage fcontext -a -t httpd_cache_t "/webapps/cache(/.*)?"
restorecon -Rv /webapps

This set and then applied the new policy to the offending directory.

This helped

OpenSUSE PlexMediaPlayer "CA Bundle not found"

sudo ln -s /var/lib/ca-certificates/ca-bundle.pem /etc/ssl/cert.pem

Linux Permissions

Give full control to files and directories for user and group

find /that/dir -type f -exec chmod u+rw,g+rw {} + ; find /that/dir -type d -exec chmod u+rwx,g+rwx {} +

Centos7 Root password reset

There are issues with selinux contexts if you just reset with any of the old fashion methods.

Procedure 25.5. Resetting the Root Password Using an Installation Disk

  1. Start the system and when BIOS information is displayed, select the option for a boot menu and select to boot from the installation disk.
  2. Choose Troubleshooting.
  3. Choose Rescue a Red Hat Enterprise Linux System.
  4. Choose Continue which is the default option. At this point you will be promoted for a passphrase if an encrypted file system is found.
  5. Press OK to acknowledge the information displayed until the shell prompt appears.
  6. Change the file system root as follows:
    sh-4.2# chroot /mnt/sysimage
  1. Enter the passwd command and follow the instructions displayed on the command line to change the root password.
  2. Remove the autorelable file to prevent a time consuming SELinux relabel of the disk:
    sh-4.2# rm -f /.autorelabel
  1. Enter the exit command to exit the chroot environment.
  2. Enter the exit command again to resume the initialization and finish the system boot.

I had issues with pam.d using "uid >=1000" as well, and then securetyy. I commented out the >=1000 lines from password-ac and system-auth-ac. I added tty1 to /etc/securetty

Centos 7 Static IP

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=
NETMASK=
GATEWAY=
UUID="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DEVICE="eth0"
DNS1=
DNS2=
DOMAIN=

Grep

Search recursivley though all files for a term, and only display the file name in which the term is found.
grep -nrl term

Search for 2 independent terms.
grep -e term1 -e term2 FILE

What is the difference between "|", ">", and ">>"

At the most basic command 1 | command 2 sends the output from the first command as the input for the second command (pipe reads from STDOUT and writes to STDIN).

cat file.txt | grep "tux" will print out the file, and then use it as the input for the grep command.

> and >> are basically aliases for the tee command. The tee command writes files (tee reads from STDIN and writes to STDOUT). > is an alias for | tee and >> is an alias for | tee --append

If I want to write the current files in my home directory to a file I would use ls ~/ > files.txt The output of ls is now stored in the file files.txt.

I now want to add the contents of / into the same file. But using > again will overwrite the file, it will always clear all data from a file and replace it with its own load.

To add text to the end of a file we need >>. Using ls / >> files.txt will result in the contents of ~/ being in the top of our file and the contents of / being below that.

But > and >> are just aliases for a | tee command, you cannot write to a file you do not have permission for with these. If you need sudo to write a file, you will need to hand write out the full tee command. So to add the text Banner /etc/banner to the end of our sshd_config file we will need to use the command echo "Banner /etc/banner" | sudo tee --append /etc/ssh/sshd_config