page

Nov 12, 2018

Add a New Disk Larger Than 2TB to An Existing Linux

see more details in
https://www.tecmint.com/add-disk-larger-than-2tb-to-an-existing-linux/


# list current partitions

[lee@hwang29 ~]$ sudo fdisk -l




# move to disk
[lee@hwang29 ~]$ sudo fdisk /dev/sda


 
d : delete a partition  # deletes the partition. It will delete the data on the disk
w : write table to disk and exit

# write partition with parted
[lee@hwang29 ~]$ sudo parted /dev/sda

(parted) mklabel gpt   # set partition table format to GPT (GUID Partition Table)
(parted) mkpart primary 0GB 3000GB # create primary partition, assaing disk capacity
(parted) quit


# Creating an ext4 File System
[lee@hwang29 ~]$ sudo mkfs.ext4 /dev/sda

# mount disk
[lee@hwang29 ~]$ sudo mount /dev/sda /data_1

# add entry to /etc/fstab for permanent mounting
[lee@hwang29 ~]$ vim /etc/fstab
/dev/sda    /data_1    ext4    defaults    0    0


tip for naming the disk
- /dev/disk/by-id/scsi-SATA_ModelName_partion1 instead of  /dev/disk/sda
- if you are using multiple disk/partition and one of them is failed, it is easy to identify which disk and partition goes wrong
- if you change, add, move disk, it might cause problems because other disk already use name sda, sdb

How to read a file into a variable in shell?


https://stackoverflow.com/questions/7427262/how-to-read-a-file-into-a-variable-in-shell


1. make file name list

ls | grep .gz > file_name_list.txt


2.  read file into shell variable & do 'for'

value=$(<file_name_list.txt)
for name in $value
do
/program_path/program -i /file_path/${name}
done

Nov 7, 2018

mount iso file in linux

https://askubuntu.com/questions/164227/how-to-mount-an-iso-file


  1. Create a directory to serve as the mount location:
    sudo mkdir /mnt/iso
    
  2. Mount the ISO in the target directory:
    sudo mount -o loop path/to/iso/file/YOUR_ISO_FILE.ISO /mnt/iso
    
  3. Unmount the ISO:
    sudo umount /mnt/iso
    

Oct 29, 2018

tophat install error : except getopt.error, msg: SyntaxError: invalid syntax

http://seqanswers.com/forums/showthread.php?t=17514

Error :
File "./tophat", line 1003
    except getopt.error, msg:
                       ^
SyntaxError: invalid syntax

To solve :
edit tophat

#!/usr/bin/env python2

instead of

#!/usr/bin/env python


This error comes from the difference between python2 and python3.

check your path  and version of python

Sep 18, 2018

python - List Comprehensions

python - List Comprehensions

https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions

List comprehensions provide a concise way to create lists. Common applications are to make new lists where each element is the result of some operations applied to each member of another sequence or iterable, or to create a subsequence of those elements that satisfy a certain condition.
For example, assume we want to create a list of squares, like:
>>> squares = []
>>> for x in range(10):
...     squares.append(x**2)
...
>>> squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
We can obtain the same result with:
squares = [x**2 for x in range(10)]
This is also equivalent to squares = map(lambda x: x**2, range(10)), but it’s more concise and readable.
A list comprehension consists of brackets containing an expression followed by a for clause, then zero or more for or if clauses. The result will be a new list resulting from evaluating the expression in the context of the for and if clauses which follow it. For example, this listcomp combines the elements of two lists if they are not equal:
>>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]
and it’s equivalent to:
>>> combs = []
>>> for x in [1,2,3]:
...     for y in [3,1,4]:
...         if x != y:
...             combs.append((x, y))
...
>>> combs
[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]

Aug 17, 2018

install R with --enable-R-shlib=yes [for shared library]

install R with --enable-R-shlib=yes  [for shared library]

if you have pre-installed R and want to install new version of R,

you need to install new version of R with shared library to share library with old version

and run rstudio.

https://stackoverflow.com/questions/28096239/how-to-configure-r-3-1-2-with-enable-r-shlib