Category: Linux

How to setup a VPS (or Dedicated Server) with Nginx from scratch 0

How to setup a VPS (or Dedicated Server) with Nginx from scratch

In this tutorial we are going to go through the steps of securing the server and configuring Nginx, PHP, Phpmyadmin and MySql.

Step 1. Basic Security

Assuming you have already logged into your server we start by changing the root password to something more secure.

passwd

 

This will prompt you to change the root password, It is recommended to choose something extremely complex as it is your most crucial line of defence against the outside world.

Next, open up the ssh config

vim /etc/ssh/sshd_config

and change the port from 22 to anything between 1025 to 65536, this will prevent our server from being easily spotted by malicious eyes (more…)

0

How to install Oracle linux on Ubuntu

the web upd8 team has already packaged it nicely for us

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

set environment variables with

sudo apt-get install oracle-java7-set-default

Verify Oracle Java installation with

java -version

If anything goes wrong with your installation… fall back with

update-java-alternatives -s java-7-oracle

 

 

How to add user to samba share 0

How to add user to samba share

Assuming the user already exists

smbpasswd -a [username]

This will prompt you to add a password. This is normal as the samba password and the unix password is stored in different databases

How to search inside files in linux 0

How to search inside files in linux

To search within files we can use the command grep (man grep). Basic usage is as follows:

grep -Ril "mail" /var/www/

This will search our web root folder (/var/www/) for any text with the word ‘mail’ inside it.

  • R – Recursive
  • i – uppercase/lowercase
  • l –  Show file name instead of actual location
How to open ports on Cent OS/Fedora/Red Hat 0

How to open ports on Cent OS/Fedora/Red Hat

To open port XY

Open flle /etc/sysconfig/iptables:

# vi /etc/sysconfig/iptables

Append rule as follows:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport XY -j ACCEPT

Save and close the file. Restart iptables:

# /etc/init.d/iptables restart

Verify that port is open

Run following command:

# netstat -tulpn | less

Make sure iptables is allowing port connections:

# iptables -L -n
How to give www-data (or any other user) sudo 0

How to give www-data (or any other user) sudo

Use visudo so you don’t completely destroy your PC. (Visudo will tell you there are any errors before you save [mistakes will permanently lock you out of your own PC].

visudo

Enter the details below then save..

www-data ALL=(ALL) ALL

 

If you wish to be more specific and give this user passwordless sudo for particular commands use the format

www-data ALL=(ALL) NOPASSWD: /sbin/shutdown, NOPASSWD: /sbin/reboot