Tuesday, April 30, 2024
Tuesday, April 2, 2024
Tuesday, October 31, 2023
Changing the ownership of all sub-directories in Linux
$ sudo chown -R utest ./samplefolder/
$ ls -l ./samplefolder/
Saturday, October 14, 2023
Common linux commands
- whoami
- man
- clear
- pwd
- ls
- cd
- mkdir
- touch
- rmdir
- rm
- open
- mv
- cp
- head
- tail
- date
- cat
- less
- echo
- wc
- piping
- sort
- uniq
- expansions
- diff
- find
- grep
- du
- df
- history
- ps
- top
- kill
- killall
- gzip
- gunzip
- tar
- nano
- alias
- xargs
- ln
- who
- su
- sudo
- passwd
- chown
- 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
chmod 644 /home/cpanel_unsername/maillog
Sunday, August 13, 2023
How to add Service to Autostart (CentOS 6/7)
systemctl status httpd.service
Wednesday, May 10, 2023
How to write or append a file without opening in Linux?
echo "hello world" >> /directory_path/my_file.txt
Friday, May 5, 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:0ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.11
NETMASK=255.255.255.255
Sunday, February 19, 2023
How to Install PHP 8.0/8.1on Linux Centos 7
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]
orrm -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 Option | Description |
rm -d | Remove an empty directory using the rm command. |
rm -r | Remove a non-empty directory and its content. |
rm -f | Ignore any prompt when deleting a write-protected file. |
rm -rf | Ignore any prompt when deleting a write-protected non-empty folder. |
rm -i | Output a prompt before deleting every file. |
rm -I | Output a prompt only once before deleting more than three files. |
rm * | Wildcard that represents multiple characters. |
rm ? | Wildcard that represents a single character. |
rmdir -p | Remove an empty subdirectory and its parent directory. |
rmdir -v | Print the information that the specified directory was deleted. |
Monday, September 12, 2022
Reset MySQL Root Password on Red Hat Enterprise Linux 8
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:
- Select a file that is need to be downloaded and do right click.
- Click Share. A dialog box will appear.
- Click Advance in the right bottom corner.
- Click on the Change.. under who has access.
- Make it On- Public on the web.
- Click Save button.
- Copy the link for sharing…like…https://drive.google.com/file/d/1UibyVC_C2hoT_XEw15gPEwPW4yFyJFeOEA/view?usp=sharing
- 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
How to get Ranking of the Students in Excel using RANK Function
=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...
-
Put the following code in a TXT file and save as "file.cmd" then run the cmd file as administrator. @echo off title Activate Micr...
-
We can install PowerMTA on the server. rpm -ivh /home/PowerMTA-4.0r6.x86_64.rpm You will see the output like this Preparing... #############...
-
# $Id: config 2015-03-24 16:00:00 Jack $ # Sample PowerMTA configuration file # PowerMTA Multiple Virtual PMTA config file sample # # E-mai...