Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, October 14, 2023

Common linux commands

  1. whoami
  2. man 
  3. clear 
  4. pwd
  5. ls
  6. cd 
  7. mkdir 
  8. touch 
  9. rmdir 
  10. rm 
  11. open 
  12. mv 
  13. cp 
  14. head
  15. tail 
  16. date
  17. cat
  18. less 
  19. echo 
  20. wc 
  21. piping 
  22. sort
  23. uniq 
  24. expansions 
  25. diff 
  26. find 
  27. grep
  28. du
  29. df 
  30. history
  31. ps
  32. top 
  33. kill
  34. killall
  35. gzip
  36. gunzip
  37. tar
  38. nano
  39. alias 
  40. xargs
  41. ln
  42. who
  43. su 
  44. sudo 
  45. passwd
  46. chown
  47. chmod

Sunday, September 17, 2023

Find WHM/cPanel or linux failed email login log



Webmail Login attempt:


/usr/local/cpanel/logs/login_log

cp /usr/local/cpanel/logs/login_log /home/cpanel_unsername

chmod 644  /home/cpanel_unsername/ogin_log


POP3 login attempts:


/var/log/maillog

cp /usr/local/cpanel/logs/maillog /home/cpanel_unsername

chmod 644  /home/cpanel_unsername/maillog

Sunday, August 13, 2023

Wednesday, April 19, 2023

How to add an additional IP address in Centos 7

Method -1:

Create file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following content:

DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.11
NETMASK=255.255.255.255

service network restart

Method-2:

Run the following command
ipadd your_ip

Example: ipadd 192.168.0.1

Sunday, February 19, 2023

How to Install PHP 8.0/8.1on Linux Centos 7

Method-1 for PHP 8.0

Remi Repository
# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

PHP 8.0 install
# yum install -y --enablerepo=remi-php80 php php-cli

Exntesions:
#yum install -y --enablerepo=remi-php80 php-mysqlnd

Method-1 for PHP 8.1

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php81
yum repolist
yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}

Wednesday, February 15, 2023

Stop and Disable Firewalld on CentOS 7

sudo firewall-cmd --state

sudo systemctl stop firewalld

sudo systemctl disable firewalld

sudo systemctl mask --now firewalld

Sunday, October 23, 2022

How to move all files and folders via mv command

To move all files & folders from one destination to another:  

