Squoggle
Mac's tech blog
Tag Archives: Linux
How To Configure Linux Raid
March 15, 2023
Posted by on Scenario: You have a Linux Server that has a boot drive and two additional hard drives you want to configure in a RAID array as data drives. This How To will demonstrate how to create a RAID 1 array using two physical drives in a server that is already up and running.
RAID 1 is disk mirroring. I want to mirror one disk to the other. In case one physical drive fails I can drop the bad drive from the RAID array, install a new drive and then add the new drive to the Array and rebuild the new disk to mirror the existing disk.
RAID can be implemented via hardware or software. With Hardware RAID the RAID configuration is done directly on the hardware. Typically this is configured in the controller itself or in the system’s BIOS. This How To is about Software RAID and is therefore done from the existing running OS.
In this scenario I have an existing running Ubuntu 22.04 LTS Virtual Machine server running and I have added two 1 GB SCSI drives.
List Disks
The first step is to get information about the disks on your system:
$ sudo lshw -class disk
*-cdrom
description: DVD reader
product: CD-ROM
vendor: VBOX
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/cdrom
logical name: /dev/sr0
version: 1.0
capabilities: removable audio dvd
configuration: ansiversion=5 status=nodisc
*-disk
description: ATA Disk
product: VBOX HARDDISK
vendor: VirtualBox
physical id: 0.0.0
bus info: scsi@2:0.0.0
logical name: /dev/sda
version: 1.0
serial: VB819a3b95-f514a971
size: 25GiB (26GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=5 guid=e2bb1f14-9526-4dd6-be4c-5aabb4b48723 logicalsectorsize=512 sectorsize=512
*-disk:0
description: SCSI Disk
product: HARDDISK
vendor: VBOX
physical id: 0.0.0
bus info: scsi@3:0.0.0
logical name: /dev/sdb
version: 1.0
size: 1GiB (1073MB)
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512
*-disk:1
description: SCSI Disk
product: HARDDISK
vendor: VBOX
physical id: 0.1.0
bus info: scsi@3:0.1.0
logical name: /dev/sdc
version: 1.0
size: 1GiB (1073MB)
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512
Notice that Disk 0 and Disk 1, both SCSI disks are the two disks that will be used for the RAID 1 device. The single ATA disk is where the operating system is installed on this system. Disk 0’s logical device name is /dev/sdb and Disk 1’s logical device name is /dev/sdc.
Partition Disks
The two disks need to have a partition created on them. I do not plan on having these two data drives be bootable so I do not need to create a master boot record on them.
Use the fdisk tool to create a new partition on each drive and format them as a Linux raid autodetect file system:
$ sudo fdisk /dev/sdb
Follow these instructions:
- Type n to create a new partition.
- Type p to select primary partition.
- Type 1 to create /dev/sdb1.
- Press Enter to choose the default first sector
- Press Enter to choose the default last sector. This partition will span across the entire drive.
- Typing p will print information about the newly created partition. By default the partition type is Linux.
- We need to change the partition type, so type t.
- Enter fd to set partition type to Linux raid autodetect.
- Type p again to check the partition type.
- Type w to apply the above changes.
Do the same thing for the second drive:
$ sudo fdisk /dev/sdc
Follow the same procedure as above.
You should now have two raid devices created /dev/sdb1 and /dev/sdc1.
MDADM
The mdadm tool is used to administer Linux MD arrays (software RAID). The mdadm utility can be used to create, manage, and monitor MD (multi-disk) arrays for software RAID or multipath I/O.
View or examine the two devices with mdadm:
$ sudo mdadm --examine /dev/sdb /dev/sdc
$ sudo mdadm --examine /dev/sdb /dev/sdc
/dev/sdb:
MBR Magic : aa55
Partition[0] : 2095104 sectors at 2048 (type fd)
/dev/sdc:
MBR Magic : aa55
Partition[0] : 2095104 sectors at 2048 (type fd)
You can see that both are the type fd (Linux raid autodetect). At this stage, there’s no RAID setup on /dev/sdb1 and /dev/sdc1.
You can see that /dev/sdb1 and /dev/sdc1 don’t have RAID set up yet with this command:
$ sudo mdadm --examine /dev/sdb1 /dev/sdc1
$ sudo mdadm --examine /dev/sdb1 /dev/sdc1
mdadm: No md superblock detected on /dev/sdb1.
mdadm: No md superblock detected on /dev/sdc1.
Notice that there are no superblocks detected on those devices.
Create RAID Logical Device
Now create a RAID 1 logical device named /dev/md0 using the two devices /dev/sdb1 and /dev/sdc1:
$ sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
The –level=mirror flag creates this device as a RAID 1 device.
$ sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
Notice that it warns that this device is not suitable for a boot device which is what we intend.
Now check the status of the MD device like this:
$ cat /proc/mdstat
You should see something like this:
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdc1[1] sdb1[0]
1046528 blocks super 1.2 [2/2] [UU]
unused devices: <none>
This shows we now have a new, active MD device designated ‘md0’. It is configured as RAID 1 and is comprised of /dev/sdb1 and /dev/sdc1.
You can get additional information with the following command:
$ sudo mdadm --detail /dev/md0
You should see details that look somewhat like this:
$ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Mar 14 20:58:52 2023
Raid Level : raid1
Array Size : 1046528 (1022.00 MiB 1071.64 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Tue Mar 14 20:58:57 2023
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : firefly:0 (local to host firefly)
UUID : b501eeef:a0a505d6:16516baa:ea80a5b8
Events : 17
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
This shows the details of the RAID device.
You can get even more details by drilling down to the two RAID devices like this:
$ sudo mdadm --examine /dev/sdb1 /dev/sdc1
You should see something like this:
$ sudo mdadm --examine /dev/sdb1 /dev/sdc1
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b501eeef:a0a505d6:16516baa:ea80a5b8
Name : firefly:0 (local to host firefly)
Creation Time : Tue Mar 14 20:58:52 2023
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 2093056 sectors (1022.00 MiB 1071.64 MB)
Array Size : 1046528 KiB (1022.00 MiB 1071.64 MB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
Unused Space : before=1968 sectors, after=0 sectors
State : clean
Device UUID : 08c16292:aa06d46a:a0646f22:7bb0bd42
Update Time : Tue Mar 14 20:58:57 2023
Bad Block Log : 512 entries available at offset 16 sectors
Checksum : 9cea23ea - correct
Events : 17
Device Role : Active device 0
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/sdc1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : b501eeef:a0a505d6:16516baa:ea80a5b8
Name : firefly:0 (local to host firefly)
Creation Time : Tue Mar 14 20:58:52 2023
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 2093056 sectors (1022.00 MiB 1071.64 MB)
Array Size : 1046528 KiB (1022.00 MiB 1071.64 MB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
Unused Space : before=1968 sectors, after=0 sectors
State : clean
Device UUID : 40d5d968:1b4aefaa:1d2a61a5:57e8d9a1
Update Time : Tue Mar 14 20:58:57 2023
Bad Block Log : 512 entries available at offset 16 sectors
Checksum : 958a78ee - correct
Events : 17
Device Role : Active device 1
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
This shows even more details about the two devices that are configured as part of md0.
Make the configs persistent
If you were to reboot the system now the mdadm device would not be persistent and you would lose your device md0.
To save the configs and make them persistent do the following:
$ sudo mdadm --detail --scan --verbose | sudo tee -a /etc/mdadm/mdadm.conf
This writes appends a couple of lines to the /etc/mdadm/mdadm.conf file.
To make it persistent across reboots do:
$ sudo update-initramfs -u
Reboot the server to ensure the configs are persistent
Once the server has booted, check to see what your MD device is:
$ cat /proc/mdstat
$ cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active (auto-read-only) raid1 sdc1[1] sdb1[0]
1046528 blocks super 1.2 [2/2] [UU]
unused devices: <none>
Your new MD Device md0 still exists as a Raid 1 device.
Configure Logical Volume Management (LVM)
Now you will need to configure LVM on the RAID Device.
Create a Physical Volume on the MD Device:
$ sudo pvcreate /dev/md0
$ sudo pvcreate /dev/md0
Physical volume "/dev/md0" successfully created.
Confirm that you have a new Physical Volume:
$ sudo pvdisplay /dev/md0
$ sudo pvdisplay /dev/md0
"/dev/md0" is a new physical volume of "1022.00 MiB"
--- NEW Physical volume ---
PV Name /dev/md0
VG Name
PV Size 1022.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 7zbtfn-EmYy-L8SI-VGsR-JXLU-yRge-3iddqw
The next step is to create a Volume Group on the Physical Volume. I am going to name the Volume Group ‘vg_raid‘:
$ sudo vgcreate vg_raid /dev/md0
$ sudo vgcreate vg_raid /dev/md0
Volume group "vg_raid" successfully created
Confirm the Volume Group was created as expected:
$ sudo vgdisplay vg_raid
$ sudo vgdisplay vg_raid
--- Volume group ---
VG Name vg_raid
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 1020.00 MiB
PE Size 4.00 MiB
Total PE 255
Alloc PE / Size 0 / 0
Free PE / Size 255 / 1020.00 MiB
VG UUID qW9wd6-jGAr-LiV4-3xG0-mm8J-YP02-rEQGMs
Now create the Logical Volume on the Volume Group. I will name the Logical Volume ‘lv_raid‘ I will also use the maximum space allowed on the Volume Group :
$ sudo lvcreate -n lv_raid -l 100%FREE vg_raid
$ sudo lvcreate -n lv_raid -l 100%FREE vg_raid
Logical volume "lv_raid" created.
Confirm creation of the Logical Volume with the lvdisplay command like so:
$ sudo lvdisplay vg_raid/lv_raid
$ sudo lvdisplay vg_raid/lv_raid
--- Logical volume ---
LV Path /dev/vg_raid/lv_raid
LV Name lv_raid
VG Name vg_raid
LV UUID FZZEIT-stdx-RuAR-vA4Y-MSHY-Itia-NTzG3b
LV Write Access read/write
LV Creation host, time firefly, 2023-03-14 23:45:14 +0000
LV Status available
# open 0
LV Size 1020.00 MiB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
Create Filesystem
Now you can create a file system on the Logical Volume. Since the file system type I am using on the other drive is ext4 I will use the same:
$ sudo mkfs.ext4 -F /dev/vg_raid/lv_raid
$ sudo mkfs.ext4 -F /dev/vg_raid/lv_raid
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 261120 4k blocks and 65280 inodes
Filesystem UUID: 40420f4a-f470-47d5-a53d-922829cde8f3
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
Mount the Logical Volume
Now that you have the file system created you are ready to mount it somewhere.
Create a mount point for mounting the Logical Volume. I’m going to create ‘/mnt/Raid‘:
$ sudo mkdir /mnt/Raid
Now you can mount the Logical Volume on the new mount point:
$ sudo mount /dev/vg_raid/lv_raid /mnt/Raid
You can now optionally set the ownership of the mount point:
$ sudo chown mac:mac /mnt/Raid/
Check to see if your Logical Volume is mounted:
$ mount | grep raid
You should see something similar to the following:
$ mount | grep raid
/dev/mapper/vg_raid-lv_raid on /mnt/Raid type ext4 (rw,relatime)
You can see that the /dev/mapper device is /dev/mapper/vg_raid-lv_raid.
Automatically Mount when booting
To automatically mount the Raid Device when booting edit the /etc/fstab file and add a section that looks like this:
# Mount Raid
/dev/mapper/vg_raid-lv_raid /mnt/Raid ext4 defaults 0 0
Now un-mount the file system:
$ sudo umount /dev/mapper/vg_raid-lv_raid
Then re-mount with the entry in /etc/fstab:
$ sudo mount -a
Then verify it was remounted:
$ mount | grep raid
You should now be able to reboot the system and it will automatically mount this Raid Device.
Test
Test Auto Mount and Read & Write to filesystem
Now test your setup by writing a test file rebooting, confirm RAID is working and write to the file again.
Create a test file in /mnt/Raid:
$ vi /mnt/Raid/testfile.txt
Write some information to the file and save the file.
Reboot your system:
$ sudo shutdown -r now
Once you have logged back into your system, confirm that the md0 device is active:
$ sudo mdadm --detail /dev/md0
Examine the two partitions that comprise the mdadm device
$ sudo mdadm --examine /dev/sdb1 /dev/sdc1
Confirm the system automatically mounted the Raid device:
$ mount | grep raid
View the test file you created earlier:
$ ls -l /mnt/Raid/
Then confirm it’s content:
$ cat /mnt/Raid/testfile.txt
Then edit the file, add additional text to the file, save it, then confirm it.
$ vi /mnt/Raid/testfile.txt
Test Drive Failure
Now test your setup by simulating a failure in one of the drives.
Remember that we created file system on a Logical Volume on top of a mdadm raid device comprised of two partitions, each partition on it’s own physical device, (/dev/sdb & /dev/sdc). Then we mounted that file system on /mnt/Raid. We can easily see this graphically with the lsblk command like this:
$ lsblk /dev/sdb /dev/sdc
You should see something like the following:
$ lsblk /dev/sdb /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 1G 0 disk
└─sdb1 8:17 0 1023M 0 part
└─md0 9:0 0 1022M 0 raid1
└─vg_raid-lv_raid 253:1 0 1020M 0 lvm /mnt/Raid
sdc 8:32 0 1G 0 disk
└─sdc1 8:33 0 1023M 0 part
└─md0 9:0 0 1022M 0 raid1
└─vg_raid-lv_raid 253:1 0 1020M 0 lvm /mnt/Raid
This shows the mount point /mnt/Raid that was created on the Logical Volume which lives on the md0 raid device comprised of two partitions that each live on their own disk.
Lets assume that at some point in the future, disk sdb starts to degrade and will soon fail and you need to replace the disk.
Write all cache to disk:
$ sudo sync
Un-mount the file system:
$ sudo umount /dev/vg_raid/lv_raid
Set the /dev/seb1 partition of md0 as failed:
$ sudo mdadm --manage /dev/md0 --fail /dev/sdb1
$ sudo mdadm --manage /dev/md0 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
Verify partition /dev/sdb1 as faulty:
$ sudo mdadm --detail /dev/md0
$ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Mar 14 20:58:52 2023
Raid Level : raid1
Array Size : 1046528 (1022.00 MiB 1071.64 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Wed Mar 15 20:57:51 2023
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Consistency Policy : resync
Name : firefly:0 (local to host firefly)
UUID : b501eeef:a0a505d6:16516baa:ea80a5b8
Events : 27
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 33 1 active sync /dev/sdc1
0 8 17 - faulty /dev/sdb1
You can also verify with this:
$ cat /proc/mdstat
$ cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[0](F) sdc1[1]
1046528 blocks super 1.2 [2/1] [_U]
unused devices: <none>
The (F) next to sdb1 indicates it has been marked as failed.
Now you can remove the disk with mdadm like this:
$ sudo mdadm --manage /dev/md0 --remove /dev/sdb1
$ sudo mdadm --manage /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
Confirm with the cat command like before:
$ cat /proc/mdstat
$ cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdc1[1]
1046528 blocks super 1.2 [2/1] [_U]
unused devices: <none>
The only partition listed is now sdc1
You can also confirm with the lsblk command like this:
$ lsblk /dev/sdb /dev/sdc
$ lsblk /dev/sdb /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 1G 0 disk
└─sdb1 8:17 0 1023M 0 part
sdc 8:32 0 1G 0 disk
└─sdc1 8:33 0 1023M 0 part
└─md0 9:0 0 1022M 0 raid1
└─vg_raid-lv_raid 253:1 0 1020M 0 lvm
You can now shutdown the server and replace that hard drive.
Replace Hard Drive
For a Physical Machine it is easy to find the correct hard drive to remove by referencing the serial number you got from the lshw command you ran at the beginning of this How To. Replace the failed drive and power on the server.
Replace Virtual Hard Drive
For a Virtual Machine running on VirtualBox use these instructions to simulate a new hard drive.
Open the VirtualBox Virtual media Manager: File > Tools > Virtual Media Manager.
Create a New Virtual Hard Disk with the same size and type as the previous other two Virtual Disks. Take note of what you name it and where you store it.
Got to the Storage Settings of your Virtual Machine: Machine > Settings > Storage. Here you will need to remove the “bad” drive from the Virtual Machine and add the new drive. The drives were added as LsiLogic SCSI drives on SCSI Port 0 and Port 1.
In our case Port 0 should be equivalent to /dev/sdb and Port 1 should be equivalent to /dev/sdc.
Since we failed disk /dev/sdb you will need to remove the disk associated with Port 0.
Now add the new disk you created in the previous step and associate it as Port 0.
Save the config and power on the Server.
Restore the Partition
Before proceeding you should confirm that you have a new device named /dev/sdb. Do that like this:
$ sudo fdisk -l /dev/sdb
You should see something like the following:
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors
Disk model: HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Notice that it is not partitioned.
Duplicate the partition from /dev/sdc to /dev/sdb:
$ sudo sfdisk -d /dev/sdc | sudo sfdisk /dev/sdb
Now that the disk is partitioned you can add it to the Raid Device:
$ sudo mdadm --manage /dev/md0 --add /dev/sdb1
$ sudo mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: added /dev/sdb1
Now verify the status of the Raid Device:
$ sudo mdadm --detail /dev/md0
$ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Mar 14 20:58:52 2023
Raid Level : raid1
Array Size : 1046528 (1022.00 MiB 1071.64 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Mar 16 01:30:32 2023
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : firefly:0 (local to host firefly)
UUID : b501eeef:a0a505d6:16516baa:ea80a5b8
Events : 49
Number Major Minor RaidDevice State
2 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
For larger drives it may take some time to actually sync the new device.
You can also get a summary of the device like this:
$ cat /proc/mdstat
$ cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[2] sdc1[1]
1046528 blocks super 1.2 [2/2] [UU]
unused devices: <none>
Confirm your test file is still intact:
$ cat /mnt/Raid/testfile.txt
Wrap Up
Wait a minute. What about the whole part where you have to create the Logical Volume, the file system and mount the device, you say? This is a Raid Device. When you added the new device to the Raid device it automatically rebuilt the new device to match the existing one. When you rebooted the server it automatically mounted the Raid Device from the entry in the /etc/fstab. Since it is a Raid Device it was still functioning but with only one disk. When you added the new disk to it, it automatically rebuilt the new disk to be a mirror of the existing disk.
Additional Info
Additional commands that could be important to this How To:
sudo mdadm --stop /dev/md0
sudo mdadm --remove /dev/md0
sudo mdadm --zero-superblock /dev/sdb1 /dev/sdc1
Some valuable links:
blah
Removal of mdadm RAID Devices – How to do it quickly?
How to Set Up Software RAID 1 on an Existing Linux Distribution
Mdadm – How can i destroy or delete an array : Memory, Storage, Backup and Filesystems
Install and Set Up Ubuntu 22.04 Server
March 13, 2023
Posted by on This page will walk through what I did to install Ubuntu 22.04 Server for use in my home network.
I’m installing it as a Virtual Machine using Virtual Box 7.0, but these instructions should be valid if you are installing on a Physical Machine as well which I will do once I have confirmed this is working the way I expect it to.
Virtual Machine Specs
The Virtual Machine Specs I set up for this are:
Memory | 4096 MB |
Processor | 2 CPUs |
Storage SATA Port 0 | 25 GB |
Network | Bridged Adapter |
In VirtualBox 7.0 you can do what is called an Unattended Installation. I believe this is only available for certain Operating Systems but since I have not explored that option fully I am skipping it for now.
Follow these instructions to install Ubuntu 22.04 Server:
- Power on the Machine.
- When Presented with the GNU GRUB screen, select ‘Try or Install Ubuntu Server‘.
- Ubuntu starts the boot process.
- When Presented with a Language Selection Menu, select your language.
- Your keyboard configuration may already be selected for you. If not select your keyboard and then select ‘Done‘.
- Choose the Type of install. For this document I am going to choose ‘Ubuntu Server‘ and also select ‘Search for third-party drivers’.
- On the Network connections screen my network settings have been filled in automatically by DHCP. This is satisfactory for me so I choose ‘Done‘.
- On the Configure proxy screen you can choose to configure a proxy. This can be common in a corporate environment but in my case as my home network I don’t need to do this. Click ‘Done‘ when satisfied.
- On the Configure Ubuntu archive mirror screen you can safely click ‘Done‘ unless you know otherwise.
- On the Guided storage configuration screen I chose Use an entire disk and Set up this disk as an LVM Group. I did NOT encrypt. Select ‘Done‘.
- On the Storage configuration screen I accepted the summary and selected ‘Done‘.
- On the Confirm destructive action dialogue box I selected ‘Continue‘ since this is a new machine and I am confident I am not overwriting anything.
- On the Profile setup screen I typed my name, chose a server name, chose a user name and password then selected ‘Done‘.
- On the Upgrade to Ubuntu Pro screen select ‘Skip for now‘ then select ‘Continue‘.
- On the SSH Setup screen select ‘Install OpenSSH server’, then select ‘Done‘.
- On the Third-party drivers screen I see that “No applicable third-party drivers are available locally or online.” so I select ‘Continue‘.
- On the Featured Server Snaps screen I’m leaving it all blank. This document is about installing Ubuntu and not about snaps so I may do another document on that later. Select ‘Done‘.
- You will see a message that it is installing the system and then security updates. When it is ready you will be able to select ‘Reboot Now‘.
- Once you have rebooted you should be given a login prompt. You can now login with the user you created.
- When you login you will get some statistics about the system, one of which is the IP address. You can use that IP address to ssh to the host now and do some of the other things outlined in this document.
Additional Resources
Here are additional resources that will be useful in configuring your server.
Additional Useful Tools
Install additional packages:
$ sudo apt install members $ sudo apt install net-tools
Additional Pages to review
How to Install and Configure an NFS Server on Ubuntu 22.04
How to Install and Configure an NFS Server on Ubuntu 22.04
How To Sudo without password
March 13, 2023
Posted by on Scenario: You just installed your Lunux Server and you are the only person using the server and you want to sudo without having to type your password all the time. This How To will show you one way of accomplishing that task.
This How To assumes you are a member of the sudo group.
- Check to see if you are a member of the sudo group:
$ id
You should see a list of all the groups you are a member of. - Edit the /etc/sudoers file:
$ sudo visudo
This will open the the /etc/sudoers file with the default editor. - There will be a line that looks like this:
%sudo ALL=(ALL:ALL) ALL
- Comment out that line and replace it with a line that looks like this:
%sudo ALL=(ALL) NOPASSWD: ALL
- Save the file.
You should now be able to sudo without being prompted for your password every time.
Install VirtualBox 7.0 on Linux Mint 21.x
March 11, 2023
Posted by on This is what I did to install VirtualBox 7.0 on my new Linux Mint 21.1 workstation.
See the VirtualBox Wiki for the deets on VirtualBox 7.0
- Ensure your system has been updated:
$ sudo apt update && sudo apt upgrade -y
- Download the VirtualBox GPG Keys:
$ curl https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor > oracle_vbox_2016.gpg
$ curl https://www.virtualbox.org/download/oracle_vbox.asc | gpg --dearmor > oracle_vbox.gpg - Import the VirtualBox GPG Keys:
$ sudo install -o root -g root -m 644 oracle_vbox_2016.gpg /etc/apt/trusted.gpg.d/
$ sudo install -o root -g root -m 644 oracle_vbox.gpg /etc/apt/trusted.gpg.d/ - There does not appear to be an official repository for Linux Mint, but Linux Mint is derived from Ubuntu 22.04 which is code named ‘Jammy’. Add the Jammy VirtualBox Repository to the system:
$ echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian \
jammy contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
- Update the Repositories:
$ sudo apt update
- Install Linux Headers:
$ sudo apt install linux-headers-$(uname -r) dkms
- Install VirtualBox:
$ sudo apt install virtualbox-7.0
- Download the VirtualBox Extension Pack:
$ cd ~/Downloads
$ VER=$(curl -s https://download.virtualbox.org/virtualbox/LATEST.TXT)
$ wget https://download.virtualbox.org/virtualbox/$VER/Oracle_VM_VirtualBox_Extension_Pack-$VER.vbox-extpack - Install the Extension Pack:
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-*.vbox-extpack
- You can now launch VirtualBox from the Desktop menu.
IPTables
May 4, 2020
Posted by on These are my notes on IP tables. Maybe at some point I may do a complete tutorial or How To but don’t hold your breath.
Chains:
There are typically 3 chains in a standard setup. They are:
INPUT FORWARD OUTPUT
Input is things coming into the server.
Forward are things that are forwarded by the server.
Output are things that are leaving the server.
Policies:
There is a default policy (rule) set up for each chain. CentOS somes standard with the default policy of ACCEPT for each of these chains. The command line to set the policy is like this:
# iptables -P INPUT ACCEPT
Pretty simple really. The -P is the flag to set the policy.
Flush:
The command that flushes the iptables is -F
. This deletes the rules in the table.
# iptables -F
If changing rules from a remote host, the tutorial says to first put the INPUT policy to ACCEPT especially if you are going to flush the table. The flush command flushes everything except the default policy so if you have set it to ACCEPT then you won’t lock yourself out. Be sure to undo the ACCEPT on the INPUT policy or it will basically be wide open unless you have some other rule locking it down.
So the first two commands, accept on the input policy and flush on the table leave you with a pretty much blank rule set.
Saving:
It’s important to understand that the commands take effect immediately so if you do a wrong command you can lock yourself out. However they are not permanently stored until you save them with this:
# service iptables save
If you did lock yourself out then theoretically you could reboot the server before saving and it would revert back to whatever it was on the last save. I have not tested this yet but that is what I understand.
Showing:
You need to be able to see the results of your commands so you can show your tables like this:
iptables -L
This leaves a bit to be desired as it shows everything and may be too much information. This will show all Chains. If you just want to list one of the Chains you can do it like this:
# iptables -L [CHAIN]
For example:
# iptables -L INPUT
Even more useful is to list with Line Numbers. This is helpful if you want to insert a rule after a certain existing rule. That command looks like this:
# iptables -L --line-numbers
or
# iptables -L INPUT --line-numbers
Even better is using the -v
or the verbose flag. That’s probably the best.
# iptables -L INPUT -v --line-numbers
Adding Rules:
Rules are added or deleted to the table by the -A
or -D
flag. The -A
appends a rule and the -D
deletes a rule. For example:
# iptables -A INPUT -i lo -j ACCEPT
This will allow everything to reach the lo interface. This is a good idea as programs running on the server interact with the lo interface.
By the way, the -i
flag specifies an interface. The -j
flag is the jump flag. In the above example if something comes in (INPUT) on the lo interface, then jump to ACCEPT.
It is also important to note that rules are put into the table in the order they are typed in using the -A
(append) command. You need to be sure you do not give permissions to something and then take it away later. It is also a good idea to set the policies for INPUT and FORWARD to drop then specifically set up the exceptions to this with the rules.
Deleting Rules:
The -D
flag can be used with line numbers and is useful to delete specific lines in your IPTables config. The Delete command is done like this:
# iptables -D INPUT 4
In other words, deleting from the INPUT chain rule number 4.
Inserting Rules:
Rules need to be in certain orders or you could cause problems. You can insert a rule to the table with this:
# iptables -I INPUT 3 -p tcp --dport 23 -j ACCEPT
This inserts at line 3 the rule to accept telnet in the INPUT chain.
IP Addresses:
You can also specify IP addresses in a rule. For example if I wanted to specify that I wanted to accept connections coming from a certain source IP address I would use something like this:
# iptables -A INPUT -s 192.168.0.4 -j ACCEPT
The -s
means source IP.
You can also specify entire networks like this:
# iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT
Comments:
Comments can also be added. This is useful if you are putting the lines into a script or something. Everything after the “#” is ignored.
# iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT # using standard slash notation
Mac Addresses:
You can also filter by mac addresses in a rule. Something like this:
# iptables -A INPUT -m mac --mac-source 00:26:B9:D1:D9:6B -j ACCEPT
Anything from the specified source mac address will be accepted by the above rule.
You can also add an IP address as well as a mac address for further filtering:
# iptables -A INPUT -s 192.168.0.4 -m mac --mac-source 00:50:8D:FD:E6:32 -j ACCEPT
The above will append the rule to the end of the chain. It is probably better to insert it somewhere like this:
# iptables -I INPUT 75 -s 192.168.0.4 -m mac --mac-source 00:50:8D:FD:E6:32 -j ACCEPT
Protocols & Ports:
To further refine you really need protocols and ports defined in a lot of the rules. Going back to this example:
# iptables -I INPUT 3 -p tcp --dport 23 -j ACCEPT
The -p
means protocol, in this case TCP and the --dport
means destination port, in this case port 23 or telnet.
To get more granular on the rules you will want to put them together. For ecample I want to accept on the INPUT chain connections coming from 192.168.0.0/24 and port 23 or telnet. The rule would look like this:
# -A INPUT -s 192.168.0.0/24 -p tcp --dport 23 -j ACCEPT
Drop & Reject:
The default configuration of IP Tables for CentOS is to have the INPUT, FORWARD & OUTPUT policies set to ACCEPT. This is probably not a good idea. Depending on your security posture it might be OK for your OUTPUT policy, unless you want to limit what goes out of your system. The way you solve this issue is to add some REJECT rules to the end of your configs. A REJECT rule looks something like this:
# iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited # iptables -A FORWARD -j REJECT --reject-with icmp-host-prohibited
A REJECT will send a TCP Reject whereas a DROP simply drops the connection. Depending on your security posture a DROP might be a better decision.
States:
The State Match
The most useful match criterion is supplied by the `state’ extension, which interprets the connection-tracking analysis of the `ip_conntrack’ module. This is highly recommended.
Specifying `-m state’ allows an additional `–state’ option, which is a comma-separated list of states to match (the `!’ flag indicates not to match those states). These states are:
NEW: A packet which creates a new connection.
ESTABLISHED: A packet which belongs to an existing connection (i.e., a reply packet, or outgoing packet on a connection which has seen replies).
RELATED: A packet which is related to, but not part of, an existing connection, such as an ICMP error, or (with the FTP module inserted), a packet establishing an ftp data connection.
INVALID: A packet which could not be identified for some reason: this includes running out of memory and ICMP errors which don’t correspond to any known connection. Generally these packets should be dropped.
An example of this powerful match extension would be:
# iptables -A FORWARD -i ppp0 -m state ! --state NEW -j DROP
The default iptables configuration has the ESTABLISHED and RELATED states set to ACCEPT on the INPUT chain like this:
# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Probably a good idea to keep that and put it first in the list. This will keep any connections going that have already been established. For example if you have an ssh connection going and you change the iptables for SSH and lock yourself out the connection will remain until you close the connection. This has saved me at least once but you could potentially keep bad connections going as well so use with care.
I have also seen that it is a good idea to use states with regular rules like this:
# iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
I don’t completely understand it myself. Things should work without it. I’ve just seen posts about it and think it is useful to mention here.
Another good thing to use might be the INVALID state. INVALID means a packet that could not be identified somehow. Just drop them:
# iptables -A INPUT -m state --state INVALID -j DROP # iptables -A FORWARD -m state --state INVALID -j DROP # iptables -A OUTPUT -m state --state INVALID -j DROP
Script:
Here’s a little script that sets up pretty much what I talked about on this page:
#!/bin/bash # iptables example configuration script # Flush all current rules from iptables iptables -F # Set default policies for INPUT, FORWARD and OUTPUT chains iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # Drop invalid packets iptables -A INPUT -m state --state INVALID -j DROP iptables -A FORWARD -m state --state INVALID -j DROP iptables -A OUTPUT -m state --state INVALID -j DROP # Accept packets belonging to established and related connections iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow private lan to ping iptables -A INPUT -s 192.168.0.0/24 -p icmp -j ACCEPT # Set access for localhost iptables -A INPUT -i lo -j ACCEPT # Allow private lan to ssh iptables -A INPUT -s 192.168.0.0/24 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # Save settings /sbin/service iptables save # List rules iptables -L -v --line-numbers
The tr command
April 1, 2020
Posted by on The tr command:
It’s short for “translate” but might be easier to remember thinking of it as “truncate”. The man page has this to say about it:
DESCRIPTION
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
There are probably books written on what tr
can do. I’m just going to leave some notes here on how I typically use it.
The tr
program reads from standard input and writes to standard output.
Convert multiple lines of text into a single line of text:
Consider a file named file
containing the following data:
abcde fghij klmno pqrst uvwxy
You want to convert the multiple lines into a single line of text. You can do that using tr
with something like this:
$ cat file | tr -d '\n'
The result of the command is written to standard output as:
abcdefghijklmnopqrstuvwxy
The -d
option deletes. In this case we’re deleting the newline character.
Replace comma with newline:
Sometimes you need to convert a single delimited line to multiple lines. Consider the following file named file
containing the following data:
abcde,fghij,klmno,pqrst,uvwxy
We can translate the comma in the file into a new line character with the following command:
$ cat file | tr ',' '\n'
The results look like this:
abcde fghij klmno pqrst uvwxy
Mount OneDrive from Linux Mint
December 5, 2019
Posted by on How to Mount OneDrive from Linux Mint
Don’t install Rclone from the standard repository. That version is too old.
Install Rclone:
cd ~/Downloads wget https://downloads.rclone.org/rclone-current-linux-amd64.deb sudo apt install ./rclone-current-linux-amd64.deb
Run the Rclone wizard:
rclone config
Select n
to create a new remote:
$ rclone config 2019/12/04 20:47:41 NOTICE: Config file "/home/mac/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config n/r/c/s/q>
Name is something meaningful like ‘onedrive’:
name> onedrive
Select 22
for Microsoft OneDrive:
22 / Microsoft OneDrive \ "onedrive"
You will be asked for a Microsoft App Client Id. Just hit Enter to accept the default and leave blank.
You will be asked for a Microsoft App Client Secret. Hit Enter to accept the default and leave blank.
You will be asked to edit advanced config. Type N
You will be asked to use auto config. Type y :
Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes n) No y/n> y
Your browser should open now and ask you to sign into OneDrive. Put in your email address. Hit next then your password and check the box to keep signed in then the sign in button.
At this point I seem to be locked out of OneDrive as my sign in did not work on this computer.
I tried again and instead of doing auto config I did N to not do auto config.
Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes n) No y/n> n For this to work, you will need rclone available on a machine that has a web browser available. Execute the following on your machine: rclone authorize "onedrive" Then paste the result below: result>
I did the above and got a very long “token” that I was able to copy and paste into this machine.
It then asked me to choose a number from below. I selected 1 for OneDrive
Then it said it found 2 drives. Not sure why. I selected drive 0
Then I was able to exit Rclone by typing q:
Current remotes: Name Type ==== ==== onedrive onedrive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q
Now create a new directory:
mkdir ~/OneDrive
Now mount OneDrive:
rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive
This will appear to hang your session but you can stop it by doing CTRL C
Now to start at boot up you can open Startup Applications, and in Startup Applications click Add.
After clicking Add, use the following:
Name: Mount OneDrive Command: sh -c "rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive"
Citrix Client on Linux Mint
November 19, 2019
Posted by on This is my document for attempting to install the Citrix Workspace App on Linux Mint.
Version of Mint is 18.3 Cinnamon 64-bit
Go to Citrix download site:
https://www.citrix.com/downloads/workspace-app/linux/workspace-app-for-linux-latest.html
Near the bottom of the page you will be presented with 3 versions:
- Full Packages (Self-Service Report)
- Web Packages (Web Workspace App Only)
- USB Support Packages
For this I’m going to get the Full Packages. I found the package for my version of Linux. (amd64.deb)
Download that to a directory on your PC then right click on the package and open with the GDebi Package Installer.
Install the package.
Open the URL of your Citrix Implementation and put in your credentials
Linux Mint 19.x
November 1, 2019
Posted by on Linux Mint 19.x
These are my notes on Linux Mint 19.x. If you find this and think it is useful, leave a comment and say what you like or don’t like. Keep in mind these are my own notes and are not intended to be a HowTo for the general public.
Install the OS from the USB Flash Drive. I chose to simply overwrite the existing version of Mint (19.1) that had already been installed on my laptop. I also chose to encrypt my home directory.
My first order of business is to make the native monitor and external monitor both set to the same resolution of 1920×1080 (16:9). The native laptop monitor supports a higher resolution of 2560×1440 but the screen is so small that it is very hard to see at that resolution so I’m standardizing both monitors at 1920×1080.
Get up and Running:
Here’s what I did to get up and running and customized the way I like it:
Update Everything:
-
- The first thing to do is open the Update Manager and update everything. The Update Manager is the little shield icon in the task bar down in the right hand corner. Open that up and click OK to dismiss the initial startup screen.
- You will be presented with a prompt to take a System Snapshot. I’m going to put this off until I have updated everything.
- You will see a message that a new version of Update Manager is available. Click the ‘Apply the Update’ button to install it.
- Once that is installed you will be presented with a list of updates that can be applied.
- Apply all the updates. It is a good idea to reboot after all the updates.
Video Drivers:
After I rebooted I got a pop up box that said to “Check your video drivers”. I launched the Driver Manager and entered my password. My software cache was updated. Then an NVIDIA Driver Manager opened up. It showed that the nouveau driver was installed, but the recommended driver was nvidia-driver-435 which I checked then “Apply Changes”. You will need to reboot after this.
System Reports:
Down in the bottom right corner of the desktop you may see a little triangular warning icon. This is the ‘System Reports’ application. Go ahead an open this up. You should see a list of detected problems that need to be addressed. Go ahead and resolve the issues. The last item in ‘System Reports’ is to configure the System Snapshot tool Timeshift. See the next section for this.
System Snapshot:
You will be asked to choose between RSYNC and BTRFS. Typically this is going to be RSYNC.
A blurb about BTRFS.
- First you have to have had installed the base OS with BTRFS file system for this to even be an option. In my case I did not want to use the BTRFS file system.
- Second the snapshot can only be installed on the same disk from which they are created. If your drive goes bad you’re screwed. Choose RSYNC.
A blurb about RSYNC:
- RSYNC snapshots are created by creating copies of system files using rsync and hard-linking unchanged files from previous versions.
- All files are copied when the first snapshot is created. Subsequent snapshots are incremental.
- Snapshots can be saved to any disk formatted with a Linux File system which means the snapshot can be external. In my case an attached USB memory stick.
I’m using a USB 3.0 Flash Stick.
When you run the setup wizard you will be asked to select your snapshot levels. I checked off Monthly, Weekly, Daily, Hourly & Boot and kept the default keep levels on each one.
I also included root and my user’s home directories and selected “Include All”.
Sudoers:
Edit the /etc/sudoers file so you don’t have to put your password in each time:
$ sudo visudo
There’s a line that looks like this:
%sudo ALL=(ALL:ALL) ALL
Comment out that line and replace it with a line that looks like this:
%sudo ALL=(ALL) NOPASSWD: ALL
Install openssh server:
Install SSH Server so you can ssh to the host:
$ sudo apt install openssh-server -y
Test ssh to the new host. You may during this process encounter an error regarding an “Offending ECDSA key in ~/.ssh/known_hosts”. This is easily resolved by deleting the referenced line in ~/.ssh/known_hosts
.
SSH Keys:
Now that you can ssh to your new host you will want to be able to ssh using your ssh key instead of password. From the remote host do this:
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [newhostname]
The above assumes the user name on the new host is the same as the user on the remote host. If not you can do the command like this:
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [user]@[newhostname]
You will be prompted to enter the password for the New Host. It will copy over your public ssh key from ~/.ssh/id_rsa.pub
. This assumes your public ssh key is indeed ~/.ssh/id_rsa.pub
.
You should be able to ssh to the new host now without entering your password.
(Optional) Now copy all the ~/.ssh
directory contents from your remote host into this host so you have the keys, the known hosts and authorized keys files from your user on the old remote host and now have them on your new host.
From the remote host:
$ cd ~/.ssh
$ scp -r * [new-host-name]:~/.ssh
Copy /etc/hosts to new host:
Now copy the /etc/hosts file from old host to new host. From the old host:
$ sudo scp /etc/hosts [new-host-name]:~
On the new host edit the file and change the local host name on line 2 to the name of your new host.
Now copy the file into place:
$ sudo mv hosts /etc/hosts
Check it like this:
$ cat /etc/hosts
Install Dropbox:
Install Dropbox:
sudo apt install dropbox
Then go to start menu and find Dropbox and run it.
You will get a message that says in order to use Dropbox you must download the proprietary daemon. Click OK
A Web Page will pop up where you enter your credentials. Do so.
Install Insync:
Don’t use this. It does not work and sync of files does not happen. Tired of using it.
I want to sync my Google Drive locally. To do that I’m using Insync.
First, add Insync’s public GPG key to allow apt to authenticate the Insync repository:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ACCAF35C
You should see something like this that shows that it was successful:
gpg: key A684470CACCAF35C: public key "Insynchq Inc <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
If the previous command did not work, use this instead:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ACCAF35C
Now create a file /etc/apt/sources.list.d/insync.list
with the following content:
deb http://apt.insync.io/mint [CODENAME] non-free contrib
Replace [CODENAME] with the Linux Mint distro codename.
To get the codename of your distro you can find it in the /etc/apt/sources.list.d/official-package-repositories.list
file. You can view it like this:
$ grep mint /etc/apt/sources.list.d/official-package-repositories.list | awk '{print $3}'
This is what I see when I run the above command:
tricia
So ‘tricia’ is the codename of this version of Linux Mint. That means the line I need to insert into /etc/apt/sources.list.d/insync.list
would be:
deb http://apt.insync.io/mint tricia non-free contrib
Update the apt repository:
$ sudo apt-get update
Install Insync:
$ sudo apt-get install insync
You should see a pop up that says Insync installation has finished and if you want to start it. Go ahead and start it. A wizard will pop up to walk you through setting up Insync to sync your Google Drive to a directory on your host.
Install KeePassXC:
Install KeePassXC:
$ sudo apt install keepassxc -y
Install Chrome:
You’ll need Chrome for certain things.
Go to https://www.google.com/chrome/
Click the Download Chrome button. Mine automatically downloaded into ~/Downloads
. The 64 bit version was automatically selected.
Install it like this:
$ cd ~/Downloads
$ sudo gdebi google-chrome-stable_current_amd64.deb
This will automatically install a repository as well for future updates.
Install Brave
Brave is a browser that automatically blocks trackers and Spam Ads. It is very buggy. I’d probably pass on this but if you insist…
$ sudo apt install apt-transport-https curl $ curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add - $ echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list $ sudo apt update $ sudo apt install brave-browser
Install Signal:
Go to https://signal.org/en/download/
Click on Download for Linux and follow the instructions that pop up.
Additional Software:
There are other software packages I need. I’ll do them one at a time because I don’t want to confuse error message between one package or another:
$ sudo apt install kwrite -y
$ sudo apt install kate -y
$ sudo apt install terminator -y
$ sudo apt install sshuttle -y
$ sudo apt install vim -y
$ sudo apt install sshpass -y
$ sudo apt install whatsapp-desktop -y
$ sudo apt install nfs-common -y
$ sudo apt install rofi -y
$ sudo apt install gparted -y
$ sudo apt install imagemagick -y
$ sudo apt install whois -y
For Mint 20:
$ sudo apt install warpinator -y
Spoof Mac Address:
Mac Address:
Set your custom mac address to get the IP address you want.
Go to start, search for ‘Network Connections’
Click on Wired connection 1
Click Edit
Put your custom mac address in the ‘Cloned MAC address’ box.
##:##:##:FF:FF:FE
Click Save. You should now get the IP address you are expecting.
You may need to reboot. You should get your IP address.
Mount NFS share:
Create a mount point:
$ cd ~
$ mkdir -p mnt/[nfs-server-host-name]
Edit /etc/fstab and add these lines:
# External Mounts
[nfs-server-host-name]:[path-to-nfs-export] /home/[your-user]/mnt/[nfs-server-host-name] nfs rw,soft,noauto 0 0
Edit /etc/hosts and add the IP address of Serenity
Then mount the NFS share:
$ sudo mount [nfs-server-host-name]:[path-to-nfs-export]
You will need to modify the firewall rule on the NFS server to allow connections from your new host before this will work.
https://squoggle.wordpress.com/2020/05/04/iptables/
Install Slack:
Go to https://slack.com/downloads/linux
Download the .deb 64 bit package into your ~/Downloads directory.
Then install it:
$ cd ~/Downloads
$ sudo gdebi slack-desktop*.deb
I found a packagecloud.io repo but I have no way of knowing if it is secure. I’ll try to figure out how to create my own local repo for this.
Install Synergy:
Linux Mint 19.2 is based off of Ubuntu 18.04 LTS.
Go to https://symless.com/account and sign in. Go to the download page and get the package for Synergy 2 Beta for Ubuntu 16.04 LTS and save in ~/Downloads
Install it:
$ cd ~/Downloads
$ sudo gdebi synergy_2.*.deb
This is literally the best software in the world.
There’s a gotcha if you’re trying to install this on Mint 20. Mint 20 is based on Ubuntu 20.04. Ubuntu 20.04 has updated libssl from version 1.0.0 to version 1.1.
If you attempt to install with the above instructions you will get an error regarding a failed dependency. I was able fix the dependency issue by editing the deb package using these instructions:
cd ~/tmp
cp ~/Downloads/synergy_2.0.12.beta_b1705+e5daaeda_amd64.deb .
ar x synergy_2.0.12.beta_b1705+e5daaeda_amd64.deb
tar xzf control.tar.gz
Edit the control file and replace libssl1.0.0
with libssl1.1
and save the file.
Now repackage the tar file and the deb package:
tar --ignore-failed-read -cvzf control.tar.gz postinst postrm prerm md5sums control
ar rcs synergy_2.0.12.beta_b1705+patched_amd64.deb debian-binary control.tar.gz data.tar.xz
You should now have a “patched” version of synergy 2.0.12.beta. Save that in your software store so you don’t have to do this part again.
Now you can install it with the gdebi command listed above.
The package installed fine it just does not work. I get a “There was a problem connecting to the background service.” Error.
Look at this page:
https://members.symless.com/forums/topic/6465-ubuntu-2004-support/
Near the end of the post. There might be some stuff there that helps
Fix your Profile:
Edit ~/.bashrc and change
alias ll='ls -alF'
to
alias ll='ls -lF'
Directories:
Delete extra directories you don’t like
$ cd ~
$ rm -rf Videos Templates Public
Create a symlink for mount
$ ln -s /home/mac/mnt/Serenity/ mac
Fix up your bin dir:
Set up your ~/bin directory:
$ cd ~
$ mkdir bin
Copy your scripts over from your other system.
Set your $PATH to include ~/bin
Edit ~/.bashrc and change. Add this to the bottom of the file:
# Set your path to inclue $HOME/bin
PATH="$HOME/bin:$PATH"
Date & Time:
Click on the Date in the bottom right corner.
Turn off 24 hour clock
Turn on the date
Hot Keys:
Go to System Settings > Keyboard > Shortcuts
Set up your custom hot keys:
Launchers:
Launch Terminal = Super+T
Launch Nemo = Super+E
Close Window = Super+Shift+C
Log out = Super+Shift+Q
rofi -show run = Super+R
rofi -show window = Super+Tab
Other resources:
Sed
October 29, 2019
Posted by on Down & Dirty Notes on SED
Replace a word with another word:
To replace all instances of a certain word in a file with another word:
$ sed 's/[oldword]/[newword]/' file
This will not modify the original file but output to the screen
Strip the last letter of a list of words:
If you have a file with a bunch of words that all end in the same letter, something like this:
austin1a denver1a dallas1a phoenix1a
and you want to strip the last letter off of each word you can do it with something like this:
$ sed 's/\(.*\)./\1/' file
Output is to screen.
Add a letter to the end of a list of words:
Lets say you want to add a letter to that list of words. You can do that like this:
$ sed 's/$/b/'file
This will add a letter b
to the end of each word in the list.
Replace the last letter of word:
You can combine the above two commands and if you want to change all the of the a
to letter b
then you can do that like this:
$ sed 's/\(.*\)./\1/' file | sed 's/$/b/'
The first part of this command strips the last letter of each word. Then the second part of the command adds the letter b
to the end of each word.
Add a trailing \
Many times you want to run a script against a list of servers or something. You can create a list with a space slash \
after each word in the file:
$ sed 's/$/ \\/' file
The results will look something like this:
austin1a \ denver1a \ dallas1a \ phoenix1a \
Insert text at the beginning of a word:
If you want to insert the word router
at the beginning of each word you could do something like this:
$ sed 's/^/router/' file
Insert text at the end of a word:
Same as above but at the end of the word:
$ sed 's/$/router/' file
Convert commas to newline:
Lets say you have CSV list in a file that looks something like this:
austin1a,denver1a,dallas1a,phoenix1a
and you want to convert those commas into newline. You can do something like this:
$ sed -e $'s/,/\\\n/g' file
Sometimes that list will have a space after the comma like this:
austin1a, denver1a, dallas1a, phoenix1a
You can modify the command slightly like this:
$ sed -e $'s/, /\\\n/g' file
Convert TABs (White space) to Commas:
Lets say you have a TAB separated file and you want to convert it to a CSV file. An example would be something like this:
austin1a.example.com. 300 IN A 10.10.20.10 denver1a.example.com. 300 IN A 10.10.30.10 dallas1a.example.com. 300 IN A 10.10.40.10 phoenix1a.example.com. 300 IN A 10.10.50.10
This command will convert any white space to a comma:
$ sed 's/[[:space:]]\+/,/g' file
Convert multiple spaces to single space:
Or if you simply want to convert multiple spaces to a single space you can do like this:
$ sed 's/[[:space:]]\+/ /g' file
More to come…
Recent Comments