|

Information on Using Linux OS and Commands.


Installing GNUcash on Ubuntu using flatpack

Has instructions on installing and uninstalling newer versions.

sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.gnucash.GnuCash
flatpak update org.gnucash.GnuCash
flatpak uninstall org.gnucash.GnuCash

Once installed in terminal <flatpak run org.gnucash.GnuCash/x86_64/stable>


How can I remove hidden in linux files I mean file start with dot(.)?

rm -rf .<file-name/directory-name> to delete a single file or directory.


Desktop Shortcut creation with gnome-desktop-item-edit

https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-18-04-bionic-beaver-linux

The gnome-desktop-item-edit command may be missing as it is not installed by default. You can install it by opening up terminal and entering the following linux command:

$ sudo apt-get install --no-install-recommends gnome-panel

To create a new desktop shortcut launcher on Ubuntu 18.04 execute the following linux command:

$ gnome-desktop-item-edit ~/Desktop/ --create-new

Linux Command Handbook

This Linux Command Handbook covers 60 core Bash commands you will need as a developer. Each entry includes example code and tips for when to use that command. You can bookmark this in your browser or download a PDF version for free. (1 hour read): https://www.freecodecamp.org/news/the-linux-commands-handbook/

  • tldr terminal command
    • Usage: tldr <command you want hints for>
    • Use to find simple options for using the command in question
    • Sudo apt install tldr (to install)
  • cmatrix terminal command
  • run in terminal and it opens up a screen like seen in the Matrix Movie
  • use cmatrix –help to see options
  • sudo apt install cmatrix
  • To add ‘sudo’ to a previous command, use <sudo !!>
  • Calendar Command <cal>
    • sudo install ncal
    • cal (current month)
    • cal -y (gives current year calendar)
    • cal mo yr == cal 8 1982
    • cal -3 (gives 3 months of calendars)


nmap – use to check for ‘holes’ in home network

sudo install nmap
nmap -sT <put network IP address here>
nmpa -script vuln <put network IP address here>

Creating a New File from the Terminal

touch nameofthenewfile.filetype

Small Linux Distros

  • Lubuntu
  • Puppy Linux (may run from USB)
  • Sparky Linux
  • AntiX Linux
  • Linux Lite
  • Zorin OS Lite
  • LXLE
  • Slax (states can run from USB drive but I could not get it to boot)

Running a Python Program Directly from the Terminal

<https://realpython.com/run-python-scripts/>

You have to add a first line with the text #!/usr/bin/env python

For Python, this is a simple comment, but for the operating system, this line indicates what program must be used to run the file.

This line begins with the #! character combination, which is commonly called hash bang or shebang, and continues with the path to the interpreter.

There are two ways to specify the path to the interpreter:

  • #!/usr/bin/python: writing the absolute path
  • #!/usr/bin/env python: using the operating system env command, which locates and executes Python by searching the PATH environment variable

This last option is useful if you bear in mind that not all Unix-like systems locate the interpreter in the same place.

Finally, to execute a script like this one, you need to assign execution permissions to it and then type in the filename at the command-line.

Here’s an example of how to do this:

$ # Assign execution permissions
$ chmod +x hello.py
$ # Run the script by using its filename
$ ./hello.py
Hello World!

With execution permissions and the shebang line properly configured, you can run the script by simply typing its filename at the command-line.

Finally, you need to note that if your script isn’t located at your current working directory, you’ll have to use the file path for this method to work correctly.

Suggestion from Explaining Computers Video (on Batteries for Raspberry Pi, May 2, 2021)

  • Line to place at the top of the beginning of the python program
    • #! /user/bin/env python
  • Lines to place in Linux bash script
    • #! /bin/bash
    • /user/bin/python <full path to python file you want to run>

i3-wm Window Manager

https://i3wm.org/

i3-wm is the name of a different package than i3. i3 is a meta-package with dependencies to other packages (required: i3-wm, recommended: dunst, i3lock, i3status, suckless-tools). i3-wm is the package containing the actual files (binaries, configuration and documentation) of the i3 window manager, which is the package that needs to be removed. You can uninstall this package with <sudo apt-get purge i3-wm>

Setting VNC to Show Camera Preview on Raspberry Pi

In the Real VNC Server (running on the host computer)
Goto Options in the menu and then goto Troubleshooting
Enable ‘experimental direct captive mode’

