How to add swap space on linux
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
After this edit /etc/fstab and add swap file to allow it on booting.
add:
/swapfile none swap sw 0 0
2025 on Tumblr: Trends That Defined the Year
Show & Tell

izzy's playlists!
I'd rather be in outer space 🛸
Jules of Nature
"I'm Dorothy Gale from Kansas"

❣ Chile in a Photography ❣
Cosimo Galluzzi
Sweet Seals For You, Always
Mike Driver

pixel skylines

祝日 / Permanent Vacation
No title available
Not today Justin
Claire Keane
h

titsay

Origami Around
Sade Olutola
hello vonnie
seen from Chile
seen from India
seen from United States
seen from Pakistan

seen from United States

seen from United States

seen from United States

seen from United States
seen from United States
seen from United States

seen from United States

seen from United States

seen from Singapore
seen from Türkiye

seen from Türkiye
seen from United States

seen from Türkiye

seen from Malaysia

seen from United States
seen from United States
@ikitaez
How to add swap space on linux
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
After this edit /etc/fstab and add swap file to allow it on booting.
add:
/swapfile none swap sw 0 0
How to replace dead hdd in software raid with mdadm
Lets say you have RAID1 array created with mdadm and you want to replace disk sdb with new one.
To view raid devices:
cat /prod/mdstat
Then remove associated partitions with md devices:
mdadm /dev/md0 --remove /dev/sdb2 mdadm /dev/md1 --remove /dev/sdb3
If it gives error that it cant be removed, then before removing make them failed:
mdadm /dev/md0 -f /dev/sdb2 mdadm /dev/md1 -f /dev/sdb3
Then insert new disk and copy partitions from working disk sda to new disk sdb:
sfdisk -d /dev/sda | sfdisk /dev/sdb
Then add new drive to arrays:
mdadm /dev/md0 --add /dev/sdb2 mdadm /dev/md1 --add /dev/sdb3
And finally install grub to new disk:
grub-install /dev/sdb
How to check ssl certificate matches private key
To check certificate type:
openssl x509 -noout -modulus -in cert.crt | openssl md5
To check key:
openssl rsa -noout -modulus -in cert.key | openssl md5
If md5 sum of both commands will be same, then cert and key matches.
How to login to remote server with ssh key
On your server run:
ssh-keygen -t rsa
You will be asked for key location and password, just leave them empty and then keys will be created in home directory of your user, for exmaple:
/root/.ssh
Then we need to copy public key to remote server:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server
Replace user with user on remote side and server with server address. You will be asked for password of remote server, fill it.
After this you can connect to remote server with command:
ssh user@server
Plesk mysql governor error
If you see in /var/log/messages such errors:
Apr 14 01:53:37 service-1 systemd: Starting MySQL watcher service...
Apr 14 01:53:37 service-1 systemd: Started MySQL watcher service.
Apr 14 01:53:37 service-1 mysqld: 2022-04-14 1:53:37 140260687537920 [Warning] Access denied for user 'admin'@'localhost' (using password: YES)
Apr 14 01:53:37 service-1 mysqld: 2022-04-14 1:53:37 140260688766720 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Apr 14 01:53:37 service-1 mysqld: 2022-04-14 1:53:37 140260685080320 [Warning] Access denied for user 'root'@'localhost' (using password: NO)
Apr 14 01:53:37 service-1 systemd: db_governor.service: main process exited, code=exited, status=1/FAILURE
Apr 14 01:53:37 service-1 systemd: Unit db_governor.service entered failed state.
Apr 14 01:53:37 service-1 systemd: db_governor.service failed.
Apr 14 01:53:40 service-1 systemd: db_governor.service holdoff time over, scheduling restart.
Apr 14 01:53:40 service-1 systemd: Stopped MySQL watcher service.
Then you have incorrect password of mysql admin user in db governer config. To fix it:
nano /etc/container/mysql-governor.xml
Look for section:
<connector login="admin" password="
There will be encoded password started with $AES
Now we need to get actual password, to do it run:
cat /etc/psa/.psa.shadow
You will see working password in same encoded format, now replace old password in config with working one from .psa.shadow . Save file and exit. DB governor will be auto reconnected.
How to restart VMware services
To restart VMware services on host, run this command:
/sbin/services.sh restart
It can be helpful to apply changes after changing SSL certificate on host.
How to get Lets Encrypt SSL certificate
First of all you need to install certbot utility. If you have any webserver runned you must stop it.
Then use command:
certbot certonly -d yourdommain.net
Answer the questions, on How would you like to authenticate with the ACME CA? step choose number 1
If everything goes well you will find cert and key in following dirs:
Cert: /etc/letsencrypt/live/yourdomain.net/fullchain.pem Key: /etc/letsencrypt/live/yourdomain.net/privkey.pem
Now you can configure your webserver with it.
How to find and replace text in all files
If you want to replace text in current directory and all it's subdirectories then use this:
find . -type f -name "*.txt" -exec sed -i 's/foo/bar/g' {} \;
This will change foo to bar in all txt files.
How to find files changed between two dates
If you need to find all files that was changed in system between two dates, for example 28 March 2020 and 30 March 2020 then use command below:
find / -type f -newermt "2020-03-28" ! -newermt "2020-03-30" -ls
How to change default editor in Linux
For example, you want to edit cron jobs, and after typing crontab -e you see that vi was opened. You can change it to nano. To do it, type:
export EDITOR='nano'
mysql table import from dump
Imagine that you have mysql dump of database (testdb.sql) and you want to restore only one table (mytable). Then do this:
sed -n -e '/DROP TABLE.*mytable/,/UNLOCK TABLES/p' testdb.sql > testdb_mytable.sql
This command will create file testdb_mytable.sql with data only for this table. Then you can import it:
mysql -uUser -p testdb < testdb_mytable.sql
Cisco Catalyst port mirror
To configure port mirror do this:
conf t
monitor session 1 source interface fa0/1
monitor session 1 destination interface fa0/10
Where fa0/1 is port we want to mirror and fa0/10 is destination port. This will work for Catalyst 2940, 2955, 2960, 2970, 3550, 3560, 3560-E, 3750 and 3750-E.
For Catalyst 2900XL/3500XL series use this:
conf t
int fa0/10
port monitor fa0/1
Where fa0/10 is destination port we will mirror traffic for, and fa0/1 is source port.
How to create partition in Linux for 2TB drive and bigger
parted /dev/sdb
mkpart primary 2048s 100%
q
mkfs.ext4 /dev/sdb1
How to install iptables service in CentOS
By default CentOS uses firewalld service to control firewall rules. If you want to configure firewall with just iptables rules, you need to do following
Disable everything of firewalld
systemctl stop firewalld.service
systemctl disable firewalld.service
Install iptables-service
yum install iptables-services
Enable and start service
systemctl enable iptables.service
systemctl start iptables.service
Now you can write rules in console and after you done type:
iptables-save
Rules will be saved and loaded after reboot.
How to allow SSH access only to your IP
iptables -A INPUT -p tcp -s your_ip_here --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -s another_your_ip_here --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j DROP
How to remove disk in CentOS
Make device offline
echo "offline" > /sys/block/sda/device/state
Delete disk
echo "1" > /sys/block/sda/device/delete
Where sda is your drive device.
How to update FreeBSD 10.2 to 10.3
freebsd-update -r 10.3-RELEASE upgrade
And follow instructions on console.