Format Hard Drive Partition with DiskPart Command Line

Format disk is necessary before using and sometimes you need to format disk partition in a terminal for it to work properly.

It can happen, that some other operating system formatted your disk (or USB drive) and now you don't see it on My computer. In that case, use DiskPart.

1. Start CMD (Windows Terminal): click Windows button, type 'cmd' and push Enter.

2. In the command line type:

diskpart

3. Check available disks

DISKPART> list disk

4. Select a disk, you want to format (eg. 3)

DISKPART> select disk 3

5. Clean the selected disk

DISKPART> clean

6. Create a primary partition

DISKPART> create partition primary

7. Select first partition

DISKPART> select partition 1

8. Format the partition (to eg. fat32)

DISKPART> format fs=fat32 quick

9. Exit the DiskPart

DISKPART> exit

Your disk is now properly formatted.

Subversion SVN for command-line (console)

Download appropriate package for you OS from: https://subversion.apache.org/packages.html

I use Win32Svn for Windows and it works great.

 

Show SVN help

svn help

View SVN info

svn info

View SVN status

svn status

Update SVN repository

svn update

Commit to SVN repository

svn commit -m "This is a commit message."

Merge branch

svn merge ^/branches/branchname

Checkout branch

svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch

Switch to branch

svn switch http://svn.example.com/repos/calc/branches/my-calc-branch

Install VMware tools on Ubuntu Server

1. Enable Shared folders

Edit virtual machine settings, go to Options / Shared folders, set to Always enabled and add a host folder to the Folders list. Run virtual machine and login to Ubuntu Server with your username and password.

2. Update package repository

sudo apt-get update

3. Instal dependencies

sudo apt-get install gcc binutils make linux-source

4. Start with the VMware Tools installation

Click "Install VMware Tools..." in the window menu of the virtual machine. If the prompt window appears (Disconnect anyway and override the lock?), click Yes.

5. Create mount directory for CD-ROM

sudo mkdir /mnt/cdrom

6. Mount virtual CD-ROM to created folder

sudo mount /dev/cdrom /mnt/cdrom

7. Extract .tar file

sudo tar xzvf /mnt/cdrom/VMwareTools-?.?.?-???????.tar.gz -C /tmp/

Tar file should be named as the file that is listed in the /mnt/cdrom folder.

8. Navigate to the extracted location

cd /tmp/vmware-tools-distrib

9. Run installation

sudo ./vmware-install.pl -d

10. Reboot the system and the VMware Tools are installed.

sudo reboot

Configure static local IP on Raspberry Pi Raspbian

1. Login to your Raspberry Pi and check your networking

ifconfig
eth0 Link encap:Ethernet         HWaddr 00:0c:29:7c:05:22 
inet addr:192.168.1.123 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

2. Edit the network config file »interfaces«

sudo nano /etc/network/interfaces

3. You will see these lines

# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
auto eth0

iface lo inet loopback
iface eth0 inet dynamic

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.con

4. Change the lines to this configuration (don't mind the comments)

# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
auto eth0

iface lo inet loopback
iface eth0 inet static # dynamic is changed to static 
address 192.168.1.100 # your custom local IP 
netmask 255.255.255.0 # same as Mask on ifconfig
network 192.168.1.0 # same as Bcast on ifconfig but with the zero at the end
broadcast 192.168.1.255 # same as Bcast on ifconfig
gateway 192.168.1.1 # default local network IP 
dns-nameservers 8.8.8.8 8.8.4.4 # Google's DNS servers

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

5. Save the file and restart networking

sudo /etc/init.d/networking restart

6. Check your local static IP

ifconfig
eth0 Link encap:Ethernet          HWaddr 00:0c:29:7c:05:22 
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

7. You may have to reboot your Raspberry Pi

sudo reboot

Note: You can also edit /etc/resolv.conf but these changes will be overwritten on reboot.

Package repositories on Ubuntu Server

Package repositories

Update the package repositories from sources with the latest versions

sudo apt-get update

A list of repositories, that the server will check for packages, is stored at /etc/apt/sources.list

cat /etc/apt/sources.list

Extra repositories can be added to /etc/apt/sources.list.d

Package information

Search for available packages (eg. mysql); to search only by the package name, use -n tag.

sudo apt-cache search mysql
sudo apt-cache search -n mysql

Get the package information (eg. mysql-server-5.6)

sudo apt-cache show mysql-server-5.6

Install/uninstall a package

Install a package || without prompting use tag -y || for quiet install use tag -qq

sudo apt-get install -y mysql-server-5.6

Uninstall a package ('purge' removes the configuration, 'remove' removes only the package)

sudo apt-get purge mysql-server-5.6

After uninstalling use autoremove to remove any dependencies that are not in use by other packages

sudo apt-get autoremove

List all installed packages

Get a list of packages installed locally (the -v tag "inverts" grep to return non-matching lines)

dpkg --get-selections | grep -v deinstall

Get a list of a specific package installed

dpkg --get-selections | grep mysql

Alternatively, simply use

dpkg -l

Get just the packages which were expressly installed (not just installed as dependencies)

aptitude search '~i!~M'

 

Install & configure Samba Server on Ubuntu VM

1. Install Samba

The first thing we need to do is to update the package repositories and then install Samba.

sudo apt-get update
sudo apt-get install samba

2. Configure Samba

Now we'll have to add a few lines to the Samba configuration file /etc/samba/smb.conf to make everything work.

[global]
# The following property ensures that the existing files do not have their
# permissions reset to the "create mask" (defined below) if they are changed
map archive = no

# Notify upon file changes so that Windows can detect such changes
change notify = yes

# Configure shared folder for your user where "developer" is your Linux username
[developer]
comment = Developer Files
path = /home/shared
guest ok = no
browseable = yes
writable = yes
create mask = 0664
directory mask = 0775

Save and close the config file and then add a Samba user and password identical to your Linux user account.

sudo smbpasswd -a developer

Restart Samba so that the config can be re-read.

sudo service smbd restart

Your Windows host should now have access to the shared folder. To access the shared folder, open a folder browser and type in:

\\*ubuntu-local-ip-address*\developer (e.g. \\192.168.1.100\developer)

To find out what your local IP address is, got to your Ubuntu server terminal and type:

ifconfig

 

 

Simple CSS Parallax effect

Create a div block with class 'parallax'

<div class="parallax"></div>

Apply CSS code (use your own background image path)

.parallax {
min-height: 600px;
background-image: url("images/background.jpg");
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}

Apache2 - Configure multiple websites (virtual hosts)

1. Login to your Ubuntu Server, navigate to and list »sites-available« directory

cd /etc/apache2/sites-available 
ll

2. You should see the files:

000-default.conf
default-ssl.conf

3. Disable the default site configuration

sudo a2dissite 000-default.conf 

4. Create a copy of the default configuration file and open it for edit

sudo cp 000-default.conf yourdomain-com.conf 
sudo nano yourdomain-com.conf 

5. Enter the configuration (you can delete the comments) in this manner

<VirtualHost *:80>
ServerName yourdomain.com
ServerAdmin info@yourdomain.com

DocumentRoot /var/www/yourdomain.com

ErrorLog ${APACHE_LOG_DIR}/yourdomain.com-error.log
CustomLog ${APACHE_LOG_DIR}/yourdomain.com-access.log combined
</VirtualHost>

6. Save and exit the file edit mode

7. Enable the yourdomain.com site configuration

sudo a2ensite yourdomain-com.conf 

8. Be sure to create appropriate directory and set permissions

cd /var/www/
sudo mkdir yourdomain.com
sudo chown username:username yourdomain.com -R

(use your own Ubuntu Server username)

9. Reload Apache2 server

sudo service apache2 reload

Configure SSH to connect to a Remote Ubuntu Server

1. On your Windows machine I suggest installing Cmder console emulator, visit http://cmder.net/ and then download and install the Full package (with git-for-windows)

2. Open Cmder or other console software on your Windows machine, navigate to root directory, create .ssh directory and enter it

cd ~
mkdir .ssh
cd .ssh

3. Create SSH key pair id_rsa & id_rsa.pub (-t is type, -b is bytes, -f is filename)

ssh-keygen -t rsa -b 4096 -f id_rsa -C "email@domain.com"

4. Display the public key on the screen, select the printed text and copy it to clipboard

cat id_rsa.pub

5. Login to your Ubuntu Server and install OpenSSH in case you don't have it yet

sudo apt-get install openssh-server

Before you do that, don't forget to update the repositories with:

 sudo apt-get update

6. On your Ubuntu Server machine, navigate to root directory, create .ssh directory and enter it

cd ~
sudo mkdir .ssh
cd .ssh 

7. Create a file authorized_keys and open it for edit

touch authorized_keys 
nano authorized_keys 

6. Paste previously copied public key and paste it to this file

7. Logout from Ubuntu Server and try to login from your Windows machine

ssh username@192.168.1.100

(use your own Ubuntu Server root username & IP address)

8. If you're connecting to eg. GitHub via SSH, test your connection with this command:

ssh -T git@github.com

Copy public SSH key to your server

When you create SSH key pair on your computer, you can copy the public key to your server via terminal (console).

cat ~/.ssh/id_rsa.pub | ssh username@192.168.1.100 'cat >> .ssh/authorized_keys && echo "Key copied"'

Configure static local IP on Ubuntu Server

1. Login to your Ubuntu Server and check your networking

ifconfig
eth0 Link encap:Ethernet         HWaddr 00:0c:29:7c:05:22 
     inet addr:192.168.1.123     Bcast:192.168.1.255  Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fe7c:522/64 Scope:Link

2. Edit the network config file »interfaces«

sudo nano /etc/network/interfaces

3. You will see these two lines

auto eth0 
iface eth0 inet static

4. Change the lines to this configuration (don't mind the comments)

auto eth0 
iface eth0 inet static            #dynamic is changed to static
address 192.168.1.100            #your custom local IP
netmask 255.255.255.0             #same as on ifconfig Mask
gateway 192.168.1.1               #default local network IP
broadcast 192.168.1.255           #same as on ifconfig Bcast
dns-nameservers 8.8.8.8 8.8.4.4   #Google's DNS servers

5. Save the file and restart networking

sudo /etc/init.d/networking restart

6. Check your local static IP

ifconfig
eth0 Link encap:Ethernet          HWaddr 00:0c:29:7c:05:22 
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe7c:522/64 Scope:Link

7. Important: if you're doing this on virtual machine (VirtualBox, VMware), you may have to reboot

sudo reboot

Apache2 enable / disable sites & modules

Enable site (virtual host)

sudo a2ensite [filename.conf]

Disable site

sudo a2dissite [filename.conf]

Enable an apache2 module

sudo a2enmod [module_name]

Disable an apache2 module

sudo a2dismod [module_name]

Force reload the server

sudo /etc/init.d/apache2 force-reload

OR

sudo service apache2 reload
Newer posts →