Screenshots using Scropt

  • scrot (by itself will take a screenshot and save it to working directory)
  • scrot /path/screenshotname.png
  • scrot -u (captures the active window)
  • scrot -u -d 10 (gives a 10 second delay before the screenshot)
  • scrot -s (waits for window click or hold left mouse button to select a rectangle)
  • GUI frontend = sudo install gnome-screenshot
  • Python uses scrot in the background
    • pysimplegui
      • myscreenshot = pysimplegui.screenshot()
      • myscreenshot.save(‘/path/file)
    • pillow
      • from PIL import ImageGrab(bbox=x,y,w,h)
      • image.save(‘/path/file)
      • example of x,y,w,h ==> 0,0,700,800

Installing Linux Mint on an External Drive and Recovering from Boot Issues

  • https://www.fosslinux.com/41285/install-complete-linux-mint-on-a-usb-drive.htm
  • Format the SSD with an ext4 partition and a NTFS partition
  • Boot computer with a USB drive created with a Mint ISO
  • Once Mint is running on the computer, plug in the external SSD drive
  • Click on installing Mint
  • Installation Type = Something else
  • Pick sdb1 (the drive you want to install to) ext4
  • Use As: ext4 journaling file system
  • Follow the install instructions
  • This will create an SSD that will boot but may make it so that the computer used to make the SSD may no longer boot with the SSD plugged in
  • To Fix the above issue where the computer will not boot without the attached drive
    • https://www.hackerearth.com/practice/notes/akshaypai94/grub-rescue/
    • unplug the external SSD
    • boot the computer
    • when you get to the ‘grub’ prompt:
      • use ls to get list of drives and find the drive with the boot directory
      • do not use the EFI partition
      • at the grub prompt:
        • set prefix=(hd0, gpt2)/boot/grub
        • set root=(hd0, gpt2)
        • insmod normal
        • normal
      • the computer should automatically boot
      • after it boots, open the Terminal and type:
        • sudo update-grub
        • sudo grub-install /dev/sda
      • this should fix the boot issue and the computer should boot without the SSD attached now

Capturing Video Using Linux

Setting up Alternatives for Python Versions

  • sudo -alternatives –config python3
  • pick the version you want to make default

Finding Current IP Address use <ip a>

