Saturday, January 13, 2018

Delete Healthy Recovery Partition on Windows 10

I wanted to expand a disk partition, but the free space was blocked by a small Healthy recovery partition, which could not be deleted by graphical Disk Management utility. A few search reveals diskpart Windows utility is a rescuer.

This is a link to original post. Below is a reference for my future use.

1. Open a command prompt as administrator.
2. Run Diskpart application by typing diskpart in the command prompt.
3. In the “diskpart” prompt, enter rescan command and press Enter key to re-scan all partitions, volumes and drives available.
4. Then type in list disk and press Enter key to show all hard disk drive available.
5. Select the disk that contains the partition you want to remove. Normally, with just 1 hard disk, it will be disk 0. So the command will be:
Select disk 0
Finish by Enter key.
6. Type list partition and press Enter key to show all available and created partition in the disk selected.
7. Select the partition that wanted to be deleted by using the following command, followed by Enter key:
Select partition x
Where x is the number of the recovery partition to be removed and unlocked its space. Be careful with the number of this partition, as wrong number may get data wipes off.
8. Finally, type in delete partition override and press Enter key.

Wednesday, January 10, 2018

Shell: Check if symbolic link

This function checks if given path has symbolic link within it.

checkSymbolicLink()
{
    if [ ! -d $1 ]; then
        return 1
    fi
    pushd $1 1>/dev/null
    cdir=$(pwd)
    while [ $cdir != '/' ]
    do
        if [ -h $cdir ]
        then
            return 0
        fi
        cd .. 1>/dev/null
        cdir=$(pwd)
    done
    popd 1>/dev/null
    return 1
}


To get real path, whether the path is real of symbolic, use realpath command.

Friday, January 05, 2018

A Note on .ssh folder

When I made a not wise decision to change /root and its content as fully accessible to other users while still logging in as root user, the other users were refused to log in as root through ssh. They could log in back after I revoked the write permission on /root folder.

Checking the /var/log/secure, it said
xx sshd[xxx]: Authentication refused: bad ownership or modes for directory /root

Based on this, further google search reveals .ssh folder does not like to be writable by group users.

Here is a suggestion to .ssh folder to make sure the access to it is mostly limited to owner itself:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys