Adjust Linux/Debian resolution in Vitual Machines

I was installing Debian on VMware and there encountered a problem with the resolution of the OS using it virtual. The resolution of the Display was not matching with the resolution of the screen, which was 1920×1080. I checked the Display application of Debian, not much use, I found. Then to the resolutions in the Virtual Machine Settings, again no much improvement. After going through the xrandr command of Debian, it was found helpful.

Copy the following lines of commands and paste it in a file with .sh extension and save it in any Directory, to make it ease put it in the Desktop.

xrandr –newmode “1920×1080”  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
xrandr –addmode Virtual1 1920×1080
xrandr –output Virtual1 –mode 1920×1080

I have used 1920×1080 because that was my system resoluton. You can replace the value by the value which you would like to have your screen adjusted to. Now, open the Terminal and type in the command to change the working directory to the location where you have saved the file.
cd /home/user/<Directory>
If the file is saved in Desktop, type in  cd /home/user/Desktop/
Then type
chmod +x <filename>.sh
Followed by:
./<filename>.sh

After the execution, the resolution is to be adjusted to 1920×1080. Least probably, there can be a chace that you hace to execute the last statement each time you turn on your Vitual Machine.
This method can be used for all Dedian Distributions like Ubuntu, Linux Mint, Discreete OS, Kali Linux and so on.

Installing applications on Linux

Formats

Linux uses some common formats to distribute software. The most common formats for the average Ubuntu user are:

  • Debian packages(.deb)
  • Tarballs
  • Redhat packages(.rpm)

Debian packages (.deb)

Debian Packages are the most common format you will encounter when installing software in Ubuntu. This is the standard software packaging format used by Debian and Debian derivatives. All of the software in the Ubuntu repositories is packaged in this format. Synaptic Package Manager, Add/Remove Applications, Aptitude, and apt-get handle the transaction with the repository behind the scenes.

Tarballs

Tarballs are a large collection of files assembled into a single archive file. The “tar” command is used to combine many files into a single file for archiving or easy distribution. The “gzip” command is used to compress the size of a file so that it takes up less space. A tarball is very similar to a .zip file on Windows, or a .sit or .dmg file on Macs.

Tarballs have extensions like “.tar.gz”, “.tar.bz2” or “TGZ”. Most of the time, a tarball contains source files and/or binary files. In the open source community, they are used to distribute source code. If you find any software with a .tar.gz appendix, you will need to uncompress it by double clicking on it before installing the software it contains.

Source files

Source files are nothing but raw code which requires compilation to work, while binary files are like .exe files which are ready to install.

RPMs

The Red hat Package Manager or .RPM format is specifically designed for easy installation and management of software packages. The format allows you to automatically install, upgrade and remove software packages. It tracks dependencies — situations where one package requires another package in order to work correctly — and will not install software if it depends on another package which is not installed.

There are also binary files which can be directly run and they come in the format .din

INSTALLING PACKAGES

APT For Debian based distributions, like, Ubuntu, Linux Mint etc.

The APT is the tool, commonly used to install packages, remotely from the software repository. In short it’s a simple command based tool that you use to install files/softwares. Complete command is apt-get and it’s the easiest way to install files/Softwares packages. This easy tools informs you about packages that are currently being installed and also it informs you about the packages that are available in repositories.

apt-get install ${packagename}

To remove/uninstall any software, just use remove

apt-get remove ${packagename}

The software packages are somewhere in the online repositoies, APT handles a local database on the user’s hard drive that contains informations about the available packages and where they are located. So when the types the command, apt-get install conky, the APT will start finding the package named conky in the database and will install conky once user types ‘y’ (yes). To get the all newly uploaded packages on the repositories, user need to update APT regularly.

To update APT database:

apt-get update

To update the APT database and also upgrade the security updates and patches that might be available for some installed softwares, users may do it at once just by using the commands like this:

apt-get update; apt-get upgrade

And remember all of the package management tools I am discussing, will need user to be in root or superuser, for example to install software in debian based distributions you will use apt-get followed by sudo then It will ask you to enter password.

sudo apt-get install conky
sudo apt-get remove conky
sudo apt-get update

Install Software in Linux, Ubuntu, debian

