Linux commands
On centOs 6
#rsync –daemon —> to start rsyncd
# chkconfig rsync on —> to enable service
and add /usr/bin/rsync –daemon in vi /etc/rc.local
# chkconfig –list —> to list services
Check os version in Linux
Check os version in Linux
cat /etc/os-release
lsb_release -a
To delete file simply rm filename with extension
Delete everything. The rm command has a powerful option, -R (or -r ), otherwise known
as the recursive option. When you run the rm -R command on a folder, you’re telling
Terminal to delete that folder, any files it contains, any sub-folders it contains, and any
files or folders in those sub-folders, all the way down.
-f means force
Extract file
Tar -zxvf filename
File format Command to extract
.tar.gz tar zxf
.zip unzip
.tar.bz2 tar jxf
Php version check php -v
To got to / directory
Cd /
To uninstall full php
yum remove php-Or to remove everything and start new installation yum remove php* yum remove –setopt=clean_requirements_on_remove= 1 php php-pear php-mysql php-cli php-common mod-php Well, after this problem I’ve stuck in a few days, then today I found the question. First thing remove php71 from system, yum remove php-common php-cli mod-php enable remi-php70 yum-config-manager –enable remi-php70 after that disabled the 7.1 yum-config-manager –disable remi-php71 then do yum update then install php 7.0.x yum -y install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-mcrypt php70u-gd php70u-devel php70u-mysql php70u-intl php70u-mbstring php70u-bcmath php70u-json php70u-iconv php70u-soap To install php yum install -y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-re lease-1.0-14.ius.centos7.noarch.rpm yum -y update To install php extension or full php yum install php-
https://linuxize.com/post/install-php-7-on-centos-7/TO CHECK ALL PHP VERSIONS INSTALLED ON CENTOS
yum list installed | grep php
To move all files from one folder to another one
mv /home/Downloads/* /home/hostingguru/public_html
It will move all the files including subfolders in the directory you want to mv . If you want to cp
(copy) or rm (remove) you will need the -r (recursive) option to include subfolders.
If you want to kill a process running as a different user, you can use sudo :
sudo killall firefox
Shell command to monitor changes in a file
tail -f logfile.log
To clean folder
rm -rfv *
rm -rfv .*
To search for a specific keyword in all files and folders
grep -irl “search_key”magento cache check
php bin/magento cache:status
Current status:
config: 1
layout: 1
block_html: 1
collections: 1
reflection: 1
db_ddl: 1
eav: 1
customer_notification: 1
amasty_shopby: 1
config_integration: 1
config_integration_api: 1
full_page: 0
config_webservice: 1
translate: 1
[readersin@server public_html]
$ php bin/magento cache:enable
Changed cache status:
full_page: 0 -> 1
Cleaned cache types:
full_page
[readersin@server public_html]
$ php bin/magento cache:status
Current status:
config: 1
layout: 1block_html: 1
collections: 1
reflection: 1
db_ddl: 1
eav: 1
customer_notification: 1
amasty_shopby: 1
config_integration: 1
config_integration_api: 1
full_page: 1
config_webservice: 1
translate: 1
[readersin@server public_html]
$
How to enable cdn url in magneto
Create cdn.examplehost.in in cloud flare
And use this in backend URL
Please configure the relevant cache.
We are not receiving emails of the customer order notification, can you please check the issue.
We need to configure the CDN URLs in the admin panel, can you please suggest which URL
needs to be used?
To create admin user and passwor dchange using CLI
ea-php70 /bin/magento2-cli adminMerging in magento CLI
ea-php70 /bin/magento2-cli conf:sto:get ‘%merge%’
ea-php70 /bin/magento2-cli conf:sto:get ‘%bundling%’
ea-php70 /bin/magento2-cli conf:sto:get ‘%minify%’
How to Find a Specific String or Word in Files and Directories
lsb_release -a
To delete file simply rm filename with extension
Delete everything. The rm command has a powerful option, -R (or -r ), otherwise known
as the recursive option. When you run the rm -R command on a folder, you’re telling
Terminal to delete that folder, any files it contains, any sub-folders it contains, and any
files or folders in those sub-folders, all the way down.
-f means force
Extract file
Tar -zxvf filename
File format Command to extract
.tar.gz tar zxf
.zip unzip
.tar.bz2 tar jxf
Php version check php -v
To got to / directory
Cd /
To uninstall full php
yum remove php-Or to remove everything and start new installation yum remove php* yum remove –setopt=clean_requirements_on_remove= 1 php php-pear php-mysql php-cli php-common mod-php Well, after this problem I’ve stuck in a few days, then today I found the question. First thing remove php71 from system, yum remove php-common php-cli mod-php enable remi-php70 yum-config-manager –enable remi-php70 after that disabled the 7.1 yum-config-manager –disable remi-php71 then do yum update then install php 7.0.x yum -y install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-mcrypt php70u-gd php70u-devel php70u-mysql php70u-intl php70u-mbstring php70u-bcmath php70u-json php70u-iconv php70u-soap To install php yum install -y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-re lease-1.0-14.ius.centos7.noarch.rpm yum -y update To install php extension or full php yum install php-
https://linuxize.com/post/install-php-7-on-centos-7/TO CHECK ALL PHP VERSIONS INSTALLED ON CENTOS
yum list installed | grep php
To move all files from one folder to another one
mv /home/Downloads/* /home/hostingguru/public_html
It will move all the files including subfolders in the directory you want to mv . If you want to cp
(copy) or rm (remove) you will need the -r (recursive) option to include subfolders.
If you want to kill a process running as a different user, you can use sudo :
sudo killall firefox
Shell command to monitor changes in a file
tail -f logfile.log
To clean folder
rm -rfv *
rm -rfv .*
To search for a specific keyword in all files and folders
grep -irl “search_key”magento cache check
php bin/magento cache:status
Current status:
config: 1
layout: 1
block_html: 1
collections: 1
reflection: 1
db_ddl: 1
eav: 1
customer_notification: 1
amasty_shopby: 1
config_integration: 1
config_integration_api: 1
full_page: 0
config_webservice: 1
translate: 1
[readersin@server public_html]
$ php bin/magento cache:enable
Changed cache status:
full_page: 0 -> 1
Cleaned cache types:
full_page
[readersin@server public_html]
$ php bin/magento cache:status
Current status:
config: 1
layout: 1block_html: 1
collections: 1
reflection: 1
db_ddl: 1
eav: 1
customer_notification: 1
amasty_shopby: 1
config_integration: 1
config_integration_api: 1
full_page: 1
config_webservice: 1
translate: 1
[readersin@server public_html]
$
How to enable cdn url in magneto
Create cdn.examplehost.in in cloud flare
And use this in backend URL
Please configure the relevant cache.
We are not receiving emails of the customer order notification, can you please check the issue.
We need to configure the CDN URLs in the admin panel, can you please suggest which URL
needs to be used?
To create admin user and passwor dchange using CLI
ea-php70 /bin/magento2-cli adminMerging in magento CLI
ea-php70 /bin/magento2-cli conf:sto:get ‘%merge%’
ea-php70 /bin/magento2-cli conf:sto:get ‘%bundling%’
ea-php70 /bin/magento2-cli conf:sto:get ‘%minify%’
How to Find a Specific String or Word in Files and Directories
grep -Rw folder/ -e ‘search_term’
grep “search_term” * -R
For some image formats you can just use the
file
command:$ file MyPNG.png
MyPNG.png: PNG image, 681 x 345, 8-bit/color RGB, non-interlaced
MYSQL Temporary password change
grep 'temporary password' /var/log/mysqld.log
to change the password login to my sql using the temp passwd
and then use below command
ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD';
Change the current timezone in CentOS 7
1.First search for the available time zone by the below command.
timedatectl list-timezones | grep -i Asia
2. Then unlink the current timezone
sudo unlink /etc/localtime
3.Now set the new timezone. The syntax for setting the new time zone is as below
sudo ln -s /usr/share/zoneinfo/[zone/timezone] /etc/localtime
For example
sudo ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
4. Now check the DateTime using date command.
date
Tue May 28 10:52:00 IST 2019
How to view MySQL server time zone
mysql -e “SELECT @@global.time_zone;”
By default you should get back something similar to:
+--------------------+ | @@global.time_zone | +--------------------+ | SYSTEM | +--------------------+
This is because by default your MySQL time zone will be set to the server’s default SYSTEM time.Clear History
for root user go to cd /
then go to cd /root
then
vi .bash_history
for any other user go to cd /home/username/.bash_history
for deleting specific history type history -d number
view the contents of tar.gz file without extracting from the command-line
tar -tf filename.tar.gz
============================================================================
tar -tf filename.tar.gz
============================================================================
Example: Extend an XFS file system
Use the df -h command to verify the size of the file system for each volume. In this example, each file system reflects the original volume size, 8 GB.
[ec2-user ~]$
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p1 8.0G 1.6G 6.5G 20% /
/dev/nvme1n1 8.0G 33M 8.0G 1% /data
...
To extend the XFS file system, install the XFS tools as follows, if they are not already installed.
[ec2-user ~]$
sudo yum install xfsprogs
Use the xfs_growfs command to extend the file system on each volume. In this example,
/
and /data
are the volume mount points shown in the output for df -h.
[ec2-user ~]$
sudo xfs_growfs -d /
[ec2-user ~]$
sudo xfs_growfs -d /data
You can verify that each file system reflects the increased volume size by using the df -h command again.
[ec2-user ~]$
df -h
Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p1 16G 1.6G 15G 10% / /dev/nvme1n1 30G 33M 30G 1% /data
***********************************************************
Extending the File System
Use a file system-specific command to resize each file system to the new volume capacity. For a file system other than the examples shown here, refer to the documentation for the file system for instructions.
Example: Extend an ext2, ext3, or ext4 file system
Use the df -h command to verify the size of the file system for each volume. In this example, both
/dev/xvda1
and /dev/xvdf
reflect the original size of the volumes, 8 GB.
[ec2-user ~]$
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 8.0G 1.9G 6.2G 24% /
/dev/xvdf1 8.0G 45M 8.0G 1% /data
...
Use the resize2fs command to extend the file system on each volume.
[ec2-user ~]$
sudo resize2fs /dev/xvda1
[ec2-user ~]$
sudo resize2fs /dev/xvdf1
You can verify that each file system reflects the increased volume size by using the df -h command again.
[ec2-user ~]$
df -h
Filesystem Size Used Avail Use% Mounted on /dev/xvda1 16G 1.9G 6.2G 12% / /dev/xvdf1 30G 45M 8.0G 1% /data ...
=====================================================================
where is php.ini
/usr/local/bin/php –ini | grep ‘Loaded Configuration File’
check a record with single nslookup
dig mail.pesb.co.in @ns.dinpl.com
Q> To check the last 3 days modified files
# find -type f -mtime -3
========================
1. To check number of http connections
# netstat -at | grep http | wc -l
—————————–
1.To check connections for bandwidth:
——-
ss -o state established
——-
2.To check HTTP connections:
——–
netstat -anp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
——–
3.To check Mysql connections:
——–
netstat -anp | grep :3306 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
——–
4.To check mail queue count:
———-
exim -bpc
———-
5.To check mail queue:
——–
exim -bp
——–
6.To run mail queue forcefully:
———-
exim -qf &
———-
7.To bounce 10 hours mails:
———
exiqgrep -o 36000 -i | xargs exim -Mg
——–
8.to delete FROZEN mails:
——–
exiqgrep -z -i | xargs exim -Mrm
——–
9.To restart SNMP service:
———
———
10.For HTTP service:
———
/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd status
/etc/init.d/httpd restart
———
11.For Mysql service:
———
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
———
12.To know version of postfix:
———
postconf -d | grep mail_version
———
13.To know apache version :
——–
apachectl -v
*OR/AND*
/usr/sbin/httpd -v
——–
14.TO check connections established in network for bandwidth:
———
ss -o state established
———
15.To restart exim
———–
/scripts/restarsrv_exim
———–
15.To kill service
ps -aux | grep httpd—–> services (FTP,Sql,User)
kill -9 pid
16.to check kernel version
———-
uname -r
*)sample output:2.6.32-23-generic-pae
OR
uname -mrs
*)sample o/p:Linux 2.6.32-23-generic-pae i686
To print all information about linux system:
uname -a
# find -type f -mtime -3
========================
1. To check number of http connections
# netstat -at | grep http | wc -l
—————————–
1.To check connections for bandwidth:
——-
ss -o state established
——-
2.To check HTTP connections:
——–
netstat -anp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
——–
3.To check Mysql connections:
——–
netstat -anp | grep :3306 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
——–
4.To check mail queue count:
———-
exim -bpc
———-
5.To check mail queue:
——–
exim -bp
——–
6.To run mail queue forcefully:
———-
exim -qf &
———-
7.To bounce 10 hours mails:
———
exiqgrep -o 36000 -i | xargs exim -Mg
——–
8.to delete FROZEN mails:
——–
exiqgrep -z -i | xargs exim -Mrm
——–
9.To restart SNMP service:
———
———
10.For HTTP service:
———
/etc/init.d/httpd start
/etc/init.d/httpd stop
/etc/init.d/httpd status
/etc/init.d/httpd restart
———
11.For Mysql service:
———
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
———
12.To know version of postfix:
———
postconf -d | grep mail_version
———
13.To know apache version :
——–
apachectl -v
*OR/AND*
/usr/sbin/httpd -v
——–
14.TO check connections established in network for bandwidth:
———
ss -o state established
———
15.To restart exim
———–
/scripts/restarsrv_exim
———–
15.To kill service
ps -aux | grep httpd—–> services (FTP,Sql,User)
kill -9 pid
16.to check kernel version
———-
uname -r
*)sample output:2.6.32-23-generic-pae
OR
uname -mrs
*)sample o/p:Linux 2.6.32-23-generic-pae i686
To print all information about linux system:
uname -a
For attack
top -c
check username
for live connection (from remote server or pc to your server or machine)
ss -o state established
ls -ltr