Showing posts with label Computer Science. Show all posts
Showing posts with label Computer Science. Show all posts

Tuesday, May 7, 2013

Spam: Stupid Pointless Annoying Messages?

Spam: Stupid Pointless Annoying Messages?
I meant to post this as part of the post on AI, but I felt that some of this information fell out of the scope of that post. So, why the post on spam? Well, it something all of us has run into in some way and it makes a wonderful case study, as you are about to find out.

I’m sure most of you have at one time or another looked at you inbox, found the countless spam messages, and though “why?”. What could these spammers, who go to such extreme lengths as to compromises other’s computers to add to their bot-nets, possibly hope to gain? Well, like most things, it boils down to money. Garry Pejski has an interesting DEFCON presentation on his time as a malware developer. Some reputable company, say GM or IKEA, will want to advertise their product or service in the hopes of attracting more customers. Another reputable middleware company, say Google, creates ads for these companies for a price and offers others a cut of this money if they display these ads on their website or product. Here’s the problem, some unscrupulous individuals look to capitalize on these offers by having others view as many of these ads as possible, whether they would actually buy any of these products or not.
There are other reasons why spammers are doing what they’re doing. Some could be trying to perform a phishing attack. But, here a more interesting case, also coming out of DEFCON, by Grant Jordan on the use of spam to affect the stock market. A spammer buy a stock, spams others to buy that stock, and then sells when it hits its height. Some interesting things brought up in this study: similar looking ads came from same spammer and would usually perform the same. Also, due to the advent of spam catching techniques, text based spam never worked.
Spam filtering is actually a highly intellectual field of computer science. It relies on computer learning, but there are two ways it can be preformed, using classification in the case of supervised learning or using clustering in the case of unsupervised learning. Both use features of a message (tokens that occur, number of capital letters)to add it to a group with similar features. In the case of classification, training data provides examples of the groups (spam and non-spam), while clustering uses input data to define groups and may only require the number of clusters to start the algorithm.

Monday, April 1, 2013

Artificial Intelligence: Finding Ourselves

I suppose you’ve heard of Watson, the Jeopardy playing robot. It’s a great case study for artificial intelligence. Watson has an almost limitless amount of information at its disposal (several terabytes). But, yet it gets things wrong. How is this possible? Consider the question “Its largest airport is named for a World War II hero; its second largest for a World War II battle”. Watson’s response: “Toronto”. Watson kind of works like a search engine, it gives a weight to key words in the question and the categories. It makes adjustments based on previous answers and produces a set of results it chooses from. So, it does a search for airports, people in WW2, battles in WW2, and cities. Then it combines, weighs them appropriately and produces an answer. The answer was probably right, but not “right”, the game show is US based and therefore a US answer is more likely.

The problem is universal to computers, they lack the basic assumptions you and I have. When I say a person X is dead, people understand what that means, a person that is dead is no longer animated and will always remain dead. But if you tell a computer that (say, in Prolog) it doesn’t understand that, I just assigns “person X” the value “dead”. Computer learning can help, but as with Watson, it can’t make this problem disappear.
One of the greatest problems facing the field of artificial intelligent is figuring out how to determine intelligence. One of the early computer scientists interested in this question was Alan Turing, who proposed the Turing Test. The idea was, essentially, if a person, through conversation, could not differentiate between a computer and a person, that computer was capable of thought.

An interesting aside about Alan Turing. Although a brilliant scientist, he was sentenced to chemical castration for being a homosexual as was the law in Britain during the time. Unable to live with the treatment, he committed suicide by ingesting an apple laced with cyanide. Rumor is, Apple’s iconic logo is in tribute to Alan Turing’s contribution to the field of computer science.
Back on track, there are several problems with the Turing Test. In practice, human judges become too suspicious and end up actually rating several humans as bots. In theory, there is the Chinese Room. In this theory, a man sits in a room with a book with responses to Chinese symbols. Chinese characters are passed to the man in the room and, after consulting the book, the man jots down the response and passes it out of the room. The theory holds that even though the outside observer may believe the box to know Chinese, the man inside the box does not actually “know” Chinese. Similarly, a computer just follows instructions (a program) and can never really “know” things.
Well, it’s an interesting view, but lets take the example a little further. The book that our man would be consulting would be very large, it would need to responded to every inquiry one could make in Chinese. Our man is only doing the simple work of finding and responding. Essentially our book plus man combo, and not the man alone, would be able the Turing Test.
Perhaps the problem isn’t the question we’re asking, but rather understanding what we’re trying to find in the first place. Perhaps the question should be: What is consciousness? It’s a question philosophers have grappled with for some time. Some define it as self awareness, emotions, or, if you’re religious, a soul. The best way that I have found to describe it is “our first person perspective”. When your body experiences something, your body does not just respond with a reflex “you” feel it. This raises some interesting questions. How do we know others are conscious, are they intellectual zombies? Are animal? Babies? Those that have undergone brain damage? How can we tell if a computer has gained a consciousness?
If a computer did become conscious, how would people react? Looking at popular fiction, some might accept it, as in Neuromancer, others may look to prevent it’s existence, as in Ghost in the Shell. Perhaps some would react in disgust, knowing that something exists like you but “different”. That is certainly the case of the Uncanny Valley.

Thursday, March 28, 2013

The Power of C in the Cloud

In my last post, I introduced you to the cloud IDE Codenvy. The primarily reason I used it is because it has a simply way to hook into Google App Engine. However, for a more robust cloud IDE, I would recommended Compilr. Compilr has support for many of the languages Codenvy does (Ruby, Java, PHP, Python) but it also has support for Objective-C and C# as well as low level languages like C and C++.
That last point leads to some interesting results. Because we have access to such low level languages, we can use the Compilr servers for general computing. From what I can tell, the Compilr servers that execute the code are running a Unix-like operating system on x86 hardware. So if you’re in a pinch and need access to a Unix like environment, Compilr can be very useful. I happened to run into such a situation while trying to make use of WoLF PSORT for a rather long sequence and lacking the necessary Linux PC to compile and run the program locally.
So, how do you execute commands on commands on Compilr’s servers? First, create your C++ project. Your program will be run in the “content” folder of your project so if you have any external files you need, place them there:
 

If you get an error message when uploading, but you also get “Upload complete”, you upload has finished. Refresh the page for the files to show up in the project panel.

The key to our program is the system function. Simply hand it commands to execute and it will do so. To untar our WoLF PSORT file execute the following:
system ("tar -zxf WoLFPSORT_package_v0.2.tar.gz");
Remember to mark the files for execution if nessessary:
system ("chmod 777 ./WoLFPSORT_package_v0.2/bin/psortModifiedForWolfFiles/psortModifiedForWoLF");
There are a few restrictions Compilr has placed on free accounts.
First, you are forced to make public project and you are restricted to 50 builds/runs. These aren’t huge problems and you can always create a new account and port code if you go over 50 builds. In fact I have noticed the build counter often reset after refreshing the page, so this never became an issue for me.
Second, you are limited to 4000 characters of output. A very simple solution, pipe output into a log file by appending > log.txt to your command:
system ("./WoLFPSORT_package_v0.2/bin/psortModifiedForWolfFiles/psortModifiedForWoLF -t ./WoLFPSORT_package_v0.2/bin/psortModifiedForWolfFiles/all.seq > log.txt");
You may also need to pipe errors and warning, in which case you can log to the same file by appending >log.txt 2>&1 to your command. Or you may wish to disable errors and warnings completely while still capturing output, in which you would append the following 1>log.txt 2>/dev/null .
Third, if your program has not accepted input in 40 seconds, it will be terminated. This requires a tricky work around. I ended up spawning a child process to accept input while the parent process was busy. The child process will send an alert for input every 30 seconds. If you choose to do something similar, remember to flush stdout before sleeping. The syntax is as follows:
fflush(stdout);
sleep(30);
Interestingly, this method triggers a security measure when one process exits before the other and will terminate the program. So make sure no process exits before your program has finished doing it’s work.
Some final points about Compilr:
Much like Codenvy, Compilr has issues with Internet Explorer. I managed to get it working in Firefox.
The first compile of every session will fail with “Lost connection to server”. Simply use a dummy application to trigger it and continue your work. If you run an application that takes a long time and it loses connection, it could block you from running further applications until it finishes.
Always backup your progress! I can’t stress this enough. If the server that stores the code loses connection to the server that runs the code while “Syncing application data”, you can lose large chunks of your work.
Finally, I’ve attached some sample code on the download website.

Tuesday, March 26, 2013

Programming with Java on Google App Engine

I wrote a draft post about Google App Engine many moons ago when it was Python only. As I’m not a Python man, the post isn’t very technical. Anyway, things have changed and GAE now supports Java. Albeit a customized subset of Java, which I’ll go into later.
Google App Engine is a cloud computing service: run your programs on their servers and pay by CPU usage. It’s similar to Amazon’s EC2 and Microsoft’s Azure, but unlike them in there is an absolutely free trial. You’re only required to provide a telephone number when signing up.
Step 1: Create the proper account
Sign up for a Google account here and a Google App Engine account here. After the GAE account is created, you should be prompted to create a new Google App Engine ID.
Now, if you’re like me, I won’t want to have to download and install the various SDKs and IDE to make your GAE app. So, I suggest Codenvy. Be sure your logged in to your Google account and click “Connect with Google”. Be sure you’re not using Internet Explorer, Codenvy seems to have issues with it.
Step 2: Create a project
On the welcome screen, choose “Create a New Project From Scratch”

Choose  Java Web Application (WAR) -> Google App Engine

You have to select the sample project, but you can skip using the JRebel plugin.

Use the Google App Engine ID you just created.

Step 3: Clear out the sample code

Click the project tab in the left menu (next to the Package Explorer tab)
Delete the src\main\java\com folder.
Delete the src\main\webapp\display.jsp file.
Open src\main\webapp\WEB-INF\web.xml and empty the “servlet” and “servlet-mapping” items. You can add java code to the src\main\java folder at a later time and add the proper information in these tags to specify it as a servlet.
Add the following in the “web-app” item after the “servlet-mapping” item:
<welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
Open src\main\webapp\WEB-INF\appengine-web.xml and make sure the “application” has enclosed your Google App Engine ID
 Customize src\main\webapp\index.jsp as you wish.
Step 4: Run your app on Codenvy servers
Make sure you save! Codenvy does not auto save changes when building.

Run -> Run Application

Step 5: Load your app into Google App Engine:
Make sure you save! Again, Codenvy does not auto save changes when building.
Go to Project -> PaaS -> Google App Engine

Select Application Update


If you get an Oath token error:

PaaS -> Google App Engine -> Logout

PaaS -> Google App Engine -> Login

Also, see this link for setting up cron jobs.

Thursday, August 2, 2012

Technological Singularity: an Unrecognizable Future


Do you ever feel like technology just moves too fast? I’ve already posted on how technology has past me by in many ways. But there might be more to it than people falling behind current trends. There’s the idea of a technologic singularity.

The technological singularity is an event in the future when technological progress becomes so rapid that it makes the future “different”. Central to this concept is the concept of accelerated change: technologic breakthroughs allow the next technologic breakthrough to occur sooner and easier. For instance, our technologic improvements in computers have allowed us to study genetic data faster and advanced our knowledge in genetics.



(Ignore that calculations per second, they are a poor measure of intelligence)

Some interesting consequences occur. As we build faster computer and create better algorithms, it allows us to create faster computers and better algorithms. But, that’s really all just an evolutionary trend, when our computers reach a high level of AI it will become revolution. It will be a paradigm shift: a social change so large that will occur and a new generation will be created.

And after the singularity? We will be able to construct machines smarter than us. And in turn, we will become more intelligent. We will become something else.

Before I finish, I would like to recommend The Gentle Seduction by Marc Stiegler as a look at what our future may become.

Sunday, April 29, 2012

