Saturday, March 13, 2021

Cara Mudah Belajar Linux dalam Windows 10

Jom kita belajar Linux guna Kali Linux dalam Windows 10.

Sambil-sambil tu boleh cuba security tools yang ada dalam Kali.

Kita install 

  1. Windows System for Linux (WSL)
  2. Kali Linux, dan
  3. XFCE desktop manager. 

Memula kena set upkan Windows System for Linux (WSL)

 1. right click on the Start Button 
 2. Pilih Windows PowerShell (mode Admin). Jika dah ada WSL(skip langkah ini)

copy dan paste command berikut dan tekan Enter untuk run :

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

3. Reboot  PC.

Install Kali Linux plak

1. Next, kita install Kali Linux.  Cari Kali Linux dalam Microsoft App store app or klik disini untuk buka terus (klick this link to open it directly).
2. Klik butang Get untuk download dan install
3. Lepas install klik butang Launch atau cari shortcut dalam Start Menu atau boleh terus ke PowerShell atau command prompt dan taip Kali kendian tekan Enter. Untuk kali pertama instalasi dan konfigurasi kena la selesai dulu. Ini mengambil masa sedikit ya ! Bawak bersabor


4. Lepas siap kita setkan WSL username dan password, silalah ikut secukup rasa untuk create. Ini diperlukan masa nak guna SUDO command.


 Kita setkan UI guna Desktop Manager XFCE

1. Sebelum kita nak ada Desktop Manager cam Windows tu kena install utiliti yang power dalam Linux iaitu  wget bagi membolehkan kita memuat turun fail dari http. Jgn lupa kalau dia tanya password gunakan yg kita dah create kat step atas tadi. Tekan Y untuk proceed untuk download dan terus intalasi.

sudo apt-get install wget




2. Dah siap install wget, kita proceed langkah seterusnya untuk download scripts instalasi

wget https://gitlab.com/kalilinux/build-scripts/kali-wsl-chroot/-/raw/master/xfce4.sh

3. Lepas tu kita run script instalasi tadi, ambik masa sket tp berbaloi kalau jawab soalan yang ditanya dengan betul.

sudo sh xfce4.sh

4. Selesai je , kita dah boleh start xrdp server supaya boleh guna Remote Desktop untuk akses server tu.

sudo /etc/init.d/xrdp start

5. Bila xrdp server dah run kita dah boleh guna Remote Desktop guna mstsc kat windows kita untuk connect 127.0.0.1:3390



6. Dah leh login guna username dan password yang kita dah create tadi.


7. Best practises selepas guna, kita shutdown dengan betul

sudo /etc/init.d/xrdp stop

Rasanya kita dah boleh sama-sama tingkat pengetahuan sebab dah boleh guna dalam laptop atau PC yang sama. Tak perlu lagi nak dual boot tapi ni sekadar teknik mungkin ada yg lebih baik lagi. 

Tolong komen dibawah jika ada apa2 yang boleh dikongsikan

#blajarSampaiLiangLahad
#kompetensiPenerajuWawasan

Wednesday, March 8, 2017

Installation Laravel Dalam Windows

1. Install XAMPP
ini untuk composer guna php.exe
2. Install composer
3.Installing Laravel
Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

Via Laravel Installer

First, download the Laravel installer using Composer:
composer global require "laravel/installer"
Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system.
Once installed, the laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog will create a directory named blog containing a fresh Laravel installation with all of Laravel's dependencies already installed:
laravel new blog
4. configure path


The PATH for Windows:

I’ve found the location where composer stores the Vendor files.
So instead of ~/.composer/vendor/bin, on Windows the following path should be used:
C:\Users\>\AppData\Roaming\Composer\vendor\bin

How to install the Laravel Installer:

I assume you have php and composer in your PATH already.
First of all install the Laravel Installer. Open a command prompt and enter:
composer global require "laravel/installer=~1.1"

Then update the PATH environment variable via e.g. command prompt with admin privileges:
setx /M path "%path%;%appdata%\Composer\vendor\bin"
%appdata% is added, so you don’t have to worry about adding your computer name.
5. Untuk buka folder project

