How to Change Forgotten Password on WSL (Bash for Windows)

Linux Bash Windows

So you have installed Bash for Windows, but forgot your password!! That’s easy to fix, and here’s how:

a. Find your username by running Bash for Windows and executing whoami

$ whoami
victor_m

b. Change the default user to root by running the code below on a Windows command prompt (cmd.exe)

LxRun.exe /setdefaultuser root

c. Now change the password with bash -c 'passwd [user]' (also on the Windows command prompt)

bash -c 'passwd victor_m'
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

d. Change the default user back to your user

LxRun.exe /setdefaultuser victor_m

e. Profit

How to Fix Sddm on Multiple Screens

Linux KDE

When running multiple screens on KDE with SDDM, your configuration will not be loaded until you actually login to the KDE desktop, so you might end up having screens out of order, or enabled/disabled when they should not be. To fix this is simple, and here’s how.

Let’s get a list of the devices name, size and position with xrandr:

$ xrandr | grep ' connected'

DP-1 connected (normal left inverted right x axis y axis)
DP-3 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 480mm x 270mm
DP-5 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 598mm x 337mm

As you can see, on my computer I have 3x monitors:

  • DP-1 - Connected on the first port but disabled
  • DP-3 - My secondary monitor; Resolution 1920x1080; position 1920x0
  • DP-5 - My main monitor; Resolution 1920x1080; position 0x0

So we will start by adding the right configuration to /usr/share/sddm/scripts/Xsetup

$ sudo vim /usr/share/sddm/scripts/Xsetup

#!/bin/sh
# Xsetup - run as root before the login dialog appears

xrandr --output DP-1 --off
xrandr --output DP-5 --mode 1920x1080 --pos 0x0 --rotate normal --output DP-3 --mode 1920x1080 --pos 1920x0 --rotate normal

Explanation:

  • The first line disables the monitor connected to the first port xrandr --output DP-1 --off
  • The second line sets the right dimension and position for my other two monitors

Now we need to add the config to SDDM:

$ sudo vim /etc/sddm.conf

[XDisplay]
# Xsetup script path
# A script to execute when starting the display server
DisplayCommand=/usr/share/sddm/scripts/Xsetup

And now a simple reboot will take care of the changes:

sudo reboot

Installing Kuman 3

Linux Hardware

Simple instructions (assuming a new Raspbian install) to install Kuman 3.5 TFT LCD on Raspberry Pi 3 Model B.

a. Download Rasbian strech (with desktop) and extract the .img file from the downloaded zip (it’s always good to also check the hash of the downloaded file)

b. Insert the SD card and make note of the device being used (make sure you get this right not to overwrite your OS)

c. Use dd to copy the image to the SD card (the values for if and of should be changed accordingly. If you never used dd please do yourself a favor and read up first)

sudo dd bs=4M if=2018-04-18-raspbian-stretch.img of=/dev/mmcblk0 status=progress oflag=sync

d. Once the process is done, mount (if needed) the boot and rootfs partitions

e. Browse to the mount point of boot and create a blank file called ssh (to enable sshd on boot)

touch ssh

f. Open cmdline.txt and write down the value of root=. Now substitute the existing line with the line below, and then change the value of root= back to the original value

dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo

g. Open config.txt and add the lines below to the end of the file

dtparam=audio=on
dtparam=spi=on
dtoverlay=ads7846,penirq=25,penirq_pull=2,xohms=150,swapxy=1,xmin=300,ymin=700,xmax=3800,ymax=3400,pmax=255
dtoverlay=waveshare35a

h. Download waveshare35a-overlay.dtb from GitHub to /boot/overlays and rename it to waveshare35a.dtbo

i. Change Option "fbdev" "/dev/fb0" in /usr/share/X11/xorg.conf.d/99-fbturbo.conf to Option "fbdev" "/dev/fb1"

Section "Device"
    Identifier "Allwinner A10/A13 FBDEV"
    Driver "fbturbo"
    Option "fbdev" "/dev/fb1"

    Option "SwapbuffersWait" "true"
EndSection

j. Create a new file /etc/X11/xorg.conf.d/99-calibration.conf with the lines below

Section "InputClass"
    Identifier "calibration"
    MatchProduct "ADS7846 Touchscreen"
    Option "Calibration" "3932 300 294 3801"
    Option "SwapAxes" "1"
EndSection

k. Reboot and enjoy


References

Creating a Simple Systemd User Service

Linux Systemd

Quick instructions on how to create a simple systemd user service for a program or script.

