Lists all files beginning with n or S followed by "-release".

ls [nS]*-release

Lists all files beginning with n or S followed by “-release” (e.g., novell-release)

oes11-34:/etc # ls -la [nS]*-release
-rw-r--r-- 1 root root 72 Jan 21 2014 novell-release
-rw-r--r-- 1 root root 69 Jun 3 2013 SuSE-release
oes11-34:/etc # cat [nS]*-release
Novell Open Enterprise Server 11 (x86_64)
VERSION = 11.2
PATCHLEVEL = 2
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 3
oes11-34:/etc #

Rescan of a SCSI bus without rebooting the VM

To issue a SCSI bus rescan you must know on which bus you’ve added the device. If you don’t know which bus and if there are mutliple buses on the system you can rescan each bus which will be somehow annoying but will not interrupt the system.
To initiate a SCSI bus rescan type:
root# echo "- - -" > /sys/class/scsi_host/hostX/scan
where X stands for the SCSI bus you want to scan, and then you can type the following:

root# lsscsi
root# fdisk -l
root# tail -f /var/log/message

How to Identify Your Linux File System Type.

To identify a Linux file system you can use the following standard command:
df -T or cat /etc/fstab or mount but the commands listed below are much more cool:

Use the file command.

root# file -sL /dev/sdc1
/dev/sdc1: sticky Linux rev 1.0 ext3 filesystem data, UUID=28d01367-3886-4f67-a3c9-447bf006ae27 (needs journal recovery) (errors) (large files)

root# file -sL /dev/sdc1
/dev/sdc1: sticky Linux rev 1.0 ext3 filesystem data, UUID=28d01367-3886-4f67-a3c9-447bf006ae27 (needs journal recovery) (errors) (large files)

Use the fsck command:

root# fsck -N /dev/sdc1
fsck from util-linux 2.20.1
[/sbin/fsck.ext3 (1) -- /mnt/data] fsck.ext3 /dev/sdc1

root# fsck -N /dev/zeus/root
fsck from util-linux 2.20.1
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/mapper/zeus-root

How do I shrink the root logical volume (LV) on LVM?

The root partition and LV resizing should be done on unmounted partitions, so you have to boot from a rescue CD or USB stick, run it as live CD. Then make sure, that your root LV is not installed, by

mount

and unmount it when necessary. The LVM command vgchange changes attributes of volume groups. What needs to be “changed” to access the volume is the “availability” — i.e. to make the kernel realize the LVM volumes are there. This can be done by the command:

lvm vgchange -a y

Note, in rescue mode the system command is lvm and the LVM command that is run is vgchange. The -a y argument sets the availability to “y” or yes. As there are no specified LVM volume groups, this command will make all LVM volumes found available to the rescue kernel.

Once the kernel is aware of all LVM volumes they will be automatically mapped as devices. These are usually located under /dev/VolGroup or /dev/mapper/VolGroup (where “VolGroup” is the name of the Volume Group). Then do filesystem check

e2fsck -f /dev/yourVG/yourLV

on this LV. Then shrink filesystem

resize2fs /dev/yourVG/yourLV 5G

and reduce LV

lvreduce -L 5G /dev/yourVG/yourLV

Reboot to your system, Enjoy!

Write ISO to USB stick.

After inserting your USB stick, you can find out what device it is using the following command:

grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)

Finally, once you've found your block device, write the image to it. Point 'dd' to the full path such as '/home/user/Downloads/Linux-x86_64.iso'

umount /dev/sdX
dd if=/path/to/downloaded.iso of=/dev/sdX

How to use bind mounts in Linux.

Bind mounting is quite simple. Instead of mounting a block device into a particular path you are mounting one path into another path.

mount -o bind /home/andzia /ftp/andzia

You will now see this reflected when running the mount command:

mount | grep var
/home/andzia on /ftp/andzia type none (rw,bind)

If you want this to persist across reboots, you’ll just need to update your /etc/fstab with the bind mount as well.

/home/andzia /ftp/andzia none bind 0 0

Get a hardware information using a CLI.

Dmidecode is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safe‐ness, this also makes the presented information possibly unreliable.


dmidecode |grep -i product

Recover root password.

1. Boot the LiveCD or rescue CD/USB, and mount your root (/) partition. For example:

mkdir /mnt/root
mount /dev/sdaX /mnt/root

and then edit the password file with your editor:

vim /mnt/root/etc/shadow

and then delete the second field on the root line:

root:$1$KmZw.u7l$JI6aYJRrSU7ZcUivaNQpZ1:15833:0:99999:7:::

2. Boot the LiveCD or rescue CD/USB, and mount your root (/) partition. For example:

mount -o remount,rw /dev/sdaX /mnt/root
chroot /mnt/root
passwd root

3. INIT or /bin/bash mode

Another trick is to add “init=/bin/bash” (LILO “linux init=/bin/bash” or add it to the Grub “kernel” line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialised, mounted, etc. You’ll definitely need the “-o remount,rw” here. Also note that other filesystems aren’t mounted at all, so you may need to mount them manually if you need them. Look in /etc/fstab for the device names.

passwd root

🙂

How to install and set up VPN (PPTP) server on Debian Linux.

PoPToP Point to Point Tunneling Server, this implements a Virtual Private Networking Server (VPN) that is compatible with Microsoft VPN clients. It allows windows users to connect to an internal firewalled network using their dialup.

Install pptpd:

root:# apt-get install pptpd

and then edit the configuration file:

root:# vim /etc/pptpd.conf

and add the following lines to:

localip 192.168.1.144
remoteip 192.168.1.200-225, 192.168.1.230

# Specifies the local and remote IP address ranges.
#
# Any addresses work as long as the local machine takes care of the
# routing. But if you want to use MS-Windows networking, you should
# use IP addresses out of the LAN address space and use the proxyarp
# option in the pppd options file, or run bcrelay.

then edit the configuration file:

root:# vim /etc/ppp/pptpd-options

and add the following lines to:

ms-dns 192.168.1.44 # my DNS server
nobsdcom
noipx
mtu 1490
mru 1490

edit another one configuration file:

root:# vim /etc/ppp/chap-secrets

and add the following lines to:

username * password *

then restart the pptpd service:

root@server: service pptpd restart

and don’t forget to enable 1723 on a firewall.