subl.exe nama folder cth: subl.exe project



Wednesday, March 25, 2015

Masalah Server Ubuntu x Leh boot lepas Powertrip atau Force Shutdown

Error : Target filesystem doesn't have /sbin/init

 mount: mounting /dev on /root/dev failed: No such file or directory  
 mount: mounting /sys on /root/sys failed: No such file or directory  
 mount: mounting /proc on /root/proc failed: No such file or directory  
 Target filesystem doesn't have /sbin/init  
 No init found. Try passing init= bootarg  
 (and then something about initramfs)  

Error ini berkemungkinan berlaku disebabkan oleh kerosakan pada file-system yang mana rosak disebabkan oleh cara shutdown yang tidak betul (force) atau berlakunya gangguan bekalan elektrik dimana tiada ups untuk membuat prosedur shutdown dengan betul.

Insyallah boleh cuba cara ini untuk membaiki file-system tersebut.

1. Dapatkan bootable iso di http://distrowatch.com/table.php? mengikut OS yang berkenaan.

a. sekiranya physical server
   i. Burn pada usb agar boleh boot guna USB tersebut.
   ii.Boleh gunakan software berikut untuk burn dalam usb http://unetbootin.sourceforge.net/
   iii. Boot server untuk load OS dari USB

Step ini yang aku tunjuk.

b. Virtual Server.
   i. Boleh boot terus dari ISO yang telah didownload.

2. Run command dalam terminal

    Pilih Try Ubuntu
    Cari Terminal
    Taip command kat bawah ni.

   sudo e2fsck -f -y -v /dev/sda1 
   sudo reboot

   command yg sama mcm chkdsk dalam Windows. Kita nak check dan repair filesystems.

   Dah siap dah ....

3. Cabut atau disconnet USB/ISO

4. Reboot Server
Kan dah boleh reboot server korang.
Alhamdulillah berbuat baiklah sesama manusia. Insyallah Allah akan balas budi korang.
Telah di uji di Server Ubuntu.

Wednesday, January 21, 2015

Memasang OwnCloud 7.0.4 dengan Nginx, MariaDB dan PHP-FPM dalam Ubuntu

Masuk ke server Ubuntu (Aku guna Ubuntu 14.0.4 dan masa install aku hanya pilih install ssh-server je). Lepas tu guna putty masuk ke server tu. Biasanya ini best practices cara aku klu korang nak start.
apt-get update
apt-get upgrade
Install la MariaDB database yang akan femes masa kini. Tapi kalau korang nak guna yang lain kena la cari kat tempat lain ye!
sudo apt-get install mariadb-server
Guna skrip dibawah klu korang nak secure db korang. Tp aku recommend buat la.
mysql_secure_installation
Jawab soklan ikut macamana korang nak securitykan DB korang tu. Tak faham tanya pakcik google.
- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
Masuk ke MariaDB sebagai root dan korang create user baru untuk database Owncloud tu  
mysql -u root -p
Enter password:
MariaDB [(none)]> CREATE DATABASE owncloud;
MariaDB [(none)]> GRANT ALL ON owncloud.* to ownclouduser@localhost identified by 'YOURPASSWORD';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
Install Nginx web server, PHP5-FPM dan pakej yang diperlukan ... just cut and paste je .. dulu penerangan kenapa kena install korang google la ...
sudo apt-get install nginx php5-fpm php5-common php5-cli php5-json php5-mysql php5-curl php5-intl php5-mcrypt php5-memcache php5-gd
Dah siap boleh la g download pakej Installer ownCLoud dari website dia.Version aku 7.0.4
cd /usr/share/
sudo wget https://download.owncloud.org/community/owncloud-7.0.4.tar.bz2
sudo tar xvfj owncloud-7.0.4.tar.bz2
sudo rm owncloud-7.0.4.tar.bz2
sudo chown -R www-data:www-data owncloud/
Korang kena generate sijil ssl dia dan adjust sket nginx config