Finding PUID and PGID

  • Useful for setting up Docker containers
  • PUID = user ID
  • PGID = group ID
  • Find using either:
    • ‘id $user’ or just ‘id’ in a Linux Terminal
    • id -u user (give the id of the user, for example id -g pi
    • id -g user (gives the id of the group the user belongs to)

Working with PDF Files, Combining PDFs using Poppler

  • Debian / Ubuntu-based distros: sudo apt install poppler-utils
  • Use the pdfseparate command to extract all the pages into individual PDF pages.
    • pdfseparate final_pdf.pdf final_pdf-page_%d.pdf
    • You can also export a range of pages. For example, use the following command to extract pages 25,26,27,28,29,30 and 31 of a PDF document.
      • pdfseparate -f 25 -l 31 FOSSBook.pdf FOSSBook-page_%d.pdf
  • Merge PDFs with pdfunite
    • pdfunite pdf_1.pdf pdf_2.pdf merged_file.pdf
    • pdfunite *.pdf merged_file.pdf

Mount a USB Drive to the Raspberry Pi

  • https://pimylifeup.com/raspberry-pi-mount-usb-drive/
  • To check where the drive has been mounted:
    • sudo cat /proc/mounts
  • Find UUID directly:
    • ls -l /dev/disk/by-uuid
  • Find name of drive:
    • df -h
  • Find information about drive:
    • sudo blkid /dev/sda1 (replace /dev/sda with name of drive above)
  • make a directory where we will mount our drive to
    • sudo mkdir -p /mnt/usb1
  • Give pi ownership of the folder
    • sudo chown -R pi:pi /mnt/usb1
    • to give full access to a directory
      • sudo chmod 777 <directory path/name>
  • Modify the fstab file to make it available every boot:
    • sudo nano /etc/fstab
      • add to the bottom of the file:
      • UUID=[UUID] /mnt/usb1 [TYPE] defaults,auto,users,rw,nofail,noatime 0 0
    • save the fstab file
    • unmount the drive
      • sudo umount /dev/sda1
    • remount the drive:
      • sudo mount -a
    • reboot

Installing KDE Plasma over Raspberry Pi OS (From leepspvideo, March 30, 2022)

  • sudo apt install kde-plasma-desktop
  • pick the ‘sddm’ option when it is offered
  • reboot and log back in choosing the plasma option from the top left dropdown list
  • open start menu and search for ‘compositor’ and turn it off
  • add h264ify to chromium and block 60 fps video playback
  • to use the windows key after adding a new desktop
  • right click on the menu, configure launcher, change none to alt-win-F1 (might need the function key)

Bash Scripting

  • Script naming: nameofscript.sh
    • Simple way to create a script is to use: nano nameofscript.sh
  • Start script with: #!/bin/bash or, in general, #!pathtolanguage such as python
  • Run a script with: bash nameofscript.sh
  • Make a script executable with: chmod +x nameofscript.sh
    • Then you can run the script using: ./nameofscript.sh
  • Use ls – l to get a list of files and their permissions
  • Bash Scripting Tutorial – Linux Shell Script and Command Line for Beginners

How to Search and Find Files in Terminal

Changing a File’s Timestamp

  • Using the Linux ‘touch’ command
    • https://linuxize.com/post/linux-touch-command/#setting-specific-timestamps

Ln Command in Linux (Create Symbolic Links)

  • A symbolic link, also known as a symlink or soft link, is a special type of file that points to another file or directory.
  • https://linuxize.com/post/how-to-create-symbolic-links-in-linux-using-the-ln-command/
  • To create a symbolic link to a given file, open your terminal and type:
    • ln -s source_file symbolic_link
    • Replace source_file with the name of the existing file for which you want to create the symbolic link and symbolic_link with the name of the symbolic link.
    • ln -s my_file.txt my_link.txt

Attribute Changing Terminal Commands

  • Use the touch command to set a specific timestamp for an existing file:
    • touch -t <timestamp> <filename>
    • The timestamp format follows a specific pattern:
      • [[CC]YY]MMDDhhmm[.ss]
  • The touch command uses the -d option to set a timestamp using a date string:
    • touch -d <string> <filename>
    • touch-d ’12 June’ filenamehere #will change the timestamp to current year
    • The date string is a flexible time format and accepts many different human-readable textual forms. Some examples include:
      • Calendar dates, such as 19 August 2020.
      • Time of day, such as 9:27pm or 8:02am.
      • Days of the week, such as SundayMonday, etc.
      • Relative time, such as 5 years agoyesterdaynext tuesday, etc.

Youtube Keyboard Commands or Shortcuts

  • Spacebar = play or pause
  • Left or Right Arrows = back or forward 5 seconds
  • m = mute
  • i (lower case)= back 10 seconds
  • I (upper case) = forward 10 seconds
  • f = full screen
  • F or ESC = exit full screen
  • c = closed caption on
  • C = closed caption off

Keyboard Shortcuts for Linux

  • Win Key + Arrows == move the application around the screen and dock it to different areas
  • Ctrl + Alt + Arrows == switches desktops (work spaces)

SSH Installation and Activation

  • Enable SSH
    • sudo apt install openssh-server
    • sudo ufw allow ssh
    • /sbin/service sshd start
  • Disable SSH
    • sudo systemctl disable –now ssh
  • Re-enable SSH
    • sudo systemctl enable –now ssh
  • Status
    • /sbin/service sshd status
    • sudo systemctl status ssh
  • Shell in a Box
    • terminal based in a web browser using port 4200
    • sudo apt install shellinabox
    • https://<the ip address here>:4200
  • Using SSH to connect and get programs to run in GUI mode
    • ssh -X username@ipaddress
    • Seems to work with programs like GNUCash

Armbian Linux

  • Installing Discover Software Store
    • sudo apt-get install plasma-discover
  • Installing Snap Store
    • sudo apt install snapd
    • sudo apt install core
    • sudo apt install snapd-store

Setting Up a Realtek Wifi USB Card

  • lshw -C network
  • ls usb or sudo lsusb -v
  • https://fostips.com/realtek-wifi-drivers-ubuntu-linux-mint/
  • Using the add through PPA method worked — To add Kelebek repository
    • sudo add-apt-repository ppa:kelebek333/kablosuz
    • sudo apt-get update
    • sudo apt-get install rtl8188fu-dkms
    • (Optional) To purge the now-no-longer-needed packages
      • sudo apt purge rtl8188fu-dkms
  • echo “options rtl8188fu rtw_ips_mode=0” | sudo tee /etc/modprobe.d/rtl8188fu.conf
    • Then key in and press Enter:
      • sudo modprobe -rv rtl8188fu && sudo modprobe -v rtl8188fu
      • Reboot
      • Find the Ubuntu drivers install in settings
      • Install the driver
      • Pick the network

  • if needed: sudo apt purge rtl8188fu-dkms

HP 600 G3 Hints

  • Boot Menu
    • Press the ESC key during boot up
    • Pick the choice under F9
  • Drive Options
    • PCIe NMVe TLC SSD M.2 2280 M-Key
    • M.2 /4x PCIe 4.0 /NVMe
  • WiFi Card
    • Wifi and Bluetooth M.2 2230
  • Memory
    • 1.2v DDR4-SDRAM
    • Unbuffered non ECC 260 pin
    • CAS latency 15 DDR4 2400 mHz )15-15-15 timing)

