Linux

Some useful Linux commands

Rename files / folders with spaces: IFS=$’\n’;for f in `find .`; do file=$(echo $f | tr [:blank:] ‘_’); [ -e $f ] && [ ! -e $file ] && mv “$f” $file;done;unset IFS Rsync: rsync -r -a -v rsync://ns2/storage/www-srv /storage/ ^^^ from ns2 to new host – (run on new host) Rsync (local to remote) […]

Linux LVM

Create and manage Linux volumes (LVM)

Create the physical volume: pvcreate /dev/sdb Create the Volume Group: vgcreate vg_backuppc_storage /dev/sdb Create the logical volume: lvcreate -l +100%FREE vg_backuppc_storage Create a filesystem on the logical volume: mkfs.ext4 /dev/vg_backuppc_storage/lvol0 Resize the physical volume: (need to unmount the LV before doing this) pvresize /dev/sdb Extend the volume: lvextend -l +100%FREE -r /dev/vg_backuppc_storage/lvol0 Mount your new […]

Linux Nagios

Define a new service in Nagios

To define a new service in Nagios you need to do the following: 1) Add the necessary commands to /etc/nagios/objects/commands.cfg 2) Define the host and service in /etc/nagios/objects/templates.cfg 3) Define a host definition in /etc/nagios/objects/.cfg Command definition in commands.cfg define command{ command_name check-ssl-cert command_line $USER1$/check_ssl_certificate -H $ARG1$ -p $ARG2$ -c $ARG3$ -w $ARG4$ } The […]

Linux

How to recover a grub boot partition

The RedHat / CentOS way. Title should be “recover grub boot loader really”! Boot into recovery mode from the linux rescue cd. Type: chroot /mnt/sysimage – this will make your main / partition (currently mounted under /mnt/sysimage) the / partition. Type mount and find which device is your hard disk. This could be sda or […]

Debian Linux Samba

mount: cannot mount block device

I was trying to mount a CIFS / SAMBA share on Debian GNU/Linux 7 (wheezy). I wasn’t being prompted for a password, I would simply get: mount -t cifs -o user=admin //10.1.1.10/BLAH remote/ mount: block device //10.1.1.10/BLAH is write-protected, mounting read-only mount: cannot mount block device //10.1.1.10/BLAH read-only I needed to install “cifs-utils” apt-get install […]