Web development: HTML, PHP, and SQL


First thing’s first, lets set up our environment. My IDE of choice is Netbeans, but that’s of little consequence. Next, install your PHP stuff. Later down the road, when we use MySQL, these tools will make yourlife a lot easier. In your php.ini file uncomment - extension=php_curl.dll to activate curl.

This post will tell you how to set upyour project. The easiest thing to start with is how to scrape a feed, basically cut and paste, see here. Quick posts to brush on your PHP:






Now let’s tap into Google APIs. Sign up for your Google License Key. Read how to use the Google API here and here. The Google News API is similar.

Next API were going to use is Twitter, well technically 3 Twitter APIs. The first is to get trending topics, seehere. Next, twitter searches, similar to Google’s search API, but you don’t need a key, see here. The third is a bit trickier, see here for help. Basically download Abraham's TwitterOAuth library add it to your project and go to http://dev.twitter.com/apps, register your app and get your keys.

Now before we jump in and start using SQL, I feel it’s important that you keep in mind the scope of your project. If you simply want to store a small amount of information with no respect to order, you might consider plain text. There’s a certain cost to setting up and maintaining a database and it may even hurt performance if you are just doing a simple project.

OK, ready? Start your server. Open up MySQL Query Browser. Right click on a Schema, create a new one or use a default, and create a new table. Now, let’s connect our new table to our PHP, see here. We’ve been getting json objects for our searches, so let’s store those in the database. For help see here, here, and here. I managed to get away with just using serialize() and mysql_real_escape_string() but not addslashes().

And there you have it. You are now the proud creator of a web application.

Thursday, January 19, 2012

Open Source Software: Doom and Gloom

A few years ago there was a rumor that the Linux Hater's Blog was being abandoned. I took the opportunity to read through his old post. Most of his posts were filled with immature rants and filled with swears, but he had a genuine point at times.

Open source software may not cost you any money, but poorly designed software will cost you time and effort. I have seen more than my share of dropped projects; projects that start out with a small team that slowly erodes away until that last person leaves up a “Thanks for all the fish” post.

The greatest evil of OSS is probably fragmentation. The mantra of OSS source software has always been freedom of choice. And it’s good if you’re a consumer trying to pick a media player or web browser, but it is hell for software developers. Each distro has a different set of libraries and a different kernel and a different set of binaries. Your software might work on distro and not on another at any given time. That’s one of the reasons companies are so afraid to make software on linux, they have no clue what libraries they can support.

I recently found out about the Linux Standard Base, who are attempting to standardize binaries across distos. However, the LSB has failed, to a certain extent. The LSB doesn’t have the influence over the distros that they need. How many distos are going to listen to the LSB and use older binaries for compatibility when they can update to the latest and greatest?

Check out what distros the LSB has certified:


Ubuntu: the latest release certified is 9.04, which is no longer supported. 8.04 (LTS) is also certified, but support ends next month. And having used an LTS this late in this life cycle, I can tell you, they are unusable.


Mandriva: the last desktop version certified is from 2006 (2007.0)!

SUSE: version 11.0 is no longer supported.

Debian: not certified at all.

Fedora: not certified at all.

Mint: not certified at all.

Congratulations Linux Standard Base, you’ve managed to standardize a bunch of Linux distros no one is running!

But that’s not to say OSS is the only software affected by these issues. Let me illustrate it with an example. Before Microsoft released Vista it was codenamed Longhorn and it was a much grander undertaking than the released product. There were, what Microsoft called, the “3 pillars of longhorn”; 3 key technologies that would form the backbone of the finished Longhorn. One of these pillars was WinFS which called for all the files on a computer to be stored in a database. For those less technically minded, this was a big deal and allowed for some neat things to be done.

At the beginning, everything seemed to be going fine; Microsoft released multiple preview releases of Longhorn and, with the exception of the normal bugs, everything was moving along. Then nothing was released to the public for several months; no preview builds, no progress reports, nothing. One day, Microsoft announced that they would be releasing WinFS after Longhorn’s release and would be porting the other 2 pillars back to XP. The reason was, they simply bit off more they could chew, they kept on adding more and more features, they had to eventually crunch bugs and make a release. In the end it WinFS was further delayed and then outright canceled.

At the same time, linux had a similar open source program: Gnome Storage. Like WinFS, it planned to put every file on a computer into a database for organization purposes. What happened to it? Well, it was abandoned. It was done almost entirely by a college student, maybe he graduated, maybe he got a job, maybe he just was no longer interested in it anymore. The end result is Gnome Storage is in a perpetually unfinished state.

Two separate project failed for entirely different reasons.

Monday, May 30, 2011

My Favorite Programming Language

Having spent some time on technical message boards, I've seen this topic pop up a lot. “What programming language should I learn?” “What language is the best for beginners?” “What’s better C#, C++, or Java?”

When I was in high school, I was taught a stripped down version of C++ that avoided a lot of the Object Oriented concepts. When I went on to college, Java was emphasized in the intro courses and then C in high level courses. There were those courses that would force you to learn some eclectic language (x86 assembly, Scheme, Prolog). Outside of the mainstays, I’ve also run into C#, SQL, PHP, and HTML (which are not programming languages and, rather, scripting languages).
As far as what language you should learn first, in my opinion it really doesn't matter. As long as you go on and learn more about programming, your first language is going to affect you all that much. All programming languages have their pros and cons and one may solve a specific problem better than the other, but at the end of the day, it really won't matter which one you choose.
C is much simpler than a higher level language like Java or C#, however it can be less forgiving than them as well. Java gives you nicer errors whereas C relies on the programmer to catch a lot of those dumber mistakes like running over the bounds of an array. Some of that can be solved using the right IDE (Visual Studio is very good in my opinion).  C# and Java introduces Object Oriented concepts, which can be too complex for first time programmers and can add unnecessary bulk to smaller projects. I’ve also heard that Java’s garbage collection can be extremely cumbersome, as a CPU heavy task that pops up at random intervals.
Nothing beats being taught in a formal course, but here are some learning resources I would recommend:

The first is A Guide to Programming in C++. This is basically baby’s first programming book. It will hold your hand the entire way. We’ve all got to start somewhere and if you’ve never taken a formal class in programming this is the book I would recommend. The book is a little old, so, you’ll need to do a few tricks to get code to run on current versions of visual studio.

Java Concepts is a great Java introductory book. It will introduce you nicely to object oriented concepts. If you read some of the later chapters,  it will also touch on some of the higher level concepts in computer science.

Next is Computer Systems: A Programmer's Perspective. This is a very advanced book. I would almost say the material in “separates the boys from the men” in the programming world. After you’ve finished with intro books, consider picking this one up.

For C#, I recommend Learn Visual Studio’s Absolute Beginner's Series for Visual C# 2005 Express Edition. The entire series used to be available for free on MSDN, and you can still find some of it in existence on that site.

Saturday, May 7, 2011

Upgrades

There’s some big news in the death of Osama bin Laden. I want to make a post on it, and we’ll see if I get around to it. It will be up if/ when it’s finished.
It may surprise you, dear reader, that being as technologically savvy as I am, I am probably one of the last people to upgrade my electronics. However, that is not to say that I do not plan upgrades, just that financial circumstances (read: unemployment) prevent me from making the final purchase.
Let’s start with the big one: my PC. My current motherboard is this beast, which I have had for the last 5 years. I envisioned it as a kind of transition PC, but here it is 5 years later, still pulling it’s weight. I would like to upgrade it to an AM3+ or Intel LGA2011 board when they get released. Hopefully it has SATA 6Gbit, USB 3.0, PCIe 3.0, and DDR4 out of box, but that’s kind of unlikely. Lightpeak (Thunderbolt?) looks to proprietary for my tastes.

I recently received a Blu-Ray burner, but my monitor isn’t HDCP, so I can’t actually watch Blu-Rays on my PC. So, I’m looking to pick up this guy when the price drops to $280 or this guy if it goes on sale again . I could even modify it for 3D.
 My device on the go is the iPhone 3G which, as you may have heard, Apple decided to unceremoniously drop support for. But I’m still considering buying an iPhone 5 or whatever iPhone happens to feature LTE. What can I say, Apple makes a damn fine mobile OS, up until the point when they make the next model.
My laptop is similar to this bad boy. I’m honestly surprised it still runs. I made upgrades to the hard drive and ram. But I no longer have the need for a laptop, so I won’t be upgrading. But if I did I would want something with a touch screen and discrete graphics card. This is a little old or a nice ThinkPad.
Finally there’s my car. It’s almost 2 decades old. I’m not a car person. But as I previously posted, I’ve started watching Top Gear and I did a little research and would love to get the Chevy Volt when it’s price comes down.

Thursday, April 21, 2011

Creating a DLL in Visual Studio


This was another subject neglected in my formal schooling. I picked it up through trial and error, but you won’t have to as I’m about to run through an example for you.
In this example I’ll be using Visual Studio 2010 to create a dynamic link library out of a C file and use it in a managed C++ project.
For the C DLL:
Create a Win32 Project. Application type: DLL. Empty Project.
Create your C file. I called mine retnum.c.
The text of my retnum.c is very simple:
__declspec(dllexport) int retnum()
{
        return 5;
}
The __declspec(dllexport) lets the compiler know we want to use this function in a DLL.
For the C++ project.
Lets create a simple CLR Console Application project under the same solution as our C project.
Right click on your solution and go to properties, set startup project to be your C++ project. Also, go to project dependencies, on the “Project” dropdown menu select you C++ project and check off your C project.
Right click on your C++ project and go to properties. Go to Common Properties, Frameworks and References, click “add new reference”. Select your C project.
Create a header file under your C++ project. I called mine cdll.h.
The text of my cdll.h is:
extern "C"
{
   retnum();
}
The extern "C" lets our C++ program know we will be using C code.
The meat of my C++ project was in my app.cpp file. Condense as follows:
#include "stdafx.h"
#include <iostream>
#include "cdll.h"

using namespace System;
using namespace std;

int main(array<System::String ^> ^args)
{
    int i = retnum();
      Console::WriteLine(L"Your number is: "+i);
      cin.get();
    return 0;
}
So, that’s how you create a C DLL and use it in a C++ project in Visual Studio.

Project files now available on the download website.

Friday, March 25, 2011

Compiling on the Wii: a Lesson in Makefile

Makefiles are files used to make compiling easier on Unix like systems.
Now I know what you’re saying. You’re saying, “Centraldogma, what does the Wii have to do with Make files?”. Well, because I learned it through trying to make some Wii homebrews, so that’s how I’m teaching it. Sure I learned some basics in college, but not the level you’ll see in Open Source.
But, let’s start with the basics. Here is a basic makefile:
all: hello

hello: main.o factorial.o hello.o
        gcc main.o hello.o -o hello

main.o: main.c
        gcc -c main.c

hello.o: hello.c
        gcc -c hello.c

clean:
        rm -rf *o hello

Each has word with a colon after is a rule. all is a default rule, if you create a file called makefile and say “make” the all rule will be executed.
Immediately after the colon is the requirement for the rule to be used, if these are other rules, those other rules will be executed. In this case all requires hello. hello requires main.o and factorial.o. For main.o a file called main.c must exist in the current directory and must be compileable. The same for hello.o and hello.c.
So, all you have to do is have your main.c and hello.c with your make file and type “make” and you get the hello binary. If you want to just make an intermediary, say main.o, you would say “make main.o”.
But lets say your all done, but you want to tar everything up and send it to your friend/partnet/employer/anyone-who-will-look-at-your-code. You have all these nasty binaries and intermediaries all over your directory! Well, we have this other rule, clean, which removes any file that ends with .o and the hello binary. Just say “make clean” and it’s done.