sudo mkdir /etc/nginx/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/owncloud.key -out /etc/nginx/ssl/owncloud.crt
Akan keluar satu scripts so follow Me la ...

Generating a 2048 bit RSA private key
..+++
....................+++
writing new private key to '/etc/nginx/ssl/owncloud.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:MY
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Edit atau create virtual block dalam nginx
sudo vi /etc/nginx/sites-available/default
Masukan script ni la bro !.
upstream php-handler {
        #server 127.0.0.1:9000;
        server unix:/var/run/php5-fpm.sock;
}
 
server {
listen 80;
server_name 10.0.0.11;
return 301 https://$server_name$request_uri; # enforce https
}
 
server {
listen 443 ssl;
server_name 10.0.0.11;
 
ssl_certificate /etc/nginx/ssl/owncloud.crt;
ssl_certificate_key /etc/nginx/ssl/owncloud.key;
 
# Path to the root of your installation
root /usr/share/owncloud;
 
client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;
 
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
 
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
 
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
 
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}
 
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
 
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
 
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
 
try_files $uri $uri/ index.php;
}
 
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}
 
# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
 
}

Enable kan script tadi ...
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default/
Editkan php-fpm config fail.
sudo vi /etc/php5/fpm/pool.d/www.conf
Masukan atau periksa value

listen = /var/www/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
Restart Nginx and PHP-FPM.

sudo service nginx restart
sudo service php5-fpm restart

Monday, October 6, 2014

Upgrade Redmine 1.3 to Redmine 2.5 on Ubuntu 12.04

This is my way to upgrade Redmine 1.3 to Redmine 2.5 .For the past 2 week , i has been tried to seek the best way to upgrade my Redmine 1.3 without upgrading my Ubuntu OS.

I'm NOT Redmine atau Ubuntu JEDI ... hehehehe , So please forgive me for any mistakes that made by my own. Hopefully with a feedback, i can make the installation notes more better and clearer.

Lets Start:
Get into existing Redmine folder and move to backup folder.
     cd /usr/share
     ls
     sudo mv redmine old-redmine
Now we’re going to download the latest version of Redmine from RubyForge: http://www.redmine.org/projects/redmine/wiki/DownloadWhen i do this, the release is redmine-2.5.2.tar.gz. We need to extract and rename it to redmine folder and give correct permission. Make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file
     sudo wget http://www.redmine.org/releases/redmine-2.5.2.tar.gz
     sudo tar xvfz redmine-2.5.2.tar.gz
     sudo mv redmine-2.5.2  redmine
     sudo chown -R root:root /usr/share/redmine
     sudo chown www-data /usr/share/redmine/config/environment.rb
Update a symbolic link from the main website home back to our actual Redmine application directory.
     sudo mv /var/www/redmine /var/www/0ld-redmine
     sudo ln -s /usr/share/redmine/public /var/www/redmine
Now we need to configure DB and make sure existing DB name is same in the new config files:
     sudo cp redmine/config/database.yml.example redmine/config/database.yml
     sudo nano redmine/config/database.yml
production:
 adapter: mysql2
 database: redmine (*same with old DB name*)
 host: localhost
 username: redmine
 password: my_password (*same with old DB name*)
 encoding: utf8
Before proceed redmine need to install ruby1.1.9-full and add all required libraries.
I preferred to use RMagick to enable Gantt export to png image.
     sudo apt-get install ruby1.9.1-full libmagickcore-dev libmagickwand-dev libmysqlclient-dev
We need to install bundle. Bundle is using to install Ruby Gems that needed by Redmine.
     sudo gem install bundler
Change to redmine folder and run to install Gems
     cd redmine
     sudo bundle install --without development test postgresql sqlite
Configure Redmine: 
There are question before the script finish configure, we need to choose our languange.
Type the code accordingly to your country or preferable languange.
     sudo rake generate_secret_token
     sudo RAILS_ENV=production rake db:migrate 
     sudo RAILS_ENV=production rake redmine:load_default_data
