cw (change word) changer le mot
dw (delete word) supprimer le mot
c4w changer 4mots
/ rechercher un mot sur la page
dd supprimer une ligne
6dd supprimer 6 lignes
o creer une nouvelle ligne
G aller en bas de page
yy puis c copier la ligne et l'inserer en dessous
:s/foo/bar/g Change each 'foo' to 'bar' in the current line.
:%s/foo/bar/g Change each 'foo' to 'bar' in all the lines.
Disque amont
$ df -h
Show number of processes
$ nproc number of process on the machine
$ free state of memory
$ free -h state of memory Human read
$ lscpu ls proc human read
$ /proc/cpuinfo info on every proc
$ /proc/meminfo info on memory
$ less /proc/cpuinfo info on every proc
$ less /proc/meminfo info on memory
List all valid IP addresses in a local network
dnf install nmap (if not installed)
nmap -sn 192.168.1.0/24 or nmap -sP 192.168.1.*
Global bash for all users
cd /etc/profile.d
touch CHOOSE_NAME_YOU_WANT.sh
put your aliasses in CHOOSE_NAME_YOU_WANT.sh
run: source /etc/profile
send file to external server with scp
scp fileToSend user_name@server_ip:~/targetFolder/|renameFile
get file from external server with scp
scp user_name@server_ip:~/targetFolder/fileToGet
Afficher les machines dans un réseau
$ arp -a | -n | -v | -nv| -e
Tester les ip sur internet
test-ipv6.com verifier l'état du ipv6
api.ipify.org ipv6 et ipv4
extend import file size in phpMyAdmin
go to mamp/bin/php.x.x./conf/php.ini
memory_limit = 256M
post_max_size = 500M
upload_max_filesize = 500M
Error: Can't connect to local mySQL server through socket /tmp/mysql.sock
run: ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
reboot mySQL
Error message in MySQL goes like this: “ERROR 1136 (21S01): Column count doesn’t match value count at row 1“.
This error typically occurs when you’re trying to insert data into a table, but the number of columns that you’re trying to insert don’t match the number of columns in the table.
SELECT table_schema, table_name, index_name, column_name
information_schema.statistics
Select all foreign key of database
select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where CONSTRAINT_TYPE = 'FOREIGN KEY'
Error: gyp: No Xcode or CLT version detected macOS Big Sur
sudo xcode-select -r
Reboot when power is re-applied after a power failure (mini-pc acepc)
on reboot press F2
go to Boot
go to State After G3
set Power On
Save & exit
Network configuration for static IP
$ cd /etc/sysconfig/network-scripts/
$ vim ifcfg-interface-Name
config or add:
BOOTPROTO=static
IPV6INIT=no
del: IPV6_AUTOCONF=yes, IPV6_DEFROUTE=yes if IPV6INIT=no
IPADDR=198.168.1.100(ex: your static ip addr)
NETMASK=255.255.255.0(according to your network)
GATEWAY=192.169.1.1((according to your network)
HOSTNAME=(name you want to give the machin)
NM_CONTROLLED=no
$ sudo systemctl restart NetworkManager.service
Change hostname
$ sudo hostnamectl set-hostname 'NEW NAME'
$ hostnamectl (to verifie the new change )
clean cache
dnf clean all
rm -rf /var/cache/yum/*
Error: semanage : commande introuvable
$ sudo dnf provides /usr/sbin/semanage
$ sudo dnf install policycoreutils-python-utils
Linux : Ajouter un nouveau utilisateur
login as adm
adduser user_name<
passwd user_name
visudo or vim /etc/sudoers
user_name ALL=(ALL) ALL
userdel user_name
Install Mysql on centos8 && almalinux
$ sudo dnf update
$ sudo dnf install mysql mysql-server (almalinux 9) and go to 5.
$ sudo dnf module list mysql
$ sudo dnf module enable mysql:8.0
$ sudo dnf install @mysql
$ sudo systemctl enable mysqld
$ sudo systemctl start mysqld
$ sudo systemctl status mysqld
$ sudo mysql_secure_installation (securisation)
$ mysqladmin -u root -p version (test mysql)
$ mysql -u root -p (connexion)
Manage Mysql on centos8
$ mysql -u root -p (connect as root)
CREATE DATABASE IF NOT EXISTS database_name;
SHOW DATABASES;
CREATE USER IF NOT EXISTS 'database_user'@'localhost' IDENTIFIED BY 'user_password'; (add user with password )
GRANT ALL PRIVILEGES ON database_name.* TO 'database_user'@'localhost';
- DROP USER IF EXISTS 'database_user'@'localhost'; (delete user)
- GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost';(grant for all database)
- SELECT user, host FROM mysql.user; (list all user account)
- DROP USER IF EXISTS 'database_user'@'localhost';(delete user account)
- SHOW GRANTS FOR 'database_user'@'localhost';(display user privilèges account)
- ALTER USER 'database_user'@'localhost' IDENTIFIED BY 'new_password';(change user password)
Initial Server Setup (Setting Up a Basic Firewall)
sudo dnf install firewalld -y
sudo systemctl start firewalld
sudo systemctl status firewalld
sudo firewall-cmd --permanent --list-all
sudo firewall-cmd --get-services
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
Install Httpd (apache) on centos8 & co
sudo dnf install httpd
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo systemctl start httpd
sudo systemctl status httpd
hostname -I ( to get IP ADDR if don't know)
http://your_server_ip ( to test if evething is ok at this point)
Error : httpd: Could not reliably determine the server's fully qualified domain name, using...
Update /etc/hosts and do server’s ip address resolvable to the fully qualified domain name(fqdn) or hostname.
$ vim /etc/hosts
change server’s ip address
$ systemctl restart httpd
Setting Up Virtual Hosts
sudo mkdir -p /home/stingers/NAME/;
sudo mkdir -p /home/stingers/NAME/log;
sudo mkdir -p /home/stingers/NAME/api;
sudo mkdir -p /home/stingers/NAME/html;
sudo chown -R apache:apache /home/stingers/NAME/;
sudo chmod -R 755 /home/stingers/
sudo vim /home/stingers/NAME/html/index.html
sudo mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
sudo vim /etc/httpd/conf/httpd.conf
press G > i ( insert mode) and add IncludeOptional sites-enabled/*.conf
sudo vim /etc/httpd/sites-available/NAME.conf; (config VirtualHost);
sudo ln -s /etc/httpd/sites-available/NAME.conf /etc/httpd/sites-enabled/NAME.conf;
Adjusting SELinux Permissions for Virtual Hosts
sudo setsebool -P httpd_unified 1;
sudo ls -dlZ /home/stingers/NAME/log/;
sudo semanage fcontext -a -t httpd_log_t "/home/stingers/NAME/log(/.*)?";
sudo restorecon -R -v /home/stingers/NAME/log;
sudo ls -dlZ /home/stingers/NAME/log/;
Testing the Virtual Host
sudo systemctl restart httpd;
ls -lZ /home/stingers/NAME/log/
Forbidden – You don’t have permission to access / on this server” Error
getenforce if output: Enforcing
sudo vim /etc/selinux/config
set: SELINUX=disabled
sudo reboot (to reboot the system)
How To Secure Apache with Let's Encrypt on CentOS 8
sudo dnf install epel-release
sudo dnf install certbot python3-certbot-apache mod_ssl
sudo certbot --apache
sudo certbot renew --dry-run;
echo "0 0,12 * * * root python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null;
AH00526: Syntax error on line 5 of /etc/httpd/conf.d/ssl.conf:
Cannot define multiple Listeners on the same IP:port
solution : comment listen: 443 in /etc/httpd/conf.d/ssl.conf file
util global modules
sudo npm i -g depcheck; run: depcheck (analyze the dependencies in a project to see: how is used or useless)
sudo npm i -g npm-check-updates ; run: ncu (checks npm modules updates)
install eslint in project
npm i eslint --save-dev;
npm init @eslint/config;
npx eslint ./ (optional : check problems in current directory)
npx eslint ./ --fix (optional : fix problems in current directory)
Process Management
sudo npm install pm2@latest -g
pm2 ecosystem
pm2 save
pm2 [list|ls|status]
pm2 logs
ecosystem config
module.exports = {
apps : [{
name: 'okai',
script: 'dist/index.js',
exec_mode : 'cluster',
autorestart: true,
watch: ['dist/**/*.js'],
ignore_watch : ["node_modules/**/*"]
}]
};