WHAT'S NEW?
Loading...
Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

To scan all Wifi networks try using the command sudo iwlist scan

wlan0    unassociated  Nickname:"rtl_wifi"
         Mode:Managed  Access Point: Not-Associated   Sensitivity:0/0
         Retry:off   RTS thr:off   Fragment thr:off
         Power Management:off
         Link Quality:0  Signal level:0  Noise level:0
         Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
         Tx excessive retries:0  Invalid misc:0   Missed beacon:0

You can connect to your WPA2 access point by putting the following in /etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp
wpa-ssid <your_router>
wpa-psk <your_wpa_key>
Get the system to read and use the changes:
sudo ifdown wlan0 && sudo ifup -v wlan0
By default a guest machine in VirtualBox is configured to use so called NAT networking - the guest's network adapter's IP is in a "virtual" subnet which includes the guest and the parent VirtualBox application which acts as a gateway.

For the guest (Linux Server inside Virtual Box) it looks like it accessing internet via something like an ordinary ADSL modem, but the guest can't be accessed from anywhere, just like you can't access machines in your local network from Internet without specifically configuring your modem to allow such access.

If you need to access your guest from outside, you need to configure bridged networking, which will give your guest its own IP in your local network. The configuration is done in VirtualBox settings.  When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.

To enable bridged networking, all you need to do is to open the Settings dialog of a virtual machine, go to the "Network" page and select "Bridged network" in the drop down list for the "Attached to" field. 


Put a Static IP in VirtualBox Machine with Ubuntu 16.04

Set first Adapter to "Host-only Adapter" and second one to "NAT" and in this example you could successfully get IP set to "192.168.56.106" with following configuration. Here is my /etc/network/interfaces :
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Host Only Network
auto enp0s3
iface enp0s3 inet static
dns-nameservers 8.8.8.8 8.8.4.4
address 192.168.56.106
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255

# NAT Network
auto enp0s8
iface enp0s8 inet dhcp

The order of the network adapters in the VirtualBox settings makes the difference.
First one should be host-only, second one NAT.
This a step by step guide on how to setup your own  monero mining pool. Remember: you must be logged in as root.

# System Updates and Pool Requirements
yes | sudo apt -y --force-yes update
yes | sudo apt -y --force-yes upgrade
sudo apt install git libssl-dev libboost-all-dev build-essential tcl curl gcc g++ cmake -y

# Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
sudo mkdir /etc/redis
sudo cp /tmp/redis-stable/redis.conf /etc/redis
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redis

# Update Redis Files
# Change line that starts with "supervised no" to "supervised systemd"
sudo sed -i 's/supervised no/supervised systemd/g' /etc/redis/redis.conf
# Change line that starts with "dir ./"  to "dir /var/lib/redis"
sudo sed -i 's/dir .\//dir \/var\/lib\/redis/g' /etc/redis/redis.conf

