Here are a few useful commands to use during Linux administration of your Splynx server.
sudo sh -c 'apt update && apt dist-upgrade -y && apt autoclean && apt autoremove'
On Ubuntu 20.04, most of the system logs are written to the /var/log/syslog
file.
You can try using dmesg
utility to find hardware issues with your server:
sudo dmesg -T | grep -i err
You can find logs on server authorization attemtps in /var/log/auth.log
.
Show info full CPU specifications:
sudo lscpu
Display 10 largest processes by CPU utilization with ps
:
sudo ps aux --sort -%cpu | head -10
You can also use top
or htop
utilities to check CPU utilization per process & free memory:
sudo htop
To check disk usage on Linux, you can use the df
command:
sudo df -h -t ext4
You can find list of each directory sorted by size in the specific path with du
command:
# List directories size under root of the filesystem:
sudo du -hs /* | sort -n -r
# List largest Splynx directories:
sudo du -hs /var/www/splynx/* | sort -n -r
Alternatively, the following command can be used to install the NCurses Disk Usage package that provides user-friendly CLI interface to check for disk usage:
sudo apt install ncdu
To launch the utility use ncdu
command.
To display RAM & Swap utilization info on the Linux server using free
utility:
free -h
Display 10 largest processes by RAM utilization with ps
:
sudo ps aux --sort -%mem | head -10
sudo sh -c "fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile && swapon --show"
sudo cp /etc/fstab /etc/fstab.backup
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
if [[ ! -f /swapfile ]]; then
echo "Building swapfile..."
dd if=/dev/zero of=/swapfile bs=64M count=32
mkswap /swapfile
chmod 0600 /swapfile
swapon /swapfile
# Mount on reboot
if [[ -z "$(cat /etc/fstab | grep swapfile)" ]]; then
echo "/swapfile none swap sw 0 0" | tee -a /etc/fstab > /dev/null 2>&1
fi
fi
This will create a 2 GB file, if you need more or less, please change bs=64M count=32 - 32 to 16 for 1 GB, 64 for 4 GB.
sudo sh -c 'swapoff /swap.img && rm /swap.img'
To check server uptime use uptime
command.
You can check time with timedatectl
and date
commands.
Time zone of your server can be changed with the following command:
sudo dpkg-reconfigure tzdata
On Ubuntu 20.04 you can change NTP server via by editing the /etc/systemd/timesyncd.conf
file.
Edit the file and set desired NTP server address after NTP=
as displayed below:
[Time]
NTP=ntp.hetzner.com
Afterwards, restart timesyncd service for settings to take effect:
sudo systemctl restart systemd-timesyncd
You can check NTP client connection status with the following command:
sudo timedatectl timesync-status