Tuesday, April 17, 2012

Hosting Operating Systems

A simple and easy way to host an operating system is using virtualbox. Its a program that lets you host Windows/Linux over Windows/Linux. Basically it supports more OS but i have used only these.

Host -> Ubuntu

How to Install Guest Applications

Here you basically using Ubuntu and via virtualbox you have installed Windows. You can install some app (lets you see in full screen) by going to your virtual windows window and click on Devices(at the top) / Install Guest Applications. It will mount a disk there and you only have ti accept and install this. Reboot your system and you can see a full screen window.

Host -> Windows


How to Install Guest Applications

Sunday, April 8, 2012

OSI model

Basics about OSI model

Osi model is the current model that almost every PC uses to connect to the internet(another computer). It consists of 7 layers which are shown in the image below


  • The layer closer to the user is the first one at the top(Application layer). For example user can open an application like firefox or outlook etc. These applications are included in Application layer or (layer 7 in the OSI model).
  • After this we go to the Presentation layer whre basically we have our operating system. Everything that our operating system does for a connection in the internet its all done here.
  • In the Session layer according to the OSI model a session bettween our computer and server is created. Imagine a client and a server making a socket.
  • In the next layer named Transport layer its all about windowing. Information and packets sending to server etc.
  • In the Network layer there is everything our router do. Everything about our IP etc.
  • In the Data link layer there is our MAC address and maybe a switcher if we have) :)
  • Finally, in the physical layer there are all the parts we use to connect physically to the internet. This includes wiring router(as a device) etc.



















                                                                                                                  (image from wikipedia)


Further Connections

Rememeber that if for exemple you want to connect two computers in the same network(eg. les say in your home) you dont care about MAC address or router's address. You only need the IPv4 address of the two computers. The connection can established via SSH access, FTP or something else. It's on you! If you want to transfer files(eg. 4GB) and you dont have a good connection then its crap. This method dont work very well and its bery slow! On the other hand you can use a crosssover cable to transfer your data. Search in your local electronics shop for "crossover cable".

Change your DNS(local)

It's good sometimes to change your DNS hosts file so "noone" can go in AND out from your PC. What i mean is, when some bad guy wants to hack your PC and send info back to him. Well, this is not gonna happen if you hack your PC too with the following things. In Linux hosts file is located in /etc/hosts. So try open a terminal and cd to /etc. Then open with an editor, for example vim the file "hosts". Remember you need sudo password. You will see some addresses basically the loopback 127.0.0.1. You can add and edit this file with everything you want according to the following: DO NOT DELETE ANYTHING. Just add :)


<ip_address> <website>


for example you can write: 195.130.121.44 www.facebook.com. This part says everytime you write in your browser "www.facebook.com" it goes STRAIGHT to the address without looking anywhere else.


What we will do here is placing some website where we mostly go giving the loopback address. For example you can write:


127.0.0.1 www.facebook.com
127.0.0.1 www.google.gr
127.0.0.1 www.google.com
127.0.0.1 blah blah...


That was an easy way to protect a little more yourself!


Have fun :)

Collecting IP Addresses

With the following command you can output your Ipv4 protocol address(Linux-FreeBSD-Sunos):

#!/bin/sh
# Shell script scripts to read ip address
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Get OS name
OS=`uname`
IO="" # store IP
case $OS in
Linux) IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;;
FreeBSD|OpenBSD) IP=`ifconfig | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'` ;;
SunOS) IP=`ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2} '` ;;
*) IP="Unknown";;
esac
echo "$IP"

Saturday, April 7, 2012

Terminal Commands

System

  • uname -a            -- print system information
  • cat /etc/issue      -– current distribution and version
  • lsb_release -a      -– prints version information for the Linux release
  • date                -– shows the date
  • cal                 -– calculator 
  • fsck                -– File System Check

    Hardware

    • lshw                -- list hardware
    • lspci               -- list all PCI devices 
    • lspci | grep VGA    –- specific graphics card model 
    • hwinfo              -- short overview of all hardware & more detailed info 
    • lsusb               -- USB buses and attached devices

    Processor

    • cat /proc/cpuinfo   -– all processors, clock speeds, flags...
    • cat /proc/loadavg   –- processor load average for the last 1, 5, and 15 min 
    • top                 –- display Linux tasks 
    • uptime              –- current time elapsed since last reboot, users, and load average

      Memory

      • df -h               –- report file system disk space
      • du -sh <path>       –- estimate file space usage
      • cat /proc/meminfo   –- amount of RAM and swap, and how much is being used for what
      • free -m             –- total, used, and free memory shown in MB 
      • df -H               –- partitions, as well as their mount-points and usage in GB

        Drivers & Format

        • sudo fdisk -l       –- all partitions, their device names, and positions on disk

         
        * mount - Mount a Drive
        * umount - Unmount Drive
        * fdisk - Format Disk
        * dd - Dupliate Disk
        * df - Disk Free Space

        Networking

        • ifconfig            –- configure a network interface
        • iwconfig            –- configure a wireless network interface
        • ip addr             –- show / manipulate routing, devices, policy routing and tunnels
        • w                   –- output all currently logged in users and what they’re doing
        chkconfig - Check Activated Services
        * ping - Test Network Connections
        * ftp - file Transfer Protocol
        * host - Check IP of Domain
        * ifconfig - Configure Network Devices
        * netstat - Display Routing Table
        * route - Set Routes
        * telnet - Connect to telnet
        * traceroute - Display Route

        Packages

        • apt-get install/remove          –- install or remove a package
        • aptitude search <packagename>   –-search for a package similar to packagename
        • apt-cache showpkg <packagename> –- packagename’s version and dependencies


            Managing files

            • cp <file> <dest>    –- Copy
            • ls                  –- List
            • mkdir <foldername>  –- Make Directory 
            • mv                  –- Move
            • rm                  –- Remove
            • grep                –- Search for Text Strings
            • head                –- Display Start of File
            • less                –- Display Part of File
            • more                –- Display Part of File
            • tail                –- View the End of a File


            Users

            •  chgroup            –- change a user group

              chmod - Change Mode
              * su - Switch User

            passwd - Create Password
            * groupadd - Add a Group
            * groupmod - Modify a Group
            * chgrp - Change Group
            * groupdel - Delete Group
             

            Other

            • awk                 –- pattern scanning and processing language
            • alias               –- declare symbolic aliases for perl data
            • lshal -m            –- monitor for hardware changes

            Tips

            • sudo lshw -html > your-file-name.html
            • man everything :)

            file - typechecking of one or more ps - the ultimate system monitor for command line - also good for scripts
            * cat - print out a file in the command line

                Format your PC and start using Linux

                Below there is a list of nesessary programs need to be installed after a "fresh" format into Linux(eg. Ubuntu/Linux distribution).

                • Open Office (installed)
                • Libre Office (not installed)

                • Ssh (installed)
                • Xampp Server (not installed)
                • Filezilla (not installed)

                File permmissions

                You must keep in mind Linux is designed to be a multi-user environment. In an environment with more than one users(like Linux), it is crucial to have a secure system for deciding which files are yours and who can fiddle with them. So, file permissions are defined separately for users, groups, and others as following:

                User: The username of the person who owns the file. By default, the user who creates the file will become its owner.

                Group: The usergroup that owns the file. All users who belong into the group that owns the file will have the same access permissions to the file. This is useful if, for example, you have a project that requires a bunch of different users to be able to access certain files, while others can't. In that case, you'll add all the users into the same group, make sure the required files are owned by that group, and set the file's group permissions accordingly.

                Other: A user who isn't the owner of the file and doesn't belong in the same group the file does. In other words, if you set a permission for the "other" category, it will affect everyone else by default. For this reason, people often talk about setting the "world" permission bit when they mean setting the permissions for "other."

                That was the categories where you set permissions. The following are THE permissions and they are defined separately for the file's owner, group and all other users.

                Read permission. On a regular file, the read permission bit means the file can be opened and read. On a directory, the read permission means you can list the contents of the directory.

                Write permission. On a regular file, this means you can modify the file, and write new data to the file. In the case of a directory, the write permission means you can add, remove, and rename files in the directory. This means that if a file has the write permission bit, you are allowed to modify the file's contents, but you're allowed to rename or delete the file only if the permissions of the file's directory allow you to do so.

                Execute permission. In the case of a regular file, this means you can execute the file as a program or a shell script. On a directory, the execute permission (also called the "search bit") allows you to access files in the directory and enter it, with the cd command, for example. However, note that although the execute bit lets you enter the directory, you're not allowed to list its contents, unless you also have the read permissions to that directory.

                You can view the access permissions of a file by doing the long directory listing with the ls -l command.

                $ ls -l 
                The first character can be any of these(type of file):
                d = directory
                - = regular file
                l = symbolic link
                s = Unix domain socket
                p = named pipe
                c = character device file
                b = block device file

                For each file you can add the following:
                r = read permission
                w = write permission
                x = execute permission
                - = no permission