# Install Node 0.10.48
cd /tmp
curl -O https://nodejs.org/download/release/v0.10.48/node-v0.10.48-linux-x64.tar.gz
tar xzvf node-v0.10.48-linux-x64.tar.gz
sudo cp /tmp/node-v0.10.48-linux-x64/bin/node /usr/bin/
sudo cp -R /tmp/node-v0.10.48-linux-x64/lib/* /usr/lib/
sudo ln -s /usr/lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm

# Install Pool
cd /tmp
git clone https://github.com/CanadianRepublican/monero-universal-pool.git pool
sudo mv ./pool /opt/pool
cd /opt/pool
npm update

# Firewall Setup
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 3333
sudo ufw allow 5555
sudo ufw allow 7777
sudo ufw allow 8888

// The config file will need some configuring to work
cp ./config_backup.json ./config.json

sudo cp ./utils/redis.service /etc/systemd/system/redis.service
sudo systemctl start redis
sudo systemctl enable redis

// run the pool
node init.js
I had a typo in my fstab and it boots to a commandline but is readonly, I know what the error is but i can't change it because it's mounted as readonly. I want to mount the filesystem and make the changes.


We must mount / in read-write mode. If /etc/fstab is correct, you can simply type:

 mount -n -o remount /

But if /etc/fstab is wrong (as it was in my case), you must give the device name and possibly the type, too: e.g.

 mount -n -o remount -t extX /dev/hdaX /

Where extX is your filesystem type and /dev/hdaX is partition you use for your root mount point. To see all your available partitions just type

ls /dev/[sh]d*

To list out all your partitions, type

 lvmdiskscan
Installing the below packages alone will auto-mounts your exFAT formatted drives ,

sudo apt-get install exfat-fuse exfat-utils

Or you may try to mount it manually after installing the above packages,

sudo mkdir /media/exfat
sudo mount -t exfat /dev/sdxx /media/exfat 

/dev/sdxx - your exfat partition. Use the commands to find your exfat usb

fdisk -l

lsblk 

sudo lsusb will tell you what USB devices Linux detects. Whether a USB storage device mounts, or is detected, are separate issues. sudo lsusb -v will give verbose output, possibly more information than you want if the OS truly doesn't recognize the device.

To unmount it, just enter sudo umount /media/exfat in the Terminal.

In Ubuntu 16, exfat-fuse and exfat-utils packages are available in Universe repository.

So enable this repository inorder to install these two packages on Ubuntu 16.

sudo add-apt-repository universe

And don't forget to update all repositories,

sudo apt-get update


Permanent Mount

In order to mount your USB drive permanently after reboot add the following line into your /etc/fstab config file:

/dev/sdc1       /media/usb-drive           exfat  defaults        0       0 

However, the above mount line may fail if you add or remove additional drives from your Linux system. From this reason it is recommend to use partition UUID instead of a raw block device name. To do so, first locate a UUID of your USB drive:

# ls -l /dev/disk/by-uuid/*
lrwxrwxrwx 1 root root 10 Mar 27 23:38 /dev/disk/by-uuid/2016-08-30-11-31-31-00 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Mar 27 23:38 /dev/disk/by-uuid/3eccfd4e-bd8b-4b5f-9fd8-4414a32ac289 -> ../../sda1
lrwxrwxrwx 1 root root 10 Mar 27 23:38 /dev/disk/by-uuid/4082248b-809d-4e63-93d2-56b5f13c875f -> ../../sda5
lrwxrwxrwx 1 root root 10 Mar 28 01:09 /dev/disk/by-uuid/8765-4321 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Mar 27 23:38 /dev/disk/by-uuid/E6E3-F2A2 -> ../../sdb2

Based on the above ls command output we can see that the UUID belonging to block device sdc1 is
8765-4321 thus our /etc/fstab mount line will be:

/dev/disk/by-uuid/8765-4321    /media/usb-drive         exfat 0   0

Run mount -a command to mount all not yet mounted devices.

# mount -a 
  1. From VirtualBox enter your VM settings > shared folders and add a new one; choose the path in your host machine name it FOLDER_NAME and check Auto mount and make permanent.
  2. Install Guest additions; look at this to see how. In summary:
    sudo apt-get update
    sudo apt-get install build-essential linux-headers-$(uname -r)
    sudo apt-get install virtualbox-ose-guest-x11
    sudo apt-get install virtualbox-guest-dkms
    reboot
    
  3. Make a folder on your guest VM to point to the folder created on the host, just create a new folder, for example /home/"your_user_name"/shared
  4. Mmount the shared folder: sudo mount -t vboxsf "FOLDER_NAME" /home/"your_user_name"/shared
  5. To make the mount automatic, add mount -t vboxsf "FOLDER_NAME" /home/"your_user_name"/shared" to the end of "/etc/rc.local" before "exit 0"

How To Start

We must install bitmonerod daemon software that ships with the Monero tree. It is a console program, and manages the blockchain. While a bitcoin wallet manages both an account and the blockchain, Monero separates these: bitmonerod handles the blockchain, and simplewallet handles the account.
This guide assumes you have already set up your VPS account and are using SSH to tunnel into the server console.

Linux, 64-bit (Ubuntu)

Make sure that port 18080 is open

bitmonerod uses this port to communicate with other nodes on the Monero network.
Example if using ufw: sudo ufw allow 18080 Example if using iptables: sudo iptables -A INPUT -p tcp --dport 18080 -j ACCEPT

Download the current Monero Core binaries

wget https://downloads.getmonero.org/linux64

Make a directory and extract the files.

mkdir bitmonero
tar -xjvf linux64 -C bitmonero

Launch the daemon

cd bitmonero
./bitmonerod

Options:

Show list of all options and settings:
./bitmonerod --help
Launch the daemon as a background process:
./bitmonerod --detach
Monitor the output of bitmonerod if running as daemon:

tail -f .bitmonero/bitmonero.log
XMR-Stak is a universal Stratum pool miner. This is the CPU-mining version and we are using a fresh Ubuntu 16.04 install

sudo apt-get --assume-yes update
sudo apt-get --assume-yes install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev screen git nano
git clone https://github.com/fireice-uk/xmr-stak-cpu.git
cd xmr-stak-cpu
cmake .
make install
cd bin/
chmod +x xmr-stak-cpu
./xmr-stak-cpu
Edit bin/config.txt file and also make sure to edit the following lines:


"pool_address" : "xmr-eu1.nanopool.org:14444",
"wallet_address" : "43x4C2pwcvWgGS9Mb9sCcY9SxFjthrk92YM3dT1VHR8QNc4kpj2MJfGQYAYKWBp2s9R9s6sheFx7DWCUezRkZrehDzenTqd",
"pool_password" : "",

After you have the config.txt edited correctly simply run xmr-stak-cpu. If you run into issues related to mmap this means you need to enable hugepages. To do this type the following commands: 

sysctl -w vm.nr_hugepages=128

nano /etc/sysctl.conf

At the end of the sysctl.conf file add:

vm.nr_hugepages=128

More info here
https://www.cryptocurrencyfreak.com/2017/08/22/monero-mining-xmr-stak-cpu-ubuntu-16-04/



First of all, install NCDU

NCDU stands for NCurse Disk Usage which is Linux program that displays Disk usage statistics in a Ncurse menu, which makes things easier where you don’t know exactly where to start

apt install ncdu


Use dpkg-query to find the largest packages and remove the ones you don't need anymore.
dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}
If the application has been installed via the package manager, all you have to do is run
sudo apt-get remove <application_name>

sudo apt-get autoremove

#check partition sizes
df -h
#check directory size
du -s -h /var/log/
#check every directory and file sizes under a dir.
du -s -h /var/log/*


Before doing anything, create a backup. You can restore your server in case anything goes wrong. Go to the shell and start by running this command with no options:
  • sudo do-release-upgrade
If the new Ubuntu has not been released yet, you should see the following:
Sample Output
Checking for a new Ubuntu release
No new release found
In order to upgrade to  the last version  before its official release, specify the -d option in order to use the development release:
  • sudo do-release-upgrade -d
If you're connected to your system over SSH, you'll be asked whether you wish to continue.
Follow the on-screen instructions.
You will now see the packages that are going to be upgraded and the changes that are going to be made. Note that the upgrading process can take several hours, and you can't cancel the process once Ubuntu is upgrading.

After the upgrade has finished, you can confirm your server is running on the new version by executing the command

lsb_release -r
Suppose we have a Raspberry Pi connected to the TV with an HDMI cable and that uses the internet connection via Wifi. In this example, the operating system is Ubuntu Mate. What we want to get is to connect the Raspberry Pi directly to the home router using an Ethernet cable and set up a static IP address so that we can connect it later using SSH.

First of all, while we are connected to Wifi, we enable Raspberry to get a dynamic IP from the Ethernet cable. To enable this feature we will have to edit the file

/etc/network/interfaces

and add these 2 lines if they are not present

auto eth0
iface eth0 inet dhcp

the result file should be similar to this

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Connect the Raspberry Pi to your router with the Ethernet cable and do a reboot.

From command line do: ifconfig



You should see a result similar to the one up. To find your Ethernet IP you have to look at the interface Eth0 and then look at the inet (IPv4) section, in the example is : 192.168.1.48

Use the route -n command and mark the values you get

raspberry@raspberry:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    1024   0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

My example values are

Gateway 192.168.1.1
Newtwork 192.168.1.0
NetMask 255.255.255.0

Now we have all informations we need to proceed

sudo nano /etc/network/interfaces


Comment the line about dynamic IP address and Eth0 interface by using #
add the line to obtain the static IP and the lines of your configuration as the example. This sets your static IP, and the appropriate settings for your resolv.conf. You'll notice it uses your local DNS, a Google DNS (8.8.8.8 and 8.8.4.4)  the final result must be similar to the follow.

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
#iface eth0 inet dhcp
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.48
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8 8.8.4.4

All done! The Raspberry static IP via Ethernet cable will be 192.168.1.48 in our exmple. Last thing to do is to reboot the system.

sudo reboot

Looking for web server ownership process

Try running ps aux | grep php to see which user owns the PHP process. 
$ ps aux | grep php
root      1249  0.0  0.1 290648  5956 ?        Ss   Sep17   0:01 php-fpm: master process (/etc/php/php-fpm.conf)              
http      1278  0.0  1.0 374340 39492 ?        S    Sep17   0:21 php-fpm: pool www                                            
http      1279  0.0  1.1 374808 41460 ?        S    Sep17   0:12 php-fpm: pool www                                            
http      3934  0.0  1.0 374852 38048 ?        S    Sep17   0:17 php-fpm: pool www
It tells that the PHP process is running under the user http.
So, a quick solution will be to issue this command and give user recursive ownership of the whole WordPress installation
$ sudo chown -hR http:http PATH_TO_YOUR_WORDPRESS_FOLDER
Replacing http with whatever user is yours.
Notes: If you are using Ubuntu. The default user and group of your PHP and Web Server software is www-data.

Add below line at the bottom of wp-config.php and you are done!
define('FS_METHOD','direct');
If you continue to have errors, try to change the permissions for the wp-content and plugins folders: 

sudo chmod 777 Your_wordpress_root_folder/wp-content
sudo chmod 777 Your_wordpress_root_folder/wp-content/plugins
How do I configure a new Ubuntu Raspberry Pi installation to accept ssh connections?



Follow these commands and you are ready:

sudo apt-get update
sudo apt-get install openssh-server
sudo ufw allow 22
That's the very minimum. It allows unlimited failed password attempts on a known port. Direct root-login is disabled (you can still su and sudo once logged in).
You need to harden it from the standard setup. I suggest:
  • Key-based logins. Disable password logins.
  • Move it off port 22. Use something crazy-high, in the 20000-60000 range.
  • Use fail2ban to ban people who do find it and try to brute it.
Move the SSH server to another port

Open /etc/ssh/sshd_config as root user and change PORT 


sudo ufw allow PORT
sudo /etc/init.d/ssh restart
use raspberry user to remotely login

If SSH service not start automatically on boot, try just simply setting

sudo systemctl enable ssh
Bitnami virtual machine images contain a minimal Linux operating system and a fully configured Bitnami application stack, in my example i used a preconfigured virtual machine with WordPress 4.4.2-1 (64-bit). [Download here]

The default login information for WordPress cloud images is:

Username: user
Password: bitnami


  • Login with usename bitnami and password bitnami
  • Become root with the command sudo -i

Enabling SSH

The virtual machine by default comes with ssh turned off but you can easily enable it with the two following commands:

mv /etc/init/ssh.conf.back /etc/init/ssh.conf 
 
start ssh
 

Installing Midnight Commander

Use the apt-get command to update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages.
 
apt-get update

finally to install Midnight Commander use the command:
 
apt-get install mc

You can edit Wordpress files from this directory /opt/bitnami/apps/wordpress

Changing TTY keyboard layout

loadkeys es (Spanish, for example)
loadkeys pt (Portuguese, for example)
loadkeys br (Brazilian Portuguese, for example)

Changing Network Configuration

Opening the /etc/network/interfaces file will produce:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
Comment the previous 2 line with # and add your custom configuration with a static IP
iface eth0 inet static
    address 192.168.32.1 #the new static address
    netmask 255.255.255.0
    gateway 192.168.1.1 #your router
On Windows use IPCONFIG and you will get the values you need

Edit the /etc/network/interfaces file and when you are happy with your configuration restart the interface with the command below

ifdown eth0; ifup eth0
If you have the error message: Cannot find device "eth0" Failed to bring up eth0

The above error was solved by using the command: 

sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

sudo reboot
When you work to build a modern website based only on HTML5 and Javascript, you don't need complex configurations to verify how the end user will display the web site. A simple web server serving static files is the fastest and easiest solution, in this guide we will learn how to install Node.js and create a simple web server to use for our work. Node.js is a runtime environment for developing server-side web applications. In simple words, the Node.js platform makes it possible to run JavaScript programs on a server and also on your Raspberry Pi 2.



First of all, please run the following command in a shell or terminal

sudo apt-get update

Please wait! This command can be very slow, it downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies.

Remove a program with similar name to node.js (it creates conflicts, so better remove it)

sudo apt-get --purge remove node

To install Node.js run the commands

sudo apt-get install nodejs
sudo apt-get install npm

Nice job! You have sucessfully installed nodejs and npm in your Raspberry Pi 2. You can see the version currently being used by the shell by typing:

node -v

If nothing happens and you have the error  nodeNo such file or directory create a symlink with the command

sudo ln -s /usr/bin/nodejs /usr/sbin/node

Create a folder called /var/www/ and navigate to that folder, it will be our work directory.

sudo mkdir /var/www 
cd /var/www

We are ready to start coding! We will create a simple Webserver to host static website. Install the dependencies 

npm install --save compression connect http serve-static

Create a folder called httpdocs, this folder will cointain your HTML file, images and js code you want to host.

sudo mkdir /var/www/httpdocs

For example create a file index.html

Create in /var/www a file named server.js and put this code inside:

or you can download the file

wget https://gist.githubusercontent.com/orfeomorello/704f8639a5afcf50871f/raw/2ca571e41e9bc4c2fd12578293bdcd08eda51a34/server.js

If you followed all the steps, typing the ls command you can see this dicrectory structure

httpdocs node_modules server.js

To start the web server, execute the script with the command

node server.js

This will create a local webserver running on port 8181, if you write this web addess in your browser http://localhost:8181/index.html you will view your website running (remember to put your files in /var/www/httpdocs folder). To stop running the server press ctrl + c

Do you want to make available your website directly on the Internet? Follow this other tutorial
Most of you surely have a USB webcam that you used in the past and then thrown away in some corner because it has become old or because you changed your PC. Nowadays, most of the computer is supplied as a standard webcam and no longer needs to buy and to be connected externally. What to do with this old hardware? If you have a device Raspberry Pi, you can reuse your old webcam to build something useful again.


Turn on your Raspberry Pi, open a terminal window, connect the webcam into the USB port and enter the following command that will list all the USB devices that are being connected.

lsusb

you should see your camera listed as a usb device, for example

Bus 001 Device 006: ID 0c45:602c Microdia Clas Ohlson TWC-30XOP Webcam

if webcam is not in the list then you are not lucky, your webcam is not compatible with Raspberry Pi. If your Webcam is compatible, you can try to take some pictures to verify its functionality by installing fswebcam software.

sudo apt-get install fswebcam

Now run this command to capture a picture from the USB Webcam and save it as testimage.jpg

fswebcam testimage.jpg

You can run fswebcam with many switches, type the following command to have more options

man fswebcam

That is all! Your webcam setup is complete, but if you want experiment more with your webcam continue to read. Now we will install another very useful software to stream the video signal via web interface. The program name is "Motion" and you can read all the documentation here.

apt-get install motion

Now edit two configuration files

sudo nano /etc/default/motion

Change the following value from NO to YES

start_motion_daemon=no --> start_motion_daemon=yes

Press Ctrl+O to save and type Ctrl+X to exit.

sudo nano /etc/motion/motion.conf

This is quite a large conf file but the points you need to edit are:
daemon on
stream_localhost off
webcontrol_localhost off

############################################################
# Daemon
############################################################
# Start in daemon (background) mode and release terminal (default: off)
daemon on
############################################################

############################################################
# Live Stream Server
############################################################
# Restrict stream connections to localhost only (default: on)
stream_localhost off
##############################################################

############################################################
# HTTP Based Control
############################################################
# Restrict control connections to localhost only (default: on)
webcontrol_localhost off
#############################################################

Press Ctrl+O to save and type Ctrl+X to exit.

Then start the program by typing

sudo service motion start

sudo motion

To see if all is runnging type

sudo netstat -tulpn | grep LISTEN

Ports are showing as listening:
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN

Now get the local IP address of the Raspberry PI with command

ifconfig

On the second line of the resulting text, you find the IP address after "inet addr:" for example 192.168.1.6

Now visit the address http://YourIpAddress:8081 in your browser and you should get the Webcam stream. In my example i do http://192.168.1.6:8081 

You will see your Webcam stream into the browser from every pc in your LAN! 

Do you want to make available the display of your webcam directly on the Internet? Follow this tutorial.

Did you have trouble configuring the program files "motion"? Watch the video to get some help.