Some Important CentOS Commands
Some Important CentOS Commands
### Check Selinux, Selinux is a firewall
-> getenforce
### Disable Selinux
-> vim /etc/sysconfig/selinux
### Change IP
-> nmtui
###check hidden file
->ls -ls
### read any file
-> cat filename
#Search file or folder
-> find / -name ansible
###if any partition is read only
mount -o remount, rw /
### check any html file
-> curl pagename
cd /var/www/html
###Login another computer
-> ssh root@192.168.0.136
###login another computer without password
->ssh-keygen
->cd /root/.ssh/
## id_rsa -> private key
## id_rsa.pub -> public key
### copy private key and public key to another computer
->ssh-copy-id root@192.168.0.136
### access mysql
-> mysql -u root -p
### Check mysql status
-> systemctl status mysqld
$ sudo systemctl enable mysqld
$ sudo systemctl start mysqld
### check dns of any website
–> nslookup www.google.com
### Check all ports
—> ss
cat /etc/services
grep -w 80 /etc/services
sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo netstat -tulpn | grep :443
sudo ss -tulpn | grep LISTEN
sudo ss -tulpn | grep ‘:22’
### mysql Password reset
1. sudo grep ‘temporary password’ /var/log/mysqld.log ( a temp pass will be generated)
2. $ sudo mysql_secure_installation
### disbale DNS
1. sudo sed -i ‘s/^dns=dnsmasq/#&/’ /etc/NetworkManager/NetworkManager.conf
sudo service network-manager restart
sudo service networking restart