Category Archives: Linux Terminal

How to compress folders in the Terminal

If you want to make a zip without those invisible Mac resource files such as “_MACOSX” or “._Filename” and .ds store files, use the “-X” option in the command so:

zip -r -X archive_name.zip folder_to_compress

Exclude .DS_Store Files from Zip Archives

zip -r archive_name.zip folder_to_compress -x “*.DS_Store”

centOS Server Speed Test

wget wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
sudo mv speedtest.py /usr/local/bin/speedtest-cli
sudo chown root:root /usr/local/bin/speedtest-cli

speedtest-cli –share

Your system is missing the file /etc/fstab.

You may get the following warning when you try to install WHM into your server.

Your system is missing the file /etc/fstab. This is an essential system file that is part of the base system.
Please ensure the system has been properly installed.

Here are the solution.

#cat /proc/mounts > /etc/fstab
#chmod 644 /etc/fstab

SSH brute force protection

SSH Failed Login Attemps

You can see the last failed login attemps

tail -f /var/log/secure

To Change Port

Open sshd_config and change the port number.

service iptables stop

sudo vi /etc/ssh/sshd_config

service sshd restart

If you get an error about restarting sshd, please follow the steps.

yum -y install policycoreutils-python
semanage port -a -t ssh_port_t -p tcp PORT_NUMBER

How to clean log file

You need to clean log files (e.g /usr/local/apache/domlogs) with the following command.

> logfile

Don’t use rm command because it may cause writing problem.

If you wanna clean multiple files, you can use the following commnd.

truncate logfile --size 0

If you wanna clean all the log files, you can use the following command. We need to use *.* because the folders cause the error and break the command.

truncate *.* --size 0