Linux Environment

Linux Debian Environment



So I decided to share my knowledge about Linux here. Enjoy! :)

Make your device accessible in the network

Samba

Have you heard about Samba? No, it’s not a Lion King story hahaha :P

Samba is a shared folder which you can accessed via finder or windows explorer (network). This tool is free and one of the most useful things in Linux.

To use Samba, we need to install it first (type this in your terminal):

1
apt-get install samba samba-common libcups2

Then you need to create a password for the root user:

1
smbpasswd -a root

and voila! your samba already installed in your machine, next you need to configure which folder will be accessible from your network. You can use your preferred text editor in Linux (I usually use nano).

1
nano /etc/samba/smb.conf

Then add these lines of code at the bottom of the file:

1
2
3
4
5
6
7
8
[storage] # name of your shared folder
path = /var/lib/storage # pointing to your folder's directory
available = yes
valid users = root
read only = no
browsable = yes
public = yes
writable = yes

then you need to restart your Samba by typing service smbd restart
and don’t forget to change your folder’s permission with
chmod -R 777 [path to folder]

Make IP static

Sometimes our devices will take a different IP address in our private network (let’s say at home), this problem can slow our productivity since we need to know what IP address our Linux machine has obtained.

Therefore we need to make the IP address of our machine be static so it will not change everytime the devices turned on or restarted.


To do this, all you need is just three steps:

  • nano /etc/network/interfaces and make sure your file looks like this:

    1
    2
    3
    4
    5
    6
    7
    8
    auto eth0
    iface eth0 inet static
    address [type your preferred number IP address e.g. 192.168.0.4]
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 192.168.0.1
  • nano /etc/resolv.conf and add the following code:

    1
    nameserver [preferred IP address you had written in the previous file]
  • restart our network service by typing /etc/init.d/networking restart

NB: If you can’t connect to your Linux machine, try to reboot it.

Web Development Software

MySQL and phpmyadmin

mysql
To install phpmyadmin, you need to install MySQL first:

1
apt-get install mysql-server php php-mysql php-mcrypt

Then start mysql service by typing service mysql start.


phpmyadminNow install phpmyadmin by typing apt-get install phpmyadmin, phpmyadmin will ask your preferences along the way.

If you want to reconfigure your phpmyadmin all you need to do is type
dpkg-reconfigure phpmyadmin.

If you want to make your phpmyadmin accessible from localhost/phpmyadmin you need to edit file phpmyadmin.conf

1
nano /etc/apache2/conf-available/phpmyadmin.conf

and add this line:

1
AllowOverride All in <Directory /usr/share/phpmyadmin>

Apache

I found that Apache is already installed in my machine (I think it is in package with Linux Debian), so I just configure the setting:

1
nano /etc/apache2/apache2.conf

and add this line:

1
Include /etc/phpmyadmin/apache.conf

don’t forget to restart the service by typing service apache2 restart

Additional step: Secure your phpmyadmin

Since we expose our phpmyadmin to be accessible in the browser, we need to secure our phpmyadmin site so only the authorized personel can access our phpmyadmin.

1
nano /usr/share/phpmyadmin/.htaccess

add these lines of code:

1
2
3
4
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

run this command:

1
htpasswd -c /etc/phpmyadmin/.htpasswd root

check if your phpmyadmin table already imported or not (you will notified when you enter the phpmyadmin site), if it’s not imported yet run these lines of code in sequence:

1
2
3
cd /usr/share/doc/phpmyadmin/examples
gunzip create_tables.sql.gz
mysql -u root -p --one-database phpmyadmin < create_table.sql

Additional step: Edit limit upload phpmyadmin

1
nano /etc/php5/apache2/php.ini

Additional step: Edit port used by Apache

1
nano /etc/apache2/ports.conf

Written by:
Darryl
Sources: