Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, November 5, 2016

Linux and Window computers unable to browse home network

Hi have a home network that consists of an ADSL router and a wireless access point.

Among the 4 smart phones, 5 tablets and 4 RaspberryPis I have 1 Linux Mint 18 desktop, 1 Ubuntu 16.04 server, 1 Linux Mint laptop, 3x Windows 10 laptops and 1 Windows 10 desktop. (I know to many for a household of 4 people but it is what I do for a living)

Recently I installed Windows 10 onto a laptop and suddenly was not able to browse the network from any of the network browsers (Linux or Windows). The strange this was that I was able to connect (from linux) using smb://192.168.1.3/ShareName and (from Windows) \\192.168.1.3\ShareName

After searching for the solution and trying many, many of the solutions I was not successful. I shutdown all the devices and started the Linux mint machines first then started the Windows machines (which was a real PITA) but nothing worked.

What finally DID WORK!

On the windows machines I opened a command line as administrator and ran the following:

  1. Click on Start button.
  2. Type Cmd in the Start Search text box.
  3. Press Ctrl-Shift-Enter keyboard shortcut to run command prompt as Administrator. Allow elevation request.
  4. Type netsh winsock reset in the Command Prompt shell, and then press the Enter key.
  5. Restart the computer.

Afterwards I was able to browse the network from both the windows machines as well as the Linux ones.

What netsh winsock reset command does are it resets Winsock Catalog to a clean state or default configuration. It removes all Winsock LSP (Layered Service Providers) previously installed, including the potential malfunctioned LSP that causes loss of network packets transmission failure. So all previously-installed LSPs must be reinstalled. This command does not affect Winsock Name Space Provider entries. (Shamelessly copied from here)

Wednesday, July 4, 2012

Fix VirtualBox Time Sync