mv /path/sourcefolder/* /path/destinationfolder/

To move All files & Folder of current:

 mv * /path/destinationfolder/

To move single File:

 mv filename.zip /path/destinationfolder/

Thursday, September 15, 2022

How to remove directory in Linux

 To permanently remove a directory in Linux, use either rmdir or rm command:

  • For empty directories, use rmdir [dirname] or rm -d [dirname]
  • For non-empty directories, use rm -r [dirname]

Before you remove a directory, you need to know the name of it. To discover files and directories, use the ls command, and to know the current directory you are in, use the pwd command.

The options you use together with these commands are also important to determine how they work. Here’s a quick recap of rm command options:

Command and OptionDescription
rm -dRemove an empty directory using the rm command.
rm -rRemove a non-empty directory and its content.
rm -fIgnore any prompt when deleting a write-protected file.
rm -rfIgnore any prompt when deleting a write-protected non-empty folder.
rm -iOutput a prompt before deleting every file.
rm -IOutput a prompt only once before deleting more than three files.
rm *Wildcard that represents multiple characters.
rm ?Wildcard that represents a single character.
rmdir -pRemove an empty subdirectory and its parent directory.
rmdir -vPrint the information that the specified directory was deleted.

Monday, September 12, 2022

Reset MySQL Root Password on Red Hat Enterprise Linux 8

sudo systemctl stop mysqld

sudo systemctl set-environment MYSQLD_OPTS=”--skip-grant-tables”

sudo systemctl start mysqld

sudo mysql -u root

mysql> FLUSH PRIVILEGES;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewRootPassw0rd!'; 

mysql> FLUSH PRIVILEGES;

mysql> QUIT;

sudo systemctl stop mysqld

sudo systemctl unset-environment MYSQLD_OPTS

sudo systemctl start mysqld

sudo mysql -u root -p

mysql> QUIT;

sudo mysql -u root -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ChangeRootPassw0rd!';

mysql> ALTER USER 'shola'@'localhost' IDENTIFIED BY 'ChangeSholaPassw0rd!';

mysql> FLUSH PRIVILEGES;

mysql> QUIT;

Now login again with new root password !!

Sunday, September 4, 2022

How to access EC2 instance if lost key Pair and root credentials

Step-1: 

Create a new instance with same OS as previous one or create it from AIM made from old instance

Step-2: 

Shutdown the old instance and detach the volume

Step-3: 

Shutdown new instance Attached the detached volume to new instance and start the instance

Step-4: 

Login new instance using ssh console

Run the following commands:

lsblk

df -h

cd mnt

mkdir oldvolume

sudo mount /dev/sda1 mnt/oldvolume

cd mnt/oldvolume/root/.ssh

sudo vi authorized_keys

Now add your public key and save 

umount /dev/sda1

sudo shutdown now

Step-5: 

Now detach the dev/sda1 volume from new instance and attach to old instance as dev/sda

Step-6:

Reboot old instance from AWS dashboard and login your old instance using ssh console 

 Note: Your old instance IP will be changed after doing this if no elastic IP

Monday, August 29, 2022

How to install NGINX and configure on Ubuntu 20.04

sudo apt-get update

sudo apt upgrade

sudo apt install nginx

sudo systemctl status nginx

sudo ufw allow http

sudo ufw reload


sudo systemctl status nginx

sudo systemctl stop nginx

sudo systemctl start nginx


sudo systemctl disable nginx

sudo systemctl enable nginx

sudo systemctl restart nginx

sudo systemctl reload nginx



sudo unlink /etc/nginx/sites-enabled/default

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl restart nginx

sudo mkdir /var/www/example.com

How to unzip tar.gz file in linux

sudo apt-get install zip

unzip file.zip -d destination_folder

unzip file.zip

tar -xf archive.tar.gz

Thursday, August 25, 2022

How to add public key to authorized_keys ec2 instance Ubunutu Linux

 Step 1: Login into you AWS account and go to EC2 instances

Step 2: Select your instance and click connect

Step 2: Then click connect button at the bottom right corner

Step 3: Now a new tab will be opened with console as follows

Step 4: Copy your SSH public key then add the key to the following key file

Use this command in Mac/Windows powershell to copy your public key: pbcopy ~/.ssh/id_rsa.pub

nano ~/.ssh/authorized_keys

Step 5: Save and reboot then try to connect again with device from which public key generated.

Tuesday, March 15, 2022

Download Large File from Google Drive to Linux Directory using command

First install yum if not installed before : sudo yum install wget

Before the file to be downloaded it is needed to be share publicly.

Steps:

  1. Select a file that is need to be downloaded and do right click.
  2. Click Share. A dialog box will appear.
  3. Click Advance in the right bottom corner.
  4. Click on the Change.. under who has access.
  5. Make it On- Public on the web.
  6. Click Save button.
  7. Copy the link for sharing…like…https://drive.google.com/file/d/1UibyVC_C2hoT_XEw15gPEwPW4yFyJFeOEA/view?usp=sharing
  8. Extrac FILEID part like….from above….1UibyVC_C2hoT_XEw15gPEwPW4yFyJFeOEA



For small file run following command on your terminal:

wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME

In the above command change the FILEID by above id extracted and rename FILENAME for your own simple use.

Large files

For large file run the following command with necessary changes in FILEID and FILENAME:

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt

Wednesday, June 2, 2021

Install imap extension on PHP 7.x or Higher in CentOS 8

yum update -y 

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 

yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm 

yum install -y php80-php-imap 

cp /opt/remi/php80/root/usr/lib64/php/modules/imap.so /usr/lib64/php/modules/ /bin/echo 'extension="imap.so"' > /etc/php.d/40-imap.ini 

systemctl restart php-fpm

Extract Domain from email in Excel or Google sheet

  =TEXTAFTER( A2 , "@") or, =MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))