Installing USB Wifi Adapter Realtek

  • Try installing drivers from the settings menu
  • sudo add-apt-repository ppa:kelebek333/kablosuz
  • sudo apt update
  • sudo apt install rtl8188fu-dkms
  • Another option: https://askubuntu.com/questions/1018375/how-do-i-install-driver-for-rtl88x2bu
    • One suggestion
      • sudo apt update
      • sudo apt install dkms bc git
      • git clone https://github.com/cilynx/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959
      • sudo dkms add ./rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959
      • sudo dkms install -m rtl88x2bu -v 5.3.1
      • sudo modprobe 88x2bu

Installing Bluetooth Adapter

Installing Drivers for USB WiFi Bluetooth Adapter, 1300Mbps Dual Band 2.4/5Ghz Wireless Network External Receiver, Mini WiFi Dongle (Auscoumer)

Installing Intel Wifi Module and Drivers

Installing WiFi Drivers in Kali Linux

  1. https://www.youtube.com/watch?v=aXagM9G_nFE&list=TLPQMjgxMTIwMjPXW4nm-Q0Czw&index=10
  2. If you have installed kali linux on a VMWare workstation or even on your physical machine, you may be able to try and use this steps mentioned in the tutorial.
  3. If you have installed KALI on a fresh pc or vm then you may find your wifi network adapter not functioning, this tutorial is to get you on board with wifi support post kali linux installation
  4. Procedure 1: Check if your wifi driver is installed In terminal type – ifconfig / airmon-ng 
  5. Procedure 2: If you haven’t found any wlan0 or wlan1 on the kali network settings, please install wifi driver 
  6. Procedure 3: Download link for the driver is http://linuxwireless.sipsolutions.net…
  7. Procedure 4: Post downloading the driver pack from the above link, go to the downloaded folder and then open a terminal by right clicking inside the download folder. Now extract the content of the file using the command below tar – jxvf compat-wireless-2010-06-26-p 
  8. Procedure 5: Post extraction, get inside the extracted folder and use the below command to setup your wifi driver
    • Make unload (Wait for the unload to complete before executing command two)
    • Make load
  9. Supported Wireless cards: Alfa Long-Range Dual-Band AC1200 – Alfa AWUS036NHA – Alfa AWUSO36NH – Alfa AWUS036NEH – Alfa AC1900 – Alfa Long-Range Dual-Band AC1200 – Panda Wireless PAU06 – Panda Wireless PAU09 – TP-Link TL-WN722N
  10. Note: Inbuilt WIFI adapter have compatibility issue with Kali Linux

Installing Ventoy to a USB Drive Using Terminal

Copy Specific Files Using Find and CP (copy) Commands

Copy Files Using the Rsync Command

  • rsync <Command> <Source/> <Target/>
  • archive = -a
  • do a dry run –dry-run
  • verbose(gets list) -v
  • human readable format -h
  • delete files in Target that are not in the Source –delete
  • shows progress -P
  • compress files for transfer (best for network copy) -z
  • prune empty directories -m
  • allow resuming aborted syncs –partial or -n
  • all directories included (use a trailing /) -r
  • can combine options for example -avr
  • example:
    • rsync -avr include=”*.JPG” exclude=”*.*” ~/media/marc/172E-7A4E/Pictures-2018 ~/media/marc/One Touch

Missing Terminal After Python Upgrade

Checking for Malware

Switching Python versions – Alternatives

  • In the terminal use the following commands:
    • update-alternatives –config python3
    • update-alternatives –list python3

Install kvm on ubuntu

Editing the UEFI Boot Menu

  • sudo nano /etc/default/grub
    • Edit this file and change the default from 0 to the number of the item you want to boot
  • In Linux, efibootmgr can do the job: Type efibootmgr or efibootmgr -v to see the entries, then do efibootmgr -b # -B to delete entry #. (You must type these commands as root or using sudo.)
  • https://www.tecporto.pt/wiki/index.php/Removing_an_entry_from_the_UEFI_boot_list_(Linux)

