Top 10 Linux Commands Every User Should Know
- Search Single String in All Files
grep -r -l ""
In this example command will search string “changeWfApprovalStatus” in all files in cd /opt/lampstack/apache2/htdocs/test/ directory and its sub-directories.
[vivek@Learncodezone ~]$ cd /opt/lampstack/apache2/htdocs/test/
[vivek@Learncodezone test]$ grep -r -l "changeWfApprovalStatus"
popups.php
origin/Purchase/Dir/RestApi/PurchaseActionManager.php
origin/Objective/Dir/RestApi/ObjectiveActionManager.php
origin/SContracts/Dir/RestApi/SContractsActionManager.php
origin/ProjGov/Dir/RestApi/ProjGovActionManager.php
origin/SA/Dir/RestApi/SAActionManager.php
origin/CP/Dir/RestApi/CPActionManager.php
origin/Expenses/Dir/RestApi/ExpensesActionManager.php
origin/OI/Dir/RestApi/OIActionManager.php
origin/MMove/Dir/RestApi/MMoveActionManager.php
origin/Facility/Dir/RestApi/FacilityActionManager.php
origin/Shipment/Dir/RestApi/ShipmentActionManager.php
origin/P2P/Dir/RestApi/P2PActionManager.php
2. Restart Apache and Mysql Server
./ctlscript.sh restart
If you are using Bitnami in centos then this code will work for restart your server .
Last login: Sat May 22 17:01:56 2021 from 202.142.115.108
[root@amtekgroup ~]# cd /opt/lampstack/
[root@amtekgroup lampstack]# ./ctlscript.sh restart
Syntax OK
/opt/lampstack/apache2/scripts/ctl.sh : httpd stopped
/opt/lampstack/mysql/scripts/ctl.sh : mysql stopped
/opt/lampstack/mysql/scripts/ctl.sh : mysql started at port 3306
Syntax OK
/opt/lampstack/apache2/scripts/ctl.sh : httpd started at port 80
[root@amtekgroup lampstack]#
3. Enable Iptables
iptables -I INPUT -p tcp --dport (Port)-j ACCEPT
Enable all Iptables all port Like this
iptables -I INPUT -p tcp --dport 25 -j ACCEPT
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --dport 465 -j ACCEPT
iptables -I INPUT -p tcp --dport 587 -j ACCEPT
iptables -I INPUT -p tcp --dport 8890 -j ACCEPT
iptables -I INPUT -p tcp --dport 514 -j ACCEPT
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
iptables -I INPUT -p tcp --dport 5005 -j ACCEPT
iptables -I INPUT -p tcp --dport 5055 -j ACCEPT
4. Delete all File And Folder
[root@learncodezone htdocs]# rm -rf Your_folder name
5. Find File in a directory by filename
find -name "file_name"
example

5. Stop Server
Go to file
/opt/lampstack
now just run this code in your console
./ctlscript.sh stop
Example
[root@example lampstack]# ./ctlscript.sh stop
Syntax OK
/opt/lampstack/apache2/scripts/ctl.sh : httpd stopped
/opt/lampstack/mysql/scripts/ctl.sh : mysql stopped
[root@castextech lampstack]# ^C
6. Change Directory Permission
chmod 777 your_directory
[root@learncodezone shop]# chmod 777 img
To set to all subfolders (recursively) use -R
chmod 755 folder_name -R
7. Check which port is running
lsof -i :port
#example
lsof -i :8080
If you want to kill running port
kill -9 port
#example
kill -9 8080