Find and replace text within a file using sed

Find and replace text within a file using sed

The procedure to change the text in files under Linux/Unix using sed:

  1. Use Stream EDitor (sed) as follows:
  2. sed -i 's/old-text/new-text/g' input.txt
  3. The s is the substitute command of sed for find and replace
  4. It tells sed to find all occurrences of ‘old-text’ and replace with ‘new-text’ in a file named input.txt
  5. Verify that file has been updated:
  6. more input.txt

Installing Visual Studio Code on RHEL

RHEL, Fedora, and CentOS based distributions
We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

Then update the package cache and install the package using dnf (Fedora 22 and above):
sudo dnf check-update
sudo dnf install code


Or on older versions using yum:
yum check-update
sudo yum install code


Due to the manual signing process and the system we use to publish, the yum repo may lag behind and not get the latest version of VS Code immediately

format a disk to fat32 on raspberry pi or linux

—— part 1 ——-
create partitions
1) get list of disks
# fdisk -l
2) Find disk in list, /dev/???
in this example /dev/sda
3) run fdisk again and specify disk
# fdisk /dev/sda
4) print current partiions
Command (m for help): p
5) use the d command to delete any of the existing partitiond
Command (m for help): d
you may have to run this multiple times if there is more that 1 partition.
6) print current partiion list again, to make sure its empty
Command (m for help): p
7) Use the o command to create a new DOS partition table
Command (m for help): o
8) use the n command to create a new partition
Command (m for help): n
accept all defaults
9) use the t command to change the partition type
Command (m for help): t
use the hex code b to select W95 FAT 32
10) use the w command to write changes to disk.
Command (m for help): w
—– part 2 ———-
create filesystem
1) mkfs -t vfat /dev/sda1

Creating and extending Linux LVMs

Notes on how to create or add disk, volume groups and logical volume in Linux (RedHat)
1. First add disk to system by what ever means your system requires.
2. Find name of disk using fdisk
# fdisk -l /dev/sd* | grep i 'Disk'
For my examples below, it would have listed sdb but not had any partition data with it.
3. Create a new partition on the disk using fdisk
# fdisk /dev/sdb
n to create a new partition
p for primary
enter through the other options
w to write the config and exit
3. make sure the disk and partition are setup OK by using lslbk
# lslbk
4. create the physical volume (pv) on the new disk (sdb1)
# pvcreate /dev/sdb1
5. list current volume groups
# vgs
6a. to create a new volume group, use vgcreate with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgcreate vg_oracle /dev/sdb
6b. extend the current volume group to include the new physical volume use vgextend with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgextend vg_oracle /dev/sdb1
7a. to create a new volume group
# lvcreate -L 20G -n lv_u01 vg_oracle
7b. to extend the logical volume
to increase it by 100GB
# lvextend -L +100G /dev/mapper/vg01_data-lv_data
to increase it to use 25% of the free space
# lvextend -l +25%FREE /dev/mapper/vg01_data-lv_data
to increase it to use all of the free space
# lvextend -l +100%FREE /dev/mapper/vg01_data-lv_data
8a. then create a xfs file system
# mkfs /dev/vg_oracle/lv_u01
8b. or resize the xfs file system
# xfs_growfs /u01