1- Identify the script or program/binary that you will be using

2- Create a systemd unit file using the example below, give it a name that will make sense to you with a .service extension (like [my_service].service), and save it to $USER/.config/systemd/user

[Unit]
Description=[Service description]

[Service]
Type=simple
StandardOutput=journal
ExecStart=[script path]

[Install]
WantedBy=default.target

For this example we used a service type simple, which allows systemd to take care of the most basic needs for us. The options used are:

  • Description = Description of your service. This will be shown when handling your service with systemctl
  • Type = We will be using the simple type, and this could be left out
  • StandardOutput = We will be logging it to the system log (you can use journalctl to view it)
  • ExectStart = The script or program to be executed
  • WantedBy = Service will be run using the default target. You can find what the default.target is with systemctl get-default

3- Enable your service so it starts automatically

systemctl --user enable [my_service].service

4- Start the service

systemctl --user start [my_service].service

4- Check that it’s running

systemctl --user status [my_service].service

How to Scan for RTSP Urls

Linux Shell Networking

So you have a camera but can’t figure out what the RTSP URL is? Here’s the solution.

Head over to nmap.org and download their rtsp-url-brute script to your computer. Then run it with nmap as:

nmap --script rtsp-url-brute -p 554 [IP]

You should see results similar to the ones below:

nmap --script rtsp-url-brute -p 554 192.168.1.15