Some directory,we need to configure correct directory permissions:
     sudo mkdir public/plugin_assets
     sudo chown -R www-data:www-data files log tmp public/plugin_assets
     sudo chmod -R 755 files log tmp public/plugin_assets
Now we can test Redmine:
     sudo ruby script/rails server webrick -e production
Enter your webaddress:http://ipaddress:3000 you should see the new version Redmine homepage.
Now configure Passenger to make sure it launches when Apache runs.
Edit

Preliminary :

Check version Ubuntu
     lsb_release -a
Check which ruby:
    which ruby
/usr/bin/ruby
    ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 22 Sep 26 16:05 /usr/bin/ruby -> /etc/alternatives/ruby
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 16 2011-10-17 21:20 /usr/local/bin/ruby -> /usr/bin/ruby1.8

Change to ruby1.9
sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.8     50        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 18 2011-12-30 17:35 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1
We need to configure Gems also:
sudo update-alternatives --config gem
There are 2 choices for the alternative gem (providing /usr/bin/gem).
  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gem1.8     180       auto mode
  1            /usr/bin/gem1.8     180       manual mode
  2            /usr/bin/gem1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gem1.9.1 to provide /usr/bin/gem (gem) in manual mode.
Edit

Install & Configure Passenger:

     sudo gem install passenger
Before we can install the Passenger module, we need some additional software:
     sudo apt-get install libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Now we are set to install the Passenger module for Apache:
     sudo passenger-install-apache2-module
Passenger will run & compile the source code into the module for Apache.
When compilation almost finish you need to copy some configuration from the running scripts:
Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so

   
     PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
     PassengerDefaultRuby /usr/bin/ruby1.9.1
   

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!
Backup old loader
sudo mv /etc/apache2/mods-enabled/passenger.load /home/admindesa(myhome folder)/
Now use nano or your favourite editor to create the loader:
sudo vi /etc/apache2/mods-available/passenger.load
#LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
Then make the module enabled:
sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
Backup Old Virtual
sudo mv /etc/apache2/sites-available/default /home/admindesa/
Configure Passenger in Virtual Hosts
vi /etc/apache2/mods-available/passenger.conf
Edit a configuration file for Passenger

  PassengerDefaultUser www-data
  PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.53
  PassengerDefaultRuby /usr/bin/ruby1.9.1
#  PassengerRoot /usr
#  PassengerRuby /usr/bin/ruby

Reconfigure Virtual Hosts
sudo mv /etc/apache2/sites-available/default /home/admindesa/
sudo vi /etc/apache2/sites-available/default

 ServerName my_domain.com
 DocumentRoot /var/www/redmine
 ServerAdmin user@example.com
 LogLevel warn
 ErrorLog /var/log/apache2/redmine_error
 CustomLog /var/log/apache2/redmine_access combined
 
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 RailsBaseURI /redmine
 PassengerResolveSymlinksInDocumentRoot on
 

Tell Apache how to configure Passenger:
sudo nano /etc/apache2/apache2.conf
Add the following line at the end of the file:
Include /etc/apache2/mods-available/passenger.conf
Finally, enable the site:
sudo mv  /etc/apache2/sites-enabled/000-default /home/admindesa/
sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/000-default
Make sure the Passenger module is enabled:
sudo a2enmod passenger
And, restart Apache:
sudo service apache2 restart
If everything went well, then you should be able to see Redmine in your browser:

Saturday, October 4, 2014

How to check our Ubuntu version

Some time we need to determine which version our Ubuntu running  :

Before upgrade version
When we need to update application

 lsb_release -a  

Friday, October 3, 2014

Rename Symlink

Pada satu ketika keperluan untuk rename symlink asal kpada yang baru diperlukan. Ini bertujuan untuk mengunakan nama symlink sediaada kepada :


  1. version baru
  2. copy folder baru
  3. folder apps yang nak guna nama symlink yang telah digunakan
  4. housekeeping

 sudo mv redmine(old symlink) old-redmine(new symlink)