Create a Custom ISO Image Using Cubic

How to fix ‘ModuleNotFoundError: No module named ‘apt_pkg’?

  • On Ubuntu 18.04, use this $ cd /usr/lib/python3/dist-packages $ sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
  • This worked for me as well… I listed all the files on the /usr/lib/python3/dist-packages, and I saw that I didn’t have of apt_pkg.cpython-34m-i386-linux-gnu.so or apt_pkg.cpython-3m-i386-linux-gnu.so, but I had apt_pkg.cpython-36m-i386-linux-gnu.so… I copied this file to apt_pkg.so and worked perfectly!

Changing Boot Order UEFI

  • https://www.technewstoday.com/how-to-change-boot-order-on-linux/
  • Start by creating a backup of the config file with the following command: sudo cp /etc/default/grub /etc/default/grub.bak
  • open the config file with a text editor. We’ll use nano. sudo nano /etc/default/grub
  • Change the value of the GRUB_DEFAULT line according to your current boot menu order.
  • update GRUB with sudo update-grub

SSD Health and Monitoring

Hard Drive Cloning

  • Download clonezilla from clonezilla.org
    • use the alternative stable ubuntu version
  • use gparted to check disk status and size
    • if cloning Windows, use Windows checkdisk (chkdsk) to test disk before using gparted
  • Cloning a Hard Drive: Options to choose
    • device-device
    • Beginner mode
    • disk to local disk
    • choose keep Clonezilla running
    • copy disk’s bootloader -Y

Install Flatpak on Ubuntu running Plasma Desktop

Samba Installing and Using

Adding Microsoft Fonts to Linux

  • sudo apt install ttf-mscorefonts-installer

Ubuntu Server

  • adding a desktop GUI to Server
    • sudo apt-get install xfce4-session xface4-goodies
    • sudo apt install kde-plasma-desktop
    • sudo apt install mate-desktop-environment
  • adduser <username you want to add>
  • usermod -aG sudo <user you just created> (adds the new user to the sudo group)
  • set permit root login to No for ssh access
    • sudo nano /etc/ssh/sshd_config
    • sudo systemctl restart ssh

Installing and Removing Vivaldi

  • https://itsfoss.com/install-vivaldi-ubuntu-linux/
  • Installing
    • echo “deb [signed-by=/usr/share/keyrings/vivaldi-browser.gpg arch=$(dpkg –print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main” | sudo dd of=/etc/apt/sources.list.d/vivaldi-archive.list
    • wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg –dearmor | sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg
    • sudo apt update && sudo apt install vivaldi-stable
  • Removing
    • sudo apt remove vivaldi-stable
    • rm -rf ~/.config/vivaldi
    • rm -rf ~/.cache/vivaldi

Cloudflare Zero Trust Tunnels

  • Domain
    • SSL/TLS
    • Edge Certificate
    • Always use –HTTPS, –Turn on
  • Zero Trust
    • Authentication
    • One Time Pin
    • Access
      • applications
      • selfhosted
    • give application a name
    • put an * in subdomain box
    • policy name = default
    • configure rules = email
    • add your email

Root Access

  • sudo su
  • cd /. or cd .root/
  • sudo chmod o+x /root/

Nala

  • Use Nala to update Linux systems from multiple mirrors at once
  • Sudo nala install
  • sudo nala fetch (to choose the mirror sites)
  • sudo nala update
  • sudo nala upgrade

Bash Commands

  • mkdir -p <nameyouwantfordirectory>
    • use this to create a new directory, it will check to make sure one does not already exists
  • ip -4 -brief a
    • easier to fine the ip address, less additional information shows up
  • Fun bash commands, can be installed using sudo apt install
    • btop
    • ranger (file manager)
    • fastfetch
      • sudo add-apt-repository ppa:zhangsongcui3371/fastfetch
      • sudo apt update
      • sudo apt install fastfetch
    • lsd
    • ncdu
    • hollywood
  • use in SSH to unlock the session
    • loginctl unlock-sessions

Virtual Screen – add tablet as a second monitor

Fix for a Broken Install

  • sudo apt –fix-broken install
  • possible fix for not booting at all
    • boot from a live cd into a temporary instance of ubuntu
    • sudo add-apt-repository ppa.yannubuntu/boot-repair
    • sudo apt update
    • sudo apt install boot-repair
    • boot-repair
      • follow instructions

3 Comments

Comments are closed.