1.04.2015

Add and Delete Users on Ubuntu 14.10

1. Create user
samdc@mango:~$ sudo adduser raqueldc
[sudo] password for samdc: 
Adding user `raqueldc' ...
Adding new group `raqueldc' (1001) ...
Adding new user `raqueldc' (1001) with group `raqueldc' ...
Creating home directory `/home/raqueldc' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for raqueldc
Enter the new value, or press ENTER for the default
 Full Name []: Raquel
 Room Number []: 
 Work Phone []: 
 Home Phone []: 
 Other []: 
Is the information correct? [Y/n] 

2. Delete user
Delete account:
samdc@mango:~$ sudo userdel newuser
Delete home directory
samdc@mango:~$ sudo rm -rf /home/newuser
==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case

Move home dir to another drive

Got it from here.
First install the drive, then follow these steps:
1. Find UUID of the partition
root@mango:~# blkid 
/dev/sdb1: UUID="8b1e1564-d7b6-4ef4-9ffd-d7d191251cc2" TYPE="ext4" PARTUUID="0835b8cd-01"

2. Modify fstab
root@mango:~# vim /etc/fstab
Add this line
UUID=8b1e1564-d7b6-4ef4-9ffd-d7d191251cc2 /media/home          ext4    defaults        0       2

3. Create temporary mount point
root@mango:~# mkdir /media/home

4. Reload fstab
root@mango:~# mount -a

5. Copy /home to new partition
root@mango:~# rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/.

6. Prepare fstab for the switch
root@mango:/home/samdc# vim /etc/fstab
Modify this line to:
UUID=8b1e1564-d7b6-4ef4-9ffd-d7d191251cc2 /home          ext4    defaults        0       2

7. Do the switch
root@mango:~# cd / && sudo mv /home /old_home && sudo mkdir /home

8. Reload fstab
root@mango:/# mount -a

9. Delete old home
root@mango:/# rm -r /old_home

10. Reboot
==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case

Install a new hard drive

Got it from here.
1. Partition disk
samdc@mango:/dev$ sudo fdisk /dev/sdc

Welcome to fdisk (util-linux 2.25.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb73af669.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048): 2048
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953525167, default 1953525167): 

Created a new partition 1 of type 'Linux' and of size 931.5 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

2. Format disk
samdc@mango:/dev$ sudo mkfs -t ext4 /dev/sdc1
mke2fs 1.42.10 (18-May-2014)
Creating filesystem with 244190390 4k blocks and 61054976 inodes
Filesystem UUID: 6dba4379-83fa-4288-b390-98574bc24bb2
Superblock backups stored on blocks: 
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
 102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     

3. Modify reserved space
samdc@mango:/dev$ sudo tune2fs -m 1 /dev/sdc1
tune2fs 1.42.10 (18-May-2014)
Setting reserved blocks percentage to 1% (2441903 blocks)

4. Label disk
samdc@mango:/dev$ sudo e2label /dev/sdc1 DataDisk2

5. Create mount point
samdc@mango:/dev$ sudo mkdir /data2

6. Mount the drive
Automatic mount at boot:
root@mango:/dev# vim /etc/fstab
Add this line (find out UUID of the disk via blkid):
UUID=6dba4379-83fa-4288-b390-98574bc24bb2 /data2           ext4    defaults 0       2
For changes to take effect:
root@mango:/dev# mount -a

Manually mount/unmount:
sudo mount /dev/sdc1 /data2
sudo umount /data2
==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case

Find out what disks are in the system

root@mango:/dev# sfdisk -l

Disk /dev/sda: 29185 cylinders, 255 heads, 63 sectors/track
sfdisk: Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1   *      0+  27135-  27136- 217963520   83  Linux
/dev/sda2      27135+  29185-   2050-  16464897    5  Extended
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
/dev/sda5      27135+  29185-   2050-  16464896   82  Linux swap / Solaris

Disk /dev/sdb: 121601 cylinders, 255 heads, 63 sectors/track

Disk /dev/sdc: 121601 cylinders, 255 heads, 63 sectors/track

root@mango:/dev# lshw -class disk
  *-disk                  
       description: ATA Disk
       product: OCZ-ARC100
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: 1.00
       serial: A22L1061449007331
       size: 223GiB (240GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 sectorsize=512 signature=2a960743
  *-disk
       description: ATA Disk
       product: WDC WD10EZEX-00B
       vendor: Western Digital
       physical id: 0.0.0
       bus info: scsi@1:0.0.0
       logical name: /dev/sdb
       version: 1A01
       serial: WD-WCC3F3NFSS65
       size: 931GiB (1TB)
       configuration: ansiversion=5 sectorsize=4096
  *-cdrom
       description: DVD-RAM writer
       product: iHAS124   E
       vendor: ATAPI
       physical id: 0.0.0
       bus info: scsi@3:0.0.0
       logical name: /dev/cdrom
       logical name: /dev/cdrw
       logical name: /dev/dvd
       logical name: /dev/dvdrw
       logical name: /dev/sr0
       version: 4L08
       capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
       configuration: ansiversion=5 status=nodisc
  *-disk
       description: ATA Disk
       product: WDC WD10EZEX-00B
       vendor: Western Digital
       physical id: 0.0.0
       bus info: scsi@4:0.0.0
       logical name: /dev/sdc
       version: 1A01
       serial: WD-WCC3F1CX4JKE
       size: 931GiB (1TB)
       configuration: ansiversion=5 sectorsize=4096

root@mango:/dev# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                      
├─sda1 ext4         1987feef-7ad1-4e00-8578-9559d8aff148 /
├─sda2                                                   
└─sda5 swap         c17c259d-e3a8-4220-9f0d-9df4af33fa34 [SWAP]
sdb                                                      
sdc                                                      
sr0                                                      

root@mango:/dev# blkid
/dev/sda1: UUID="1987feef-7ad1-4e00-8578-9559d8aff148" TYPE="ext4" PARTUUID="2a960743-01" 
/dev/sda5: UUID="c17c259d-e3a8-4220-9f0d-9df4af33fa34" TYPE="swap" PARTUUID="2a960743-05" 

root@mango:/dev# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Jan  4 08:24 1987feef-7ad1-4e00-8578-9559d8aff148 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jan  4 08:24 c17c259d-e3a8-4220-9f0d-9df4af33fa34 -> ../../sda5

==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case

New System 2015

I built a new system this winter break...

==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case

12.13.2014

Perforce Client Setup

I got it from here.
1. Export environment variable
$ export P4CONFIG=.p4config

2. Create workspace directory
$ cd /auto/home/delacs/projects/autoselect_feature
$ mkdir code

3. Create p4 config file, name of client will be 'delacs-autoselect-feature'
$ vi .p4config
P4CLIENT=delacs-autoselect-feature
P4PORT=server.domain.com:1666

4. Create the client
$ p4 client

In text editor:
Client: delacs-autoselect-feature
Root:  /auto/home/delacs/projects/autoselect_feature
View: //tools/main/perf/scripts/scheduler/... //delacs-autoselect-feature/code/scheduler/...
      //tools/parser/... //delacs-autoselect-feature/code/parser/...

5. Now, let's pull down code from perforce
$ p4 sync

11.24.2014

Get Latest Records SQL

Using this SQL:

SELECT sb1.date, sb1.branch, sb1.build
FROM stable_builds sb1
INNER JOIN (
    SELECT max(date) date, branch
    FROM stable_builds
    GROUP BY branch
) AS sb2
ON sb1.branch = sb2.branch
AND sb1.date = sb2.date
ORDER BY date DESC

Data:
Date Branch Build   
2014-11-24 5.6 460049
2014-11-19 5.6 459641
2014-11-16 5.6 459347

Output:
Date Branch Build   
2014-11-24 5.6 460049