Today I needed to do some testing on a VirtualBox VM to ensure that our software handles crossing over midnight correctly, this meant that I either needed to change the time on my VM or wait until midnight to do my testing (yeah that's not going to happen).

That's no problem you might say, ah but you'd be wrong for if you change the time and wait a few seconds then the time will reset itself. Once again I hear you say "no problem, disable 'synchronisation with the Internet time server" and once again you'd be wrong and the reason for this is that VirtualBox syncs the time between your Host and Guest machines.
To prevent this from happening you need to stop your VM and run the following command:

vboxmanage setextradata "VMs Name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Just replace VMs Name with the registered name (how it appears in VirtualBox) of your VM and voilà problem solved.

Note: If that doesn't work you can also modify the vbox file of your VM manually. Open the file with your favourite text editor and add the following line

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>

under the <ExtraData> element.

Friday, June 22, 2012

My customizations to an Ubuntu Server 12.04 LTS

I have been toying with the idea of setting up an Ubuntu Server to run my media server at home.  Each time I go down this route there are several tweaks I do until I am happy.  The following is a list of the things I have to search the web to find most often.
I have also found some awesome suggestions for tools for xfce at their wiki.
Table of Contents
  1. Screen Resolution
  2. Console Font
  3. Set line numbers to always appear in vi
  4. Change command prompt to include colour
  5. Some additional aliases
  6. cp with a wget style progress bar
  7. Lightweight xfce4 gui
  8. phpMyAdmin for the mysql db
  9. phpPgAdmin for the PostgreSQL db
  10. Install Oracle JDK 6
  11. Webmin

  1. Screen resolution.
  2. This is simply done by editing the /etc/defaults/grub file like so
    sudo vi /etc/defaults/grub

    find the line that says GRUB_CMDLINE_LINUX="" and change it to look as follows
    GRUB_CMDLINE_LINUX="vga=773"

    save the file and REMEMBER to run
    sudo update-grub

    This will give you a console resolution of 1024x768
    You can chose other resolutions based on the following table

    VGA Resolution Codes for GRUB & Lilo<
    --- Depth --

    Colorsbits640x480800×6001024×7681152×8641280×10241600×1200
    2568vga=769vga=771vga=773vga=353vga=775vga=796
    32000?vga=784vga=787vga=790vga= ? vga=793vga= ?
    6500016vga=785vga=788vga=791vga=355vga=794vga=798
    16.7M24vga=786vga=789vga=792vga=795vga=799vga= ?

    All you need do then is reboot and you should see your server with the new resolution.

  3. Console Font
  4. Still trying to find a permanent solution to this - The closest I have come is here but this setting gets lost after a reboot.

  5. Set line numbers to always appear in vi
  6. In you home directory create a file called .vimrc and add the following line to it
    set number

    Save the file and the next time you open vi each line will automatically be numbered.

  7. Change command prompt to include colour
  8. I use this in case I login as root or if I have su'ed to root so I won't forget who I am running as at the moment. If I am running as root I want my user to appear in bright red otherwise in bright green. I also want the directories to be displayed after the username in dull green and if I am root in dull red.
    For my normal user (The green one) I edit my .bashrc file in my HOME dir
    vi ~/.bashrc

    and add the following at the end of it.
    # Set prompt: " username@hostname/directory/tree $ " (with colors)
    export PS1="\[\e[32;1m\]\u\[\e[0m\]\[\e[32m\]@\h\[\e[36m\]\w \[\e[33m\]\$ \[\e[0m\]"

    For the root user I add the following to the end of roots .bashrc
    # Set prompt: " username@hostname/directory/tree $ " (with colors)
    export PS1="\[\e[31;1m\]\u\[\e[0m\]\[\e[31m\]@\h\[\e[31m\]\w \[\e[33m\]\$ \[\e[0m\]"


  9. Some additional aliases
  10. I have some other aliases that I make use of also that I add to the end of my .bashrc file
    alias ver="cat /etc/lsb-release"
    alias free="free -m"
    alias update="sudo apt-get update"
    alias install="sudo apt-get install"
    alias upgrade="sudo apt-get upgrade"
    alias remove="sudo apt-get remove"


  11. cp with a wget style progress bar
  12. When I am copying files I like to see the speed and progress of the copy. To do this I create a file in my home dir called cppv which look as follows

    #!/bin/bash

    set -e

    if [ $# -lt 2 ]; then
    echo "cppv - copy files with progress bar and rate limiting ability"
    echo "Usage: cppv source_file[s] destination_file_or_directory"
    echo "No other non-positional command line arguments can be given"
    echo "Always recurses like find"
    echo "You can change copying speed limit on the fly with \"pv -R\" if you find out pv's PID"
    echo "Use FIND_OPTS, PV_OPTS, CPIO_O_OPTS, CPIO_I_OPTS to override arguments to the pipeline parts"
    echo "Examples:"
    echo " cppv a b # Copy file a to b. Just calls \"pv a > b\""
    echo " cppv a d/ # Copy file a to d/a. Calls \"find a | cpio -o | pv | (cd d && cpio -i)\""
    echo " cppv *{01..26}*.mkv /mnt/usb/ # Copy all matching files to /mnt/usb/."
    echo " cppv dir1 dir2 # duplicate dir1"
    echo " PV_OPTS=\"-L 1M\" cppv . /tmp/ # Limit copying rate to 1M"
    echo " cppv /home/vi/bin /tmp/ # Warning: Copy /home/vi/bin to /tmp/home/vi/bin"
    exit 1
    fi;

    true ${CPIO_O_OPTS:="-H newc -0o"}
    true ${CPIO_I_OPTS:="-0diu --no-absolute-filenames"}
    true ${FIND_OPTS:="-depth -print0"}

    ARGS=( "$@" );

    DEST="${ARGS[$#-1]}"
    unset ARGS[$#-1];

    if [[ ( "${1:0:1}" == "-" && ! -e "$1" ) || ( "${DEST:0:1}" == "-" && ! -e "$DEST" ) ]]; then
    echo "There should not be any command line options. Only file names." >&2
    exit 1;
    fi

    DIRMODE=0

    if [[ $# > 2 || "${DEST:${#DEST}-1:1}" == "/" || -d $DEST ]]; then
    DIRMODE=1
    elif [[ -d "$1" && ! -d "$2" ]]; then
    DIRMODE=1
    mkdir "$DEST";
    DEST=`readlink -f "$DEST"`;
    cd "$1";
    ARGS=(".")
    fi

    if [ $DIRMODE == 0 ]; then
    pv "$1" > "$2" && exit 0;
    fi;

    if [ ! -d "$DEST" ]; then
    echo Not a directory: "$DEST" >&2
    exit 1
    fi

    if [ "${1:0:1}" == "/" ]; then
    echo "Warning: it will do a bit different thing than usual cp" >&2
    echo " For example, copying $1 to $DEST$1, not to $DEST/`basename $1`" >&2
    fi

    SIZE=`du -sb "${ARGS[@]}" | perl -ne '/^(\d+)/ and $q+=$1; END{print $q}'`

    find "${ARGS[@]}" $FIND_OPTS | cpio $CPIO_O_OPTS | pv -s $SIZE $PV_OPTS | (cd "$DEST" && cpio $CPIO_I_OPTS)


    I also create a static link in the /usr/bin dir to this file so I don't have to keep adding the path before the command. The command to create a static link looks like so:
    sudo ln -s ~/cppv /usr/bin/cppv


  13. Lightweight xfce4 gui

  14. From the CLI terminal, we will install a few software packages to make our life easy
    1. Install the Xfce desktop environment (a GUI for using the server) :

    2. sudo apt-get install xfce4 xfce4-terminal xauth xorg

    3. Install the Gnome Display Manager (which includes a GUI login manager) :

    4. sudo apt-get install gdm

      Alternately (what I prefer to do is) install lightdm

      sudo apt-get install lightdm-gtk-greeter

    5. If you find you have some icons missing try this to fix the problem. Also check under
      "Applications Menu->Settings->Appearance" under the icon tab and make sure you are using an icon theme.

    6. sudo apt-get install tango-icon-theme tango-icon-theme-extras gnome-icon-theme

    7. I change the font of my terminal to use "Monospace" size 10
      "Edit->Preferences->Appearance"

    8. I want my terminal window to use more real estate so I edit the "~/.config/Terminal/terminalrc" file and change the MiscDefaultGeometry setting to look as follows.

    9. MiscDefaultGeometry=100x40

    10. OPTIONAL: Install the Synaptic package manager (a GUI for installing software) :

    11. sudo apt-get install synaptic

    12. OPTIONAL: Install the Update manager (a GUI for updating software) :

    13. sudo apt-get install update-manager

    14. OPTIONAL: Install the Gnome System Tools (which includes a GUI for user administration) :

    15. sudo apt-get install gnome-system-tools

    16. Now reboot the server, so that you can login to the Xfce GUI environment :

    17. sudo shutdown -r now

    When the server reboots, there will now be a GUI login screen
    Select the xfce-session, the username and enter the password
    The Xfce desktop environment will be displayed with the menu panel on top and a few icons on the desktop screen

  15. phpMyAdmin for the mysql db

  16. If I have installed mysql I normally install phpMyAdmin to make manipulation and admin of the database easier. This is easily done by following the setup found here. But basically you need to run the following with some configuration.

    sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

  17. phpPgAdmin for the PostgreSQL db

  18. If I have installed PostgreSQL I normally install phpPgAdmin to make manipulation and admin of the database easier.

    The following instructions will get PostgreSQL accessible from a remote server on your lan

    If PostgreSQL is not installed already:

    sudo apt-get install postgresql

    Log into PostgreSQL and create an account and a database for the user:

    sudo -u postgres psql template1
    psql> create user acme with createdb password 'abcd';
    psql> create database acme with owner=acme; psql> \q


    Leave out the createdb option in the CREATE USER statement if you do not want to grant the user the privilege to create databases.

    By default PostgreSQL server does not accept remote connections. To enable remote connections (which is necessary for servers like CS3 but not for servers like CSNS), modify /etc/postgresql/9.1/main/postgresql.conf so:

    listen_addresses = '*'


    And modify /etc/postgresql/9.1/main/pg_hba.conf so that:

    host all all 0.0.0.0/0 md5
    host all all ::0/0 md5


    To install phpPgAdmin:

    sudo apt-get install phppgadmin

    By default phpPgAdmin only allows local access. To allow remote access, edit /etc/phppgadmin/apache.conf so that

    #deny from all
    #allow from 127.0.0.0/255.0.0.0 ::1/128
    allow from all

    Then restart Apache2. After that phpPgAdmin can be accessed at http://host/phpmyadmin/ .

    NOTE:I was looking for the quickest way to manage PostgreSQL I was not testing the security of the admin tool.

  19. Install Oracle JDK 6

  20. I followed this link to install the Oracle JDK6 onto my Ubuntu Server.
    I also add the following to my .bashrc
    # Java environment variables
    export JAVA_HOME=/usr/lib/jvm/java-6-oracle
    export PATH=$PATH:$JAVA_HOME/bin

  21. Webmin

  22. I can't believe I didn't remember to talk about installing Webmin. Firstly you'll need to have some dependancies installed. You can do this by running the following from the command line.
    apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

    Official instructions can be found here, but basically there are 2 ways to install webmin.
    1. Via APT
    As root edit /etc/apt/sources.list and add the following lines
    deb http://download.webmin.com/download/repository sarge contrib
    deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

    You will then need to install the GPG key which you can do using the following as rootcommand
    wget http://www.webmin.com/jcameron-key.asc && sudo apt-key add jcameron-key.asc
    Once you have update the sources file you can install webmin using the following commands.
    sudo apt-get update
    sudo apt-get install webmin

    2. Manually Download the latest webmin archive.
    wget http://www.webmin.com/download/deb/webmin-current.deb

    Install webmin with following command:
    sudo dpkg --install webmin-current

    You can connect to webmin by pointing your browser to:
    http://server-host-ip-address:10000/

Friday, May 16, 2008

WARNING: HDD shortened life span under linux

Please note this is NOT my work. I have shamelessly copyied it from http://ubuntuforums.org/showthread.php?t=795327 so kudos to nicedude.

Due to APM constantly parking and unparking your hdd your hdd cycle count increases rapidly. As most drives are rated to 600 000 cycles the faster you get to these the faster your drive will wear. I tested my drive (Western Digital) and found I suffered from this very problem.

Basically you need to do the following - Install the disk monitoring tools


sudo aptitude install smartmontools

Then by running


sudo fdisk -l

and finding out how your drive is addressed (I.e. /dev/sda) you can run this


sudo smartctl -a /dev/sda | grep Load_Cycle_Count

WAIT 15 MINS AND RUN THE COMMAND AGAIN

NB: If in 15 mins the last number increased by more than 2-4 then you suffer from the same issue as I did.  Following the directions in the origional post I downloaded the shell script to my desktop made it executable and ran the following


sudo cp ~/Desktop/99-sda-load-count-fix.sh /etc/acpi
sudo cp ~/Desktop/99-sda-load-count-fix.sh /etc/acpi/start.d
sudo cp ~/Desktop/99-sda-load-count-fix.sh /etc/acpi/suspend.d
sudo cp ~/Desktop/99-sda-load-count-fix.sh /etc/acpi/resume.d



you could also create the shell script yourself it looks as follows


#!/bin/sh
## Script by nicedude at Ubuntu forum 5-14-2008
## A fix to stop high hdd spin down counts from occuring thereby increasing hdd life
## The hdparm -B parameter can be adjusted between 200-254 should be sufficient for these purposes
## Using the value - B 200 should work fine if not enough then you could increase up to a max of 255
## which means no APM power management for the drive
## If your drive is called hda instead of sda then change it below
## You can find out by running sudo fdisk -l in a terminal and looking at whether it is called hda or sda

hdparm -B 200 /dev/sda


After a reboot run the following to get the Load_Cycle_Count


sudo smartctl -a /dev/sda | grep Load_Cycle_Count


WAIT 15 MINS AND RUN THE COMMAND AGAIN

You should only see a small increment.

Hope you are feeling a little more comfortable.. ;)