Linux Tips
This is just a collection of notes for various projects I am working on. The categories of notes are at the top nav bar.
Create a Temporary Proxy Using Only Netcat
Use the following to create a temporary tcp proxy using only netcat:
nc -l <source port> --sh-exec "nc localhost <dest port>"
- Read more about Create a Temporary Proxy Using Only Netcat
- Log in to post comments
See Journalctl Log Since Last Reboot
How to see the journal log up to your last reboot. This comes in handy if you system locks up. You can run this after the reboot to find any errors:
journalctl -b -1 -e
The "-e" will drop you to the bottom of the list.
- Read more about See Journalctl Log Since Last Reboot
- Log in to post comments
Extract Public SSH Key from Private Key
The following will extract the public key from a private key. This assumes your private key is call id_rsa and public key is called id_rsa.pub. This can also be used to validate a public/private key are a match.
ssh-keygen -y -f .ssh/id_rsa
This should match the output of the following:
cat .ssh/id_rsa.pub
- Read more about Extract Public SSH Key from Private Key
- Log in to post comments
Install a User Service for a Podman Container
Create a User based service file:
cd ~/.config/systemd/user podman generate systemd CONTAINER-NAME > container-CONTAINER-NAME.service
Edit the service file and comment out the PID= section. The allows you to not have to create a new service file each time you re-create the container.
Reload the systemctl dameon as root:
systemctl dameon-reload
Enable/start the service up. Do this as the user it will run as:
systemctl --user enable container-CONTAINER-NAME systemctl --user start containre-CONTAINER-NAME
- Read more about Install a User Service for a Podman Container
- Log in to post comments
Best Way to Upgrade Fedora via Command Line
Upgrading via the Software application can have issues. If it has any issues at all it just fails leaving your system partially upgraded. This method is much safer and give you the ability to fix any issues as you find them. Also don't try to jump more than 2 versions at a time (ie. 35 to 37).
Before you even get started I like to backup my grub.conf file and remove all kernels accept the current one just to get a cleaner start:
- Read more about Best Way to Upgrade Fedora via Command Line
- Log in to post comments
Remove a File with a Dash (-) in the Beginning
To remove file in Linux that has a hyphon or dash in front of it just prefix it with "./". For example:
rm ./-testfile
- Read more about Remove a File with a Dash (-) in the Beginning
- Log in to post comments
Reset SSH password on OctoPrint
1. power off the pi, remove the MicroSD card, and put that in a PC.
2. Then in the drive called "boot", create a file named "octopi-password.txt"
3. In that text file ("octopi-password.txt") you only need the password you want to set for the "pi" user, nothing else. So it will be one word only in this file.
4. Now take the MicroSD out of the PC, install it in the pi and boot it.
5. You can now log in again using SSH, with username "pi" and the password you set in the file "octopi-password.txt".
- Read more about Reset SSH password on OctoPrint
- Log in to post comments
View Logs of Last Boot
To use journalctl to view the logs of the last reboot use the following:
journalctl --boot=-1
This command is handy for viewing logs right before a crash. Do the above command then use shift-g to go to the bottom of the list.
- Read more about View Logs of Last Boot
- Log in to post comments
Find History of RPMs
To find the install history of a specific RPM do the following:
rpm -q --last <package name>
To find the install history of all RPMs do the following:
rpm -qa --last
NOTE: This will not sort them by install date.
- Read more about Find History of RPMs
- Log in to post comments