How to install Midnight Commander (MC) on Ubuntu 18.04

Once after installing Ubuntu Server 18.04, when trying to install Midnight Commander, a message was displayed that the package for installation was not found.

To solve the problem, you need to add the Universe repository:
Continue reading “How to install Midnight Commander (MC) on Ubuntu 18.04”

Speed limit on network interface using TC

I will give an example of a speed limit of up to 3.3 Gb/s on a network interface on Ubuntu Server 16.04:

/sbin/tc qdisc del dev ens2f0 parent ffff:
/sbin/tc qdisc add dev ens2f0 handle ffff: ingress
/sbin/tc filter add dev ens2f0 parent ffff: protocol ip prio 50 u32 match ip dst 0.0.0.0/0 police rate 3300mbit burst 330k mtu 30000 drop flowid 1:0

Continue reading “Speed limit on network interface using TC”

BGP. Channel Balancing on Quagga

I will give an example of balancing only incoming traffic with two channels using Quagga.

On the test, I will use Ubuntu 16.04.4 LTS and Quagga 0.99.24.1, the network interface ens1f0 for the second provider with one neighbors and ens2f0 for the first provider with two neighbors, the local network will be connected to ens2f1. Both providers announce “default”.
3.3.3.0/23 this will be my network with white IP addresses.
Continue reading “BGP. Channel Balancing on Quagga”

Directories with a large number of files

Once there was an interesting situation, in the same directory there were millions of files.
And some of them are necessary.

When you try to view the list of files, you will naturally get a stupor for a long time.
Alternatively, they can be viewed via FTP, which has 10,000 for the frequent standard limit on the number of displayed files, for example, the FileZilla FTP client conveniently moves files in directories, but this option is long, because time is spent on FTP requests, the load on the drive is low.

If the files are not needed, you can delete them with the command (with the confirmation request to delete)

rm -r /dir/

Or delete everything without a request along with the directory:

rm -rf /dir/

In my case, small files were unnecessary, so going to the right directory, deleted the command below with anything that is smaller than the specified size:

cd /dir/
find -size -2 -type f -print -delete

Before deleting, you can see the number of such files and the total number, but this is also a lengthy process:

find -maxdepth 1 -size -2 -type f -print | wc -l
find -maxdepth 1 -type f -print | wc -l

If, instead of -2, you specify 0, then files with zero size will be deleted, that is, empty.

If you need to sort the files by directories, go to the directory with files, create the necessary directories, for example, by dates and move the files by template (all whose names begin on 2017, -maxdepth 1 indicates that you do not need to search for files in subdirectories):

cd /dir/
mkdir 2017
find -maxdepth 1 -type f -name '2017*' -exec mv -vn -t /dir/2017 {} \+

The result of the execution can be written to the file by adding to the command “> file”, for example:

find -maxdepth 1 -type f -name '2017*' -exec mv -vn -t /dir/2017 {} \+ > /dir/dir/file.log

Blocking social networks using iptables

Once on one of the NAT servers I needed to block some sites.

If the sites are located on several IP addresses, then you need to find out these ranges of IP addresses, for example, look for VKontakte on bgp.he.net, for example, a list of subnets for one of the AS belonging to VK “http://bgp.he.net/AS47541#_prefixes”.

When networks or hosts are known, add rules for them in iptables, for example:

/sbin/iptables -A FORWARD -s 87.240.128.0/18 -j DROP
/sbin/iptables -A FORWARD -s 95.142.192.0/20 -j DROP

Thus, we prohibit the passage of the traffic of these networks through the server.

See also my articles:
Blocking social networks on Cisco
Blocking social networks on Mikrotik routers

NetData installation

NetData – monitoring system that displays real-time statistics on web panels.

On the test, I will install NetData on Ubuntu 18.04 and Ubuntu 16.04.
Before installing, you can upgrade the system:

sudo apt-get update
sudo apt-get upgrade

If Ubuntu version is 18.04 and newer, then NetData is installed with the command:

sudo apt-get install netdata

After installation, the configuration will be in /etc/netdata/, the logs in /var/log/netdata/.

On Ubuntu 16.04 and older, you can install as follows (the installation will be done in /opt/netdata/):

sudo bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh)

Restart NetData can command:

sudo systemctl restart netdata

View status:

sudo systemctl status netdata
sudo ps ax | grep netdata

After installing NetData, you can immediately open it in the browser http://HOST:19999
I recommend to immediately restrict access to the tcp port 19999, for example through iptables.