Command toolbox
Linux - Disable RH subscription manager
vi /etc/yum/pluginconf.d/subscription-manager.conf
enabled=0
Linux - Delete logs older than
find /aa/bb -name '*.log' -type f -mtime +30 -exec rm {} +
Linux - Export amount of lines of log to tar.gz
cat <log_file_name> | wc -l
sed -n '777850,805947p' <log_file_name> | gzip > <output_file_name>Linux - Pack bunch of logs in their own tar.gz
find . -type f \( -name "server.log.2021-02*" ! -name "*tar.gz" \) -exec tar czvf {}.tar.gz {} --remove-files \;Linux - VirtualHere with legacy usb printer.
This is server-client solution for sharing USB devices over network.
If you have old usb printer connected to USB in your linx server you know that cups will not provide high quality printing.
So, my HP DeskJet 920c neded encapsulation of usb. Unfortunately freely available usbip is not a solution since on client side Iām using Windows and usbip drivers for windows are not signed. Hard way you can use it but it involves mapping device and starting windows in disabled drivers signing check.
It is a pain.
Looking for solutions for it there are only commercially available solutions.
VirtuHere trial allows you use only one device on server side in trial mode with no time restrictions.
Taking under consideration my infrequent usage of printer - it is just fine.
Bellow installation covering Linux server and windows client.
Get server for your operating system from:
https://www.virtualhere.com/usb_server_software
Publish package as you want on your server.
Run first only to generate config.ini file
Move config.ini file to your favorite destination, mine is /etc/virtualhere/config.ini
Because trial gives you opportunity to work only with one USB device chose one:
lsusb
Bus 002 Device 002: ID 0bc2:231a Seagate RSS LLC Expansion Portable
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 03f0:1504 HP, Inc DeskJet 920c
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Mine ID is 03f0, so update config with:
AllowedDevices=03f0
ServerName=my_server_name
Hostname=my_server_name
Create service:
systemctl edit --full --force virtualhere.service
[Unit]
Description=VirtualHere Client
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/vhusbdx86_64 -b -c /etc/virtualhere/config.ini
[Install]
WantedBy=multi-user.target
systemctl enable virtualhere.service
systemctl start virtualhere.service
Enable access over firewall to port where your service is present.
Now get client from virtualhere page:
https://www.virtualhere.com/usb_client_software
Linux - Scale columns for ps dump
ps -eo user:20,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,group:50,args > /tmp/ps_202107010942.txtDocker - volume to containers assigment
docker ps -aq | xargs docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}'Docker - overlay to container assigment
docker inspect $(docker ps -qa) | jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"'Linux - Simple serving your http status
This is python 3.9 code that serves simple HTTP server with custom response.
It is useful for testing purposes, for example to check if your firewall is working properly.
import http.server
import socketserver
PORT = 8000
class MyHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(b"OK")
with socketserver.TCPServer(("", PORT), MyHandler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()