Category: Linux

  • install ShadowSocks client in Ubuntu 18.04

    install ShadowSocks client in Ubuntu 18.04

    ShadowSocks client is part of shadowsocks package. This include both client and server. If you are looking to install server, see Install ShadowSocks server on Debian 10

    To install ShadowSocks, run

    apt install -y shadowsocks
    

    ShadowSocks client is called sslocal, get installed in /usr/bin/sslocal.

    On Ubuntu, no start up script provided with this package, so you need to create one or manually run sslocal when required.

    Create a service file

    vi /lib/systemd/system/[email protected]
    

    Add following content

    [Unit]
    Description=Shadowsocks client mode service
    Documentation=man:sslocal(1)
    After=network-online.target
    
    [Service]
    Type=simple
    User=nobody
    Group=nogroup
    ExecStart=/usr/bin/sslocal -q -c /etc/shadowsocks/%i.json
    Restart=on-failure
    RestartSec=30
    
    [Install]
    WantedBy=multi-user.target
    

    Now we need to create a configuration file with your ShadowSocks server IP and password.

    mkdir /etc/shadowsocks/
    vi /etc/shadowsocks/local.json
    

    Add following content

    {
        "server":"YOUR_SERVER_IP",
        "server_port":8044,
        "local_address": "127.0.0.1",
        "local_port":8044,
        "password":"PASSWORD",
        "timeout":300,
        "method":"aes-256-cfb",
        "fast_open": false,
        "workers": 1,
        "prefer_ipv6": false
    }
    

    “server” = IP of the server where you installled ShadowSocks server.
    “server_port” = Port used by ShadowSocks server
    “password” = ShadowSocks server password.

    local_port can be anything you like.

    Enable shadowsocks service

    systemctl enable shadowsocks-local@local
    

    To start

    systemctl start shadowsocks-local@local
    

    To see status

    systemctl status shadowsocks-local@local
    

    Now you can configure your browser or other sock proxy supported application using 127.0.0.1:8044. Here is how to configure firefox

    shadowsocks firefox settings

  • Install ShadowSocks server on Debian 10

    To install ShadowSocks server on Debian 10, run

    apt install -y shadowsocks
    

    Create config file

    vi /etc/shadowsocks/config.json
    

    Add following

    {
        "server":"SERVER_IP",
        "server_port":8044,
        "local_port":0,
        "password":"PASSWOARD_HERE",
        "timeout":600,
        "method":"aes-256-cfb"
    }
    

    You can change server_port if required.

    To enable service, run

    systemctl enable shadowsocks-server@config
    

    To start shadowsocks proxy, run

    systemctl start shadowsocks-server@config
    

    For status/restart

    systemctl status shadowsocks-server@config
    systemctl restart shadowsocks-server@config
    
  • Install nslookup on ArchLinux

    To install nslookup on ArchLinux, run

    pacman -S dnsutils
  • Setting up MineCraft Server in Ubuntu

    To setup MineCraft server on Ubuntu, first you need to install Java.

    apt install openjdk-8-jre -y
    

    Create a user to run minecraft

    useradd -m --shell /bin/bash minecraft
    

    You can set a password if you want direct SSH login to this user or login as root, then “su – minecraft”.

    passwd minecraft
    

    Login as user minecraft with SSH or “su”.

    Download minecraft server .jar file from

    https://www.minecraft.net/en-us/download/server/

    At the time of writing, i downloaded

    wget https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar
    

    Don’t use above link as it can get older, always go to minecraft site and get new link, so you get latest minecraft server jar file.

    You can start minecraft server with command

    java -Xmx1024M -Xms1024M -jar server.jar nogui
    

    First time when you run, it exit with some error related to EULA.

    You need to edit file

    vi eula.txt
    

    Set

    eula=true
    

    Now minecraft will run. You can create a run.sh file with following command for starting minecrat easily.

    vi ~/start.sh
    

    Paste following content

    #!/bin/bash
    
    java -Xmx1024M -Xms1024M -jar server.jar nogui
    

    To make the file executable, chmod it 755

    chmod 755 ~/start.sh
    

    When you start minecraft from terminal/ssh, it get closed when you disconnect. To keep minecraft server running after you disconnect, use tmux or screen.

  • networking

    On Ubuntu 19.04, networking service is provided by package ifupdown

    apt install -y ifupdown
    

    By default this package is not installed. So if you add network interface configuration in /etc/network/interfaces, it won’t work.

    Ubuntu 18.04 + use netplan instead of ifupdown/networking service to configure network interfaces.

    Linux KVM Bridge network on Ubuntu

    Configure OVH Bridge Network from command line

  • Ubuntu Configure systemd-resolved

    Latest Ubuntu/Debian use systemd-resolved for DNS resolution. On a fresh Ubuntu 19.04 install DNS failed to resolve.

    root@ubuntu19:/# ping serverok.in
    ping: serverok.in: Temporary failure in name resolution
    root@ubuntu19:/# 
    

    To fix this, create file

    mkdir /etc/systemd/resolved.conf.d/
    vi /etc/systemd/resolved.conf.d/dns_servers.conf
    

    Add content

    [Resolve]
    DNS=8.8.8.8 1.1.1.1
    

    Restart systemd-resolved

    systemctl restart systemd-resolved
    

    You can find systemd-resolvd status with command

    resolvectl status
    systemd-resolve --status
    

    To resolve a domain, use

    resolvectl query serverok.in
    

  • Configure OVH Bridge Network from command line

    Configure OVH Bridge Network from command line

    If you have a Proxmox or VmWare ESXi server on OVH network, you need to configure network interface once virtual machine is created.

    First login to OVH, go to IP page. Find the IP address you need to assign to this new VM, create a Virtual MAC. OVH allow 2 type of MAC. If you are using Proxmox, use OVH Mac. For VMWare ESXi, use vmware vmac.

    Once you have Virual Mac. you need to configure it in your VM network interface settings. For Vmware ESXi

    Now login to Virtial Machine, run following commands

    ip link set NETWORK_INTERFACE_HERE up
    ip addr add FO_IP_HERE dev NETWORK_INTERFACE_HERE
    ip route add GW_IP_HERE dev NETWORK_INTERFACE_HERE
    ip route add default via GW_IP_HERE dev NETWORK_INTERFACE_HERE
    

    In above, replace

    NETWORK_INTERFACE_HERE = name of your network interface. This can be found with command “ip link”. Normally it is eth0 or ensXXX.

    FO_IP_HERE = this is the Failover IP you will be using for this Virtual Machine.

    GW_IP_HERE = This is gateway IP. For OVH network, it will be your servers MAIN IP address with last number replaced with 254.

    Here is an actial example.

    ip link set ens192 up
    ip addr add 178.33.35.183 dev ens192
    ip route add 149.202.199.254 dev ens192
    ip route add default via 149.202.199.254 dev ens192
    

    This settings will be lost when you reboot OS. For configuring network interface permanantly, you can do

  • Install iperf3 on ArchLinux

    To install iperf3 on ArchLinux, run

    pacman -S iperf3
    

    To do speed test

    [root@tvmovies1 ~]# iperf3 -c ping.online.net -p 5209
    Connecting to host ping.online.net, port 5209
    [  5] local 163.172.50.206 port 50430 connected to 62.210.18.40 port 5209
    [ ID] Interval           Transfer     Bitrate         Retr  Cwnd
    [  5]   0.00-1.00   sec   282 MBytes  2.36 Gbits/sec    0    720 KBytes       
    [  5]   1.00-2.00   sec   280 MBytes  2.35 Gbits/sec    0    755 KBytes       
    [  5]   2.00-3.00   sec   281 MBytes  2.36 Gbits/sec   11    755 KBytes       
    [  5]   3.00-4.00   sec   280 MBytes  2.35 Gbits/sec    0    758 KBytes       
    [  5]   4.00-5.00   sec   281 MBytes  2.36 Gbits/sec    0    758 KBytes       
    [  5]   5.00-6.00   sec   256 MBytes  2.15 Gbits/sec  1507   42.4 KBytes       
    [  5]   6.00-7.00   sec   115 MBytes   965 Mbits/sec  6917    130 KBytes       
    [  5]   7.00-8.00   sec   114 MBytes   954 Mbits/sec  6643   48.1 KBytes       
    [  5]   8.00-9.00   sec   114 MBytes   954 Mbits/sec  6749    119 KBytes       
    [  5]   9.00-10.00  sec   112 MBytes   944 Mbits/sec  6923   38.2 KBytes       
    - - - - - - - - - - - - - - - - - - - - - - - - -
    [ ID] Interval           Transfer     Bitrate         Retr
    [  5]   0.00-10.00  sec  2.07 GBytes  1.77 Gbits/sec  28750             sender
    [  5]   0.00-10.00  sec  2.06 GBytes  1.77 Gbits/sec                  receiver
    
    iperf Done.
    [root@tvmovies1 ~]# 
    

    Here we do speed test with http://ping.online.net, they run iperf3 server on port 5209

  • Install netdata on ArchLinux

    First update the packages with

    pacman -Syu
    

    Install netdata

    pacman -S netdata
    

    Enable and start netdata

    systemctl enable netdata
    systemctl start netdata
    
  • Ubuntu remove SSH welcome message

    Ubuntu remove SSH welcome message

    When you login to an Ubuntu server using SSH, you get welcome message like

    Ubuntu welcome message

    On most Linux systems, this is generated by /etc/motd. On Ubuntu, MOTD (message of the day) generated dynamically with some scripts. I don’t want to see all the marketing message from Ubuntu everyday.

    To disable MOTD on Ubuntu, just delete the scripts from /etc/update-motd.d/

    rm -f /etc/update-motd.d/*
    

    If you want a differnt motd, you can put a shell script in this folder.

    Method 2

    Another way to disable motd is by disabling pam_motd.so module.

    Edit files

    /etc/pam.d/login
    /etc/pam.d/sshd
    

    Comment out the lines related to pam_motd.so

    session    optional     pam_motd.so  motd=/run/motd.dynamic
    session    optional     pam_motd.so noupdate
    
  • nmtui

    nmtui

    nmtui allow you to configure network interface if you are using network manager.

    On Debian/Ubuntu, it is part of network-manager package

    apt install network-manager
    

  • Install Linux Kernel 5.0 on Ubuntu 18.04 LTS

    Ubuntu 18.04 was released with Linux kernel 4.15

    root@DUS-147022:~# hostnamectl
       Static hostname: DUS-147022.op-net.com
             Icon name: computer-desktop
               Chassis: desktop
            Machine ID: 1fcb383ac03e4299a3b994dca4c51a10
               Boot ID: 66d616e9b11145c38387d71f9c48a4bd
      Operating System: Ubuntu 18.04.3 LTS
                Kernel: Linux 4.15.0-58-generic
          Architecture: x86-64
    root@DUS-147022:~# 
    

    On 8 Aug 2019, Cannonical released Ubuntu 18.04.3 LTS with Linux Kernel 5.0.

    If you are using older Ubuntu 18.04 point release, you won’t get newer kernel when you do software upgrade.

    To get newer Linux kernal installed, you need to install Hardware enablement (HWE) stack, this provide newer kernel that provide support for latest hardware.

    To install Hardware enablement (HWE) stack, run

    apt install linux-generic-hwe-18.04
    

    if this is Desktop computer, you may need to run

    apt install linux-generic-hwe-18.04 xserver-xorg-hwe-18.04
    

    after installing, reboot

    reboot
    

    after reboot, you will see latest Linux Kernel.

    boby@sok-01:~$ hostnamectl
       Static hostname: sok-01
             Icon name: computer-desktop
               Chassis: desktop
            Machine ID: 70486772aac1410c9a8031851ab60a0d
               Boot ID: 6c946c08f95d4c6b883e6790ab83e728
      Operating System: Ubuntu 18.04.3 LTS
                Kernel: Linux 5.0.0-25-generic
          Architecture: x86-64
    boby@sok-01:~$