Starting Nmap 7.60 ( https://nmap.org ) at 2018-02-09 23:00 EST
Nmap scan report for 192.168.1.15
Host is up (0.0033s latency).

PORT    STATE SERVICE
554/tcp open  rtsp
| rtsp-url-brute:
|   errors:
|     rtsp://192.168.1.15/media.amp
|     rtsp://192.168.1.15/media/media.amp
|     rtsp://192.168.1.15/media/video1
|     rtsp://192.168.1.15/media/video2
|     rtsp://192.168.1.15/media/video3
|     rtsp://192.168.1.15/medias1
|     rtsp://192.168.1.15/mjpeg.cgi
|     rtsp://192.168.1.15/mjpeg/media.smp
|     rtsp://192.168.1.15/media
|     rtsp://192.168.1.15/mp4
|   discovered:
|     rtsp://192.168.1.15/
|     rtsp://192.168.1.15/1
|     rtsp://192.168.1.15/1.AMP
|     rtsp://192.168.1.15/1/1:1/main
|     rtsp://192.168.1.15/1/cif
|     rtsp://192.168.1.15/1/stream1
|     rtsp://192.168.1.15/11
|     rtsp://192.168.1.15/12
|   other responses:
|     400:
|       rtsp://192.168.1.15/0
|       rtsp://192.168.1.15/0/video1
|       rtsp://192.168.1.15/4
|       rtsp://192.168.1.15/CAM_ID.password.mp2
|       rtsp://192.168.1.15/CH001.sdp
|       rtsp://192.168.1.15/GetData.cgi
|       rtsp://192.168.1.15/H264
|       rtsp://192.168.1.15/HighResolutionVideo
|       rtsp://192.168.1.15/HighResolutionvideo
|       rtsp://192.168.1.15/Image.jpg
|       rtsp://192.168.1.15/LowResolutionVideo
|       rtsp://192.168.1.15/MJPEG.cgi
|       rtsp://192.168.1.15/MediaInput/h264
|       rtsp://192.168.1.15/MediaInput/h264/stream_1
|       rtsp://192.168.1.15/MediaInput/mpeg4
|       rtsp://192.168.1.15/ONVIF/MediaInput
|       rtsp://192.168.1.15/ONVIF/channel1
|       rtsp://192.168.1.15/PSIA/Streaming/channels/0?videoCodecType=H.264
|       rtsp://192.168.1.15/PSIA/Streaming/channels/1
|       rtsp://192.168.1.15/PSIA/Streaming/channels/1?videoCodecType=MPEG4
|       rtsp://192.168.1.15/PSIA/Streaming/channels/h264
|       rtsp://192.168.1.15/Possible
|       rtsp://192.168.1.15/ROH/channel/11
|       rtsp://192.168.1.15/Streaming/Channels/1
|       rtsp://192.168.1.15/Streaming/Channels/101
|       rtsp://192.168.1.15/Streaming/Channels/102
|       rtsp://192.168.1.15/Streaming/Channels/103
|       rtsp://192.168.1.15/Streaming/Channels/2
|       rtsp://192.168.1.15/Streaming/Unicast/channels/101
|       rtsp://192.168.1.15/Streaming/channels/101
|       rtsp://192.168.1.15/Video?Codec=MPEG4&Width=720&Height=576&Fps=30
|       rtsp://192.168.1.15/VideoInput/1/h264/1
|       rtsp://192.168.1.15/access_code
|       rtsp://192.168.1.15/access_name_for_stream_1_to_5
|       rtsp://192.168.1.15/av0_0
|       rtsp://192.168.1.15/av0_1
|       rtsp://192.168.1.15/av2
|       rtsp://192.168.1.15/avn=2
|       rtsp://192.168.1.15/axis-media/media.amp
|       rtsp://192.168.1.15/axis-media/media.amp?videocodec=h264&resolution=640x480
|       rtsp://192.168.1.15/cam
|       rtsp://192.168.1.15/cam/realmonitor
|       rtsp://192.168.1.15/cam/realmonitor?channel=1&subtype=00
|       rtsp://192.168.1.15/cam/realmonitor?channel=1&subtype=01
|       rtsp://192.168.1.15/cam/realmonitor?channel=1&subtype=1
|       rtsp://192.168.1.15/cam0_0
|       rtsp://192.168.1.15/cam0_1
|       rtsp://192.168.1.15/cam1/h264
|       rtsp://192.168.1.15/cam1/h264/multicast
|       rtsp://192.168.1.15/cam1/mjpeg
|       rtsp://192.168.1.15/cam1/mpeg4
|       rtsp://192.168.1.15/cam1/onvif-h264
|       rtsp://192.168.1.15/cam4/mpeg4
|       rtsp://192.168.1.15/camera.stm
|       rtsp://192.168.1.15/cgi-bin/viewer/video.jpg?resolution=640x480
|       rtsp://192.168.1.15/ch0
|       rtsp://192.168.1.15/ch0.h264
|       rtsp://192.168.1.15/ch001.sdp
|       rtsp://192.168.1.15/ch01.264
|       rtsp://192.168.1.15/ch0_0.h264
|       rtsp://192.168.1.15/ch0_unicast_firststream
|       rtsp://192.168.1.15/ch0_unicast_secondstream
|       rtsp://192.168.1.15/channel1
|       rtsp://192.168.1.15/dms.jpg
|       rtsp://192.168.1.15/dms?nowprofileid=2
|       rtsp://192.168.1.15/h264
|       rtsp://192.168.1.15/h264.sdp
|       rtsp://192.168.1.15/h264/ch1/sub/
|       rtsp://192.168.1.15/h264/media.amp
|       rtsp://192.168.1.15/h264Preview_01_main
|       rtsp://192.168.1.15/h264Preview_01_sub
|       rtsp://192.168.1.15/h264_vga.sdp
|       rtsp://192.168.1.15/image.jpg
|       rtsp://192.168.1.15/image.mpg
|       rtsp://192.168.1.15/image/jpeg.cgi
|       rtsp://192.168.1.15/img/media.sav
|       rtsp://192.168.1.15/img/video.asf
|       rtsp://192.168.1.15/img/video.sav
|       rtsp://192.168.1.15/ioImage/1
|       rtsp://192.168.1.15/ipcam.sdp
|       rtsp://192.168.1.15/ipcam/stream.cgi?nowprofileid=2
|       rtsp://192.168.1.15/ipcam_h264.sdp
|       rtsp://192.168.1.15/jpg/image.jpg?size=3
|       rtsp://192.168.1.15/live
|       rtsp://192.168.1.15/live.sdp
|       rtsp://192.168.1.15/live/av0
|       rtsp://192.168.1.15/live/ch0
|       rtsp://192.168.1.15/live/ch00_0
|       rtsp://192.168.1.15/live/ch00_1
|       rtsp://192.168.1.15/live/ch1
|       rtsp://192.168.1.15/live/ch2
|       rtsp://192.168.1.15/live/h264
|       rtsp://192.168.1.15/live/mpeg4
|       rtsp://192.168.1.15/live0.264
|       rtsp://192.168.1.15/live1.264
|       rtsp://192.168.1.15/live1.sdp
|       rtsp://192.168.1.15/live2.sdp
|       rtsp://192.168.1.15/live3.sdp
|       rtsp://192.168.1.15/live_h264.sdp
|       rtsp://192.168.1.15/live_mpeg4.sdp
|       rtsp://192.168.1.15/livestream
|_      rtsp://192.168.1.15/livestream/
code with