Well, that’s the basics, on to the advanced stuff. That’s where the guys at CodeMii come in, I’ll let them explain it:
A makefile is usually found that the root directory of the source code you have. Take the gamecube template source code example (C:\devkitPro\examples\gamecube\template). In that directory you will see a file name “Makefile”. If you open it up with notepad, you’ll be able to see the different parts of a makefile.
The important parts of a makefile for this tutorial are the following lines:
1.include $(DEVKITPPC)/gamecube_rules
By specificing “gamecube_rules” we are telling our compiler that the source code we want to compile will be run on the gamecube. You would use “wii_rules” to compile for the Wii.
By changing between these two, you are changing which libraries will be used when compiling the source code. Libraries are a bunch of files which we use in our source code to interact with the gamecube or Wii system.
1.SOURCES        :=    source
2.DATA        :=    data
3.INCLUDES    :=
These lines tell the compiler which files should be compiled. Most of the time you can leave this alone as our source code will be in /source and our additional files like images, music, etc will be in /data.
1.LIBS    :=    -logc –lm
This is a very important line as it tells the compiler which additional libraries we wish to use. Say we want to play an mp3 and have the relevant code in our source to do so. If we were to compile our source with the above line, the compiler would complain and say that it can’t find the functions we are using to play an mp3 file. For playing mp3 files, you need to include the “lmad” library.
The LIBS line when we add the lmad library looks like:
1.LIBS    :=    -lmad -logc –lm
The order of how you include your libraries is also important as some libraries may reference other libraries and if you haven’t got them in the right order, the compiler will complain about it.

Friday, March 18, 2011

SSH and Linux


SSH and Linux

Meant to put this up yesterday, but better late than never.

I guess this is my first technical post about programming. Well, not really programming… whatever.

My first experience with Linux went something like this: install whatever the popular distro of the day was, get any additional hardware working right, play around with it for one or two day, then format and install Windows. Because OS that you use really isn’t all that important as long as your familiar with it.

When I went off to college, I got much more rigorous training in Linux (and all Unix based systems) trying to compile code on the lab machines through CLI.  Was like a whole different experience. And I am going to impart some of the wisdom I gained to you my loyal reader (lucky you!).

Something important about Linux: Everything in Linux is a file. Also, see the picture for the breakdown of the directories.
If the place you’re working at supports SSH, your weapons of choice will be PuTTY (for general CLI) and Webdrive (for SFTP file transfer). PuTTY is free but Webdrive will cost you money. There are free software that does Webdrive’s job, but in my opinion, not as well. PuTTY can also be used for tunneling, which can be useful in … circumstances.
ls = list files in a in a directory. Use “ls –a” for detailed info. In case you don’t know –a is an argument to the program ls, you can pass multiple augments to a program as such “ls –a –rf” ect.
pwd = gives your current directory
cd = change your current directory. “cd ..” will move you to your parent directory as “..” represents to the parent directory
. = at is a way to denote the current directory. Say you need your current directory to run your program “a.out”, you’re going to want to say “./a.out
mkdir = create a directory. To create a directory called foo say “mkdir foo”. You can also use –m to specify a mode.
rm = remove a file. You can’t use rm to remove a directory unless you use “rm -rf” to recursively go into each folder, remove it’s condense and remove the folder.
more = print out the contense of a file
emacs = emacs is a popular text editor. Hit Ctrl-X and Ctrl-C to close emacs.
top = displays all the processes running. Like a task manager but CLI.
gcc = C++ comiler. –o tell it what to name the compiled file. –Wall gives you more warnings, but those are just warnings, it won’t break your program. –pedantic –ansi holds the program to stricter standards. –g compiles for debugging with gdb (I never used gdb, though it has some interesting features, I stuck to printf’s and getf’s to debug when I couldn’t use a proper IDE).  So the whole thing would look like “gcc-o hello hello.c –Wall –pedantic –ansi –g
tar = –cvf creates the archive as such: “tar -cvf file.tar file1 file2 file3” tars file1, file2, and file3 into file.tar.  –xvf untars a tar file.
scp and sftp – in certain cases, you won’t be able to use Webdrive or your SFTP client of choice. Use scp to send files, sftp to get.