buy tb500

Archive for the ‘Linux’ Category

Restore Database Plesk Oynx – Linux command line

Thursday, May 4th, 2017

1- plesk db  databasename < databasename.sql

or

2- mysql -uadmin -p”`cat /etc/psa/.psa.shadow`” databasename < databasename.sql

Find and Replace in Linux

Thursday, May 4th, 2017
sed -i 's/original/new/g' file.txt

  • sed = Stream EDitor
  • -i = in-place (i.e. save back to the original file)
  • The command string:
    • s = the substitute command
    • original = a regular expression describing the word to replace (or just the word itself)
    • new = the text to replace it with
    • g = global (i.e. replace all and not just the first occurrence)
  • file.txt = the file name
 

Reconfigure Nginx in Plesk Onyx Centos 7

Monday, April 10th, 2017

Run the following command

 

/usr/local/psa/admin/bin/httpdmng –reconfigure-all

 

 

How to RSYNC files between two servers

Wednesday, December 21st, 2016

The below command need to be run in the source server to sync the files to the destination server

rsync -auvP /home/eplusglo/mail –rsh=”ssh -p 55000 ” root@124.216.218.39:/home/alzweac/

in the above command the mail folder will sync to the new server

 

leave a comment if you not understand.

Thanks.

Sort file by size

Friday, November 11th, 2016

du -sh * | sort -rh | head -6

ZIP and UNZIP in Linux Command Line.

Thursday, November 3rd, 2016

Task: Create a Zip File

To create a zip file, enter:

zip filename.zip input1.txt input2.txt resume.doc pic1.jpg

Task: Decompress a zip

To decompress a zip file in Unix, enter:

unzip filename.zip

Mount unknown file system type NTFS CentOS

Friday, June 17th, 2016

By default CentOS does not support the ‘NTFS’ file system, if you are tying to mount an NTFS file system  you will  need to have installed correct RPM package

#  wget  packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

# rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm

warning: rpmforge-release-0.3.6-1.el5.rf.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing…        ########################################### [100%]
1:rpmforge-release  ########################################### [100%]

#  yum install fuse fuse-ntfs-3g dkms dkms-fuse

Make a directory for mount a file system to /mnt/usb

# mkdir /mnt/usb

# fdisk -l

Disk /dev/sda: 1999.8 GB, 1999844147200 bytes
255 heads, 63 sectors/track, 243133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      514048+  83  Linux
/dev/sda5           14902       15921     8193118+  83  Linux
/dev/sda6           15922      243133  1825080358+  83  Linux

Disk /dev/sdb: 1000.2 GB, 1000204885504 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      121602   976759808    7  HPFS/NTFS

 

Execute the mount command

# mount -t ntfs-3g /dev/sdb1 /mnt/usb/

Open the mounted directory /mnt/usb

# cd /mnt/usb/

# ls -al
drwxr-xr-x 39 root root       4096 May 11 09:34 .
drwxr-xr-x  5 root root       4096 Jan 11 09:34 ..

Now the ntfs partition mounts perfect.

#  df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6             1.1T  179G  880G  12% /
/dev/sda5             6.6G  146M  6.1G   2% /tmp
/dev/sda1             587M   43M  519M  10% /boot
/dev/sdb1             932G  781M  931G   1% /mnt/usb

You will need to unmount the partition,

umount /mnt/usb

references

http://thelinuxfaq.com/41-mount-unknown-file-system-type-ntfs-centos

OpenSSH Installations under CentOS Linux

Thursday, March 31st, 2016

OpenSSH Installations under CentOS Linux

To install the server and client type:

# yum -y install openssh-server openssh-clients

 

Start the service:

# chkconfig sshd on
# service sshd start

 

Make sure port 22 is opened:

netstat -tulpn | grep :22

 

Firewall Settings

Edit /etc/sysconfig/iptables (IPv4 firewall),

vi /etc/sysconfig/iptables

 

Add the line

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEP

 

If you want to restict access to 192.168.1.0/24, edit it as follows:
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT

If your site uses IPv6, and you are editing ip6tables, use the line:
-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j ACCEPT

 

Save and close the file. Restart iptables:
# service iptables restart

———————-

OpenSSH Server Configuration

Edit /etc/ssh/sshd_config, enter:
# vi /etc/ssh/sshd_config

To disable root logins, edit or add as follows:
PermitRootLogin no

 

Restrict login to user tom and jerry only over ssh:
AllowUsers tom jerry

Change ssh port i.e. run it on a non-standard port like 1235
Port 1235

Save and close the file. Restart sshd:
# service sshd restart

Find and replace in Linux file

Tuesday, December 1st, 2015

if in single file

sed -i ‘s/ugly/beautiful/g’ /home/bruno/old-friends/sue.txt

if in multiple files

$ find /home/bruno/old-friends -type f -exec sed -i ‘s/ugly/beautiful/g’ {} \;

 

Thanks.

 

To figure out how many CPU cores you have on your dedicated server

Thursday, November 26th, 2015

SSH to the server and run the following command

grep pro /proc/cpuinfo -c

 

Thanks.