Insert password to install any package

yum: For RPM based Linux distributions, like, Fedora, Red Hat

You will not have any trouble understanding yum because its same as apt-get. As ‘apt-get’ installs software packages for Debian packages, like that ‘yum’ installs software packages for RPM packages. It can also like apt-get download and install packages from a repository.

Yum install ${packagename}

To remove software packages, just use remove

yum remove ${packagename}

There is one thing to note that yum does not keep a local database by default in user’s hard disk. So there is no need to update it. But to install available security paches and bug fixes, use the following command:

yum update

If user wants to update any single package then do it in the following way:

yum update ${packagename}

Tar Balls

Tar ball files usually come in the formar .tar.gz or .tar.bz2. To install a file that comes in the above formats, firstly change the current working directory to there the package is placed using the cd command.

          cd /home/userName/path

You are not “installing” a .tar.gz file or .tar.bz2 file. .tar.gz files are gzip-compressed tarballs, compressed archives like .zip files. .bz2 files are compressed with bzip2. You can extract .tar.gz files using:

tar xzf file.tar.bz2

Similarly you can extract .tar.bz2 files with:

tar xjf file.tar.bz2

If you would like to see the files being extracted during unpacking, add v:

tar xjvf file.tar.bz2

The parameters are x to extract files, z to filter through gzip for decompression (leave this off if the file does not have a gz extension), v for verbose mode so you can tell what’s going on, f indicating there will be a filename to follow.

(If you are extracting a file named a.tar.gz, then another extracted file will be created in the same directory in a folder named a)

Further, the installation can be done by getting into the directory to the the extracted file is  placed and then type down ./configure in the terminal.

EXECUTING A .run or .bin file

.Run or .Bin files are probably the only file types you will ever need to mark as executable in normal use of Ubuntu. There are two ways to execute them (which usually installs something), either in the terminal, or graphically (which usually relies on the terminal somewhat as well). 

First, open the Terminal, then mark the file as executable with the chmod command.

        chmod +x file-name.run

Now you can execute the file in the terminal.

         ./file-name.run

If an error message including a problem such as ‘permission denied’ appears, use sudo to run it as root (admin). Be careful, sudo allows you to make critical changes to your system. Many software installs will require sudo. 

          sudo ./file-name.run

Create a Bootable USB

​Creating a bootale usb in Linux is much easier than that in Windows.

First what you need to have is the iso image of the OS which you wish to install, which can be either downloaded from the internet. In case you do not have an iso but you have the setup files, in the sense all the files that are to be included in the iso, then you should create an iso with those files.

  • In ubuntu or anyother Linux distros, it can be done the following way:Select all the files to be included in the iso image and right click and then select Compress
  • A window apppers asing for the location and the type of the compressed file. There you select .iso and click ‘Create’.
  • It is done

Now, after you have the iso image ready, place it in an accessable directory. To simplify the case, lets put it in the Desktop. Then folow the steps,

  • Open the terminal (Ctrl+Alt+T).
  • Type in 

    sudo fdisk -l.    

This command will give you the list of all the harddrives connected to you PC and there you can can find out the name of your flash drive. It will be in the form /dev/sdb<?>

  • Then change the working directory to the location where you have placed the iso. Here we are in the Desktop. So, type in cd Desktop/. (In general, cd /home/userName/path)
  • sudo dd if=iso_name.iso of=/dev/sdb/<?>

Here, iso_name refers to the name of the iso which you want to write to the flash drive and /dev/sdb<?> is the name of your USB/flash drive.

  • Wait for a few minutes till the process is completed. When completed successfully, few messages will be displayed. Later you can reboot your PC to install the OS.

In windows, there are applications like rufus which is a very small and effecient portable application which allows you to boot a USB Drive.

LOCK OR UNLOCK A PC USING USB

If you prevent access to your computer with just a password, you are missing out on an alternate (and more secure) way to lock down your computer.

Predator, a free Windows program, turns your USB drive into a key that locks your computer when it’s removed. To unlock your computer, you’ll have to plug the USB drive back in. (Talk about having secret-agent-style security.)

Anyone who attempts to access your computer without the USB flash drive will be hit with an epic “Access Denied” message. To get started, follow this guide:

Step 1: Download and install Predator.

Step 2: Once Predator launches, plug in your USB flash drive. None of the contents of the drive will be deleted or altered in any way, so feel free to use your primary thumbdrive.

When you insert the drive, a dialog box will appear asking you to create a password. Click OK to continue.

Step 3: In the Preferences window, take note of a few key settings. First, enter a secure, unique password in the “New password” field. If you lose your USB drive, you’ll use it to unlock your computer.

If you’d like, you can check the Always Required box and you’ll be asked to enter the password each time you use your thumbdrive to unlock your PC.

Finally, in the section under Flash Drives, ensure that the correct USB flash drive is selected. When you’re done, click “Create key” and then OK.

Step 4: Predator will exit. When it does, click the Predator icon in the taskbar to restart the program. A few seconds later, the icon will turn green, alerting you that Predator is running.

Every 30 seconds, Predator will check to see that your USB drive is plugged in. If it isn’t, your computer will dim and lock down.

Here are some extra tips:

To pause Predator at any time select “Pause monitoring” from the taskbar menu.If someone tried to access your PC while it was locked down, you’ll see the activity log when you log back in. You can see the log at any time by clicking “View log” from the taskbar menu.Predator’s Web site has several cool how-tos, including one that shows you how to program your computer to take a snapshot each time someone tries and fails to log in to your computer. Check it out.

One obvious flaw comes with this setup: you’ll always be down one USB port. But if you’re sold on Predator, consider purchasing a USB hub to compensative.

CREATE A BOOTABLE USB

Using command lines:

1. On Linux/Ubuntu Terminal

sudo umount /dev/sdc<?>

sudo dd bs=4M if=input.iso of=/dev/sdc<?>
where input.iso is the input file, and /dev/sdc<?> is the USB device you’re writing to. <?> is a number. Look it up.

2. On Windows CMD

•Insert a USB flash drive and open CMD
•Type ‘diskpart’ and hit Enter.
•Wait for a while until the DISKPART program run.Type ‘list disk’ to view active disks on your computer and hit Enter. There would be seen that the active disks shown as Disk 0 for hard drive and Disk 1 for your USB flashdrive with its total capacity.
•Type ‘select disk 1’ then hit Enter.
•Type ‘clean’ and hit Enter to remove all of data in the drive.
•Type ‘create partition primary’ and hit Enter. Creating a primary partition and further recognized by Windows as ‘partition 1’.
•Type ‘select partition 1’ an hit Enter.
•Type ‘active’ and hit Enter. Activating current partition.
•Type ‘format fs=ntfs quick’ and hit Enter.
•Type ‘exit’ and hit Enter.

Else you have windows applications like rufus which is a utility helping you to create a bootable usb using iso images.
On linux you have built in application, usually.

INSTALL VMWARE ON LINUX

Here, I am talking about Kali Linux. The same steps can be followed for any latest versions of Linux distributions. Update your Kali Linux and Install Required Packages for VMware Workstation

1. Login into your server as root or non-root user with sudo privileges and run the following commands to keep your system up-to-date. Related Article  How to Install Kali Linux 2.0 Sana in VMware Workstation Step-by-Step Guide

apt-get update && apt-get upgrade -y

2. Run the commands below to install required packages for VMware Workstation to run properly.

apt-get install build-essential linux-headers-`uname -r`

Download VMware Workstation Binaries

1. Download the VMware Workstation software binary from VMware official site. You will download script file like “VMware-Workstation-Full*.bundle”, by default this installer script file downloaded without execute permission, so you will need to give it in later step.

2. Go to the directory which contains the VMware Workstation binary file. File looks like “VMware-Workstation-Full*.bundle”.

3. Give execute permission for this installer file.

chmod +x VMware-Workstation-Full*.bundle

Next, run the command below to begin the installation of VMware Workstation inside Kali Linux 2

./VMware-Workstation-Full*.bundle

Once the installer is running, you see the following window the screen. Accept the license agreement to continue. After installing, go to Unity Dash and launch VMware workstation.

Done

CHANGE MAC ADDRESS

Changing the MAC Address..

On kali linux:

1. Open your terminal, and type

ifconfig | grep HWaddr

 You will the original MAC address

2. To temporary change our MAC address, we need to turn off the network interface first by running this command

ifconfig eth0 down

3. After that we can configure the new MAC address

ifconfig eth0 hw ether 00:00:00:00:00:02

you can change the MAC address using this hexadecimal format XX:XX:XX:XX:XX:XX

4. Now we can turn on the network interface again.

ifconfig eth0 up

5. And the last we can check again our MAC whether it’s change or not.

if we follow until this step, MAC address will back to default after we restart our machine. Go to next page to view how to change MAC address permanently.

6. Kali Linux was built based on Debian. In Debian all the network interface was located on /etc/network/interfaces.

7. We will configure the /etc/network/interfaces. In this tutorial I will use pico text editor, but you can choose any of your favourite text editor.

pico /etc/network/interfaces

8. Now we will add one line of script to change our MAC address permanently

pre-up ifconfig eth0 hw ether 00:00:00:00:00:02

9. If we want to restore the default MAC address, just add the # sign in front of script in step 8.

#pre-up ifconfig eth0 hw ether 00:00:00:00:00:02


SETTING UP C IDE

C-Language

The C programming language is one of the most popular and widely used programming languages. It is a general-purpose programming language and there are very few computer systems in existence that are not set up for its use (i.e. where a C compiler does not exist).

Here will see how to set up a C IDE.

ON WINDOWS

Dev C++ is an open source C/C++ compiler that is one of the most user friendly and effective development environment and compiler. It can be downloaded from source forge or from bloodshed.

• Download the setup file from any of the above links or from somewhere it is feasile.

• Install it and open the IDE. Click on ‘New project’ from the menu File to the top left.

•Type in your code. Next comes the task of saving the source code in c source format. Give it a name and from the drop down menu which appeares in the save window select ‘c source file’ and then click save.

•After saving, click on the compile button from the menu or press F9. If there are no syntax errors in your code, the program will be compiled amd will be set ready for execution.

•To execute it click on ‘Run’ or press ‘Ctrl+F10’. It is done for now.

ON LINUX

Linux based distributions like ubuntu, kali etc usually come pre installed with GCC(GNU Compiler Collection). It is used for compiling C/C++ source codes. To check if your Linux has gcc installed, type in the Terminal,
gcc -v

If yes, it will gove you details about your version and so on. Else you can follow the method given to get it installed. Type the commands corresponding to your Linux distribution.

On CentOS/Redhat
yum install gcc gcc-c++ autoconf automake

On Debian
sudo apt-get install build-essential

Now you have the compiler installed. One aother method is to install ‘Wine’ which is a software in Linuxbwhich enables Windows applications to be run on it.

  • If you are using a 64-bit Architecture, then enable 32-bit for better compatibility
    sudo dpkg --add-architecture i386
  • Add the repository: sudo add-apt-repository ppa:wine/wine-builds
  • Update your Repositories: sudo apt update
  • Then install the version of Wine you wish to use:Based on Wine Development (Testing Stage) (eg: 1.9) – sudo apt install wine-develBased on Wine-Staging (Bleeding Edge) (eg: 1.9.1) – sudo apt install wine-staging

    Lastly run:
    export WINEARCH=win32 andwinecfg in the terminal to make sure it configures Wine correctly (In that order). You will also need to install winetricks (Another configuration package, really helpful for installing Windows components like .NET Framework and other needed libraries). So after this, please do:sudo apt install winetricks

Alright. No let us see how to run a c program on Linux.

• First of all open any text editor and type in your source code and save it to a directory(let us take Desktop) with the extension .c

• Then, open Terminal(Ctrl+Shift+T or from the appilcation menu). Change the workind directory to the location where you have saved the program. Since here it is Desktop, type:

cd Desktop/

• Again type gcc [<program_name.c>] This will compile the source code and if there are any errors in the code, error messages will be displayed in the screen. Else a new executable file will be generated in the same directory where you are working now with an extension .out .

• If the program was compiled successfully then type ./<executable_program_name>.out

That’s all.
ON ANDROID

There are many android applications which helps in compiling C/C++ programs on Android devices. You can have detailed explanations here.

Hope it worked.