Solution Resort

Learn, try and share…

Page 3 of 3

Virtual Box Mount new Disk (Centos 6)

This is a step to step guide mounting a disk to Centos 6 running on Virtual Box.

  1. Add a new disk under virtualbox setting -> storage.

  2. Set the new disk as Primary Slave

  3. Boot up centos and type in fdisk -l

You should see a disk called Disk /dev/sdb something like ,

Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  1. Run mkfs -t ext3 /dev/sdb will create a partition for the drive

  2. Mount the drive to /mnt/disk-extended by typing the following commands

mkdir /mnt/disk-extended
mount -t ext3 /dev/sdb /mnt/disk-extended

  1. Finally, automount the disk on boot by adding a line to /etc/fstab

LABEL=79d3d2d4  / ext4 defaults,noatime 0 0
LABEL=e21a3e10  /boot ext3 defaults,noatime 0 0
devpts /dev/pts  devpts  gid=5,mode=620   0 0
tmpfs   /dev/shm  tmpfs   defaults      0 0
proc    /proc proc defaults      0 0
sysfs   /sys   sysfs   defaults      0 0
/dev/sdb   /mnt/disk-extended   ext3  defaults   0 0

SSH Public / Private Key Setup

Create Public / Private key pairs

ssh-keygen -t [Type of the key]  -b [Number of bits in the key to create]

e.g. ssh-keygen -t rsa -b 4096

Copy public key to remote server

ssh-copy-id -i [path to public key] [username]@[host]

e.g. ssh-copy-id -i keys/sample_public_key.pub dummyuser@dummyhost.com

 

p.s.

Public key is always associated with a user when it gets copied onto the remote server. The default location storing the keys is usually ~/[user]/.ssh/. All public keys are appended to the ~/[user]/.ssh/authorized_keys file.

 

Useful Linux Commands

Commonly used Linux commands.

//change permissions recursively on Directories:
find . -type d -exec chmod XXX {} ;

//change permissions recursively on Files:
find . -type f -exec chmod XXX {} ;

//extract .tar.gz file:
tar -zxvf [file].tar.gz

//logout
logout

//switch user:
su [username]

//change owner of a directory recursively
chown -Rv [username] [somedir]

//change group of a directory recursively
chgrp -Rv [usergroup] [somedir]

//add a user and add to group
useradd -G [group-name] [username]

//add a group
groupadd [groupname]

//add an existing user to group
usermod -a -G [group name] [username]

//SSH into another server
ssh -i [path/to/private/keyfile] [username]@[ip]

//Find files / folders greater than a size
du -h / | grep ^[0-9.]*G
du -h /usr/ | grep ^[1-9][0-9][0-9][0-9]*M

Page 3 of 3

Powered by WordPress & Theme by Anders Norén