Wednesday, November 10, 2010
(Note: This is a continuation of “CLI Part 1”. It would be best for beginners to review the first installment before continuing) CLICK ANY IMAGE TO ENLARGE
Checking System Stats
Like many users people what to know the status of their systems and hardware. So the first thing we are going to cover is how to check system information from the CLI. Up front I would like to mention the programs we are going to be using to check system stats. The commands are as follows: free, top, df, and ps. Before we begin I would like to break down what each of the previous stated commands are for. Free, is for checking RAM and Swap usage. Top, is like the “Processes” Tab in Windows Task Manager, It will show current applications in use and what resources they are taking in real-time. DF, shows mounted file-systems with information on their capacity and total amount used, such as you Hard-Drive or USB Flash Drive and others. Finally, PS, will list all current processes/services loaded with their current PID number, and will allow you to have the option of terminating a process or service if it is either hung, frozen, or in limbo. Keep in mind top can do the same thing but is a bit more difficult to use. I will get to that later.
Free is a great tool that to my knowledge comes with every flavor of Linux. As stated its used to check system memory used as well as swap space. Free is straight forward. Simply type “free” in the command line and you will be represented the following information:
As you can see on the “- / + buffers/cache” under the “used” and “free” columns I currently have 320,500 Kb (Kilobytes) of RAM currently taken, and 641180 Kb of RAM available. It's simple and easy to use. You don't really have to do a Kb to Mb (Megabyte) conversion to get the exact amount. There are 1024Kb in 1 Mb, so if you know that, you can get an estimate of how much is taken/available.
Top, unlike the ps command, allows you to watch resources and applications in real time. Just like ps, in Top you can kill processes from it, but it can be difficult to filter the list because there are more things running then you realize and using ps is just an easier way. Below is a picture showing what the interface of the Top command looks like.
If you notice across the top you are given more information then just applications. As I said everything in top is displayed in real time, so on a side note it will cause your CPU usage to spike. On the top you will find number of users logged in, total amount of tasks, ram information, program states (sleeping, stopped, zombies), and more. It is a very useful tool. Along with just showing applications it shows their PID, owned user, percent of memory used, CPU cycles used and more. If you wish to kill off an application that is near the top of the list and is visible, press the “k” key to open the “kill” function. All you have to do is enter the PID number next to the process you wish to kill and that's it. Now lets move on to “df”.
It's always nice to see how much disk space you have available. Just to make sure you are not running out, an see if you are needing to get rid of some things or buy another hard-drive. With that you can run the simple command, df. DF will show all mounted file-systems, their total capacity and how much is taken. By viewing the below image you will see what I mean.
As you can see on the first line in the output area, you can see that my partition “/dev/sda1” (sda meaning the first drive and 1 meaning the first partition) is mounted on “/”. Like I said you can see the available space field, and used field which is given by a percentage. Other then that there is not a whole lot more use you can get out of it for just that basic purpose.
Now ps is a good command for finding running process if they need to be killed off. It's sad but true, that Linux isn't perfect. Applications do crash from time to time. Unlike Windows however, it can be recovered with no reboot necessary. There are different flags or arguments you can use with ps and I prefer “-ax”. The argument -a displays all w/ tty except session leaders and -x displays processes w/o controlling ttys. I won't get into what all that means at this time but I thought I would at least explain them. Executing the command in this fashion will look like this:
The list goes off the screen as you can see. If you a looking for a specific program you can pipe it into the grep command. If you are say looking for firefox it would look like this, “ps -ax | grep firefox”. Just on a side note to use the pipe symbol you press shift along with the “ \ “ key. I will go into using the pipe feature in a future CLI session. Anyways back to subject. As show in the picture, if I wanted to kill say the Gedit program that has the file “New Blog Post.txt” open I would type in “kill 1709”. You kill the PID associated with the target program and you find it by looking at the correct line so it was,
“1709 ? S 0:00 gedit /home/user01/Desktop/Next Blog Post.txt”. The first number on the line is the PID connected with that application.
Well that about wraps up system status tools so now we go on.
Finding and Installing Software
There are many different types of package managers out there and they are all different in their own way. For this session I will be covering “Apt”. This is used mainly in Debian based distributions. I may discuss managers like “yum” at a later date. First thing is first, I am going to cover how to find software before installing it. Kind of makes sense, no? I would like to point out at this time you will need some sort of higher privilege to use the apt program. An again I am going to assume you have “sudo” access. Sudo allows you to run a program as a higher privilege level. It will ask you for your personal user account password to continue to execute the command at a sudo level. I will warn you, don't use sudo for every command, only use it when it is absolutely required. Just a security precaution.
Now, when you are looking for a program you need to use key words. I will give an example. Say you want some video editing software, you are going to issue and apt command with some key words, such as “video” and “editing”. The command to look for such software is: “sudo apt-cache search video editing”. When you issue such a command you will get results like this:
After your search you will be given a list of packages, if any. On the far left is the package name and next to it is the package description. Now trying software and installing is easy thanks to the creation of package managers. When it comes to installing software it use to absolutely ludicrous. Having to install the correct version, finding all its dependencies, compiling, and linking everything properly was a headache but you can pet an thank your package manager for helping to fix all of that. To install a package its a simple as typing “sudo apt-get install (package-name)”. Just simply drop in the package name in the list displayed from your “apt-cache search” command and let apt do the rest.
Once its done you are set. You have successfully downloaded and installed your first package. If you ever wish to uninstall a package simply use "sudo apt-get remove (packagename)".
How to run Program from a Terminal
This section won't be very long so enjoy it. Running a program for a terminal is not difficult at all. For example, if you have say the Firefox Web Browser installed, all you have to type is “firefox” and press Enter. … … … That's it. Nothing more to it. Just like using the “Run” feature in windows. However you will notice that running a program in this fashion takes control of your terminal window. If you wish to run a program and still have terminal functions, use the “&” symbol at the end, like we covered in Part 1 of this series. To use it, the command would look like this, “firefox &”. Tada! You know have full control over your terminal window once again while staring a new application.
How to Use and Create Symbolic Links
First off you are probably asking, “What are symbolic links?” To put simply, they are almost like shortcuts in Windows. An you can create these symbolic links to have faster access to files, folders, or executables and it's not that difficult. For this tutorial we will be just making a symbolic link for a given folder. So lets get started. As shown in this picture below we will be creating a symbolic link in one folder to direct us to another.
As you can see in the first line we are using the command “ln”. It is used when creating symbolic links. We then follow it with a “-s” for soft-link. Not using this flag creates a “hard-link” and linking to a directory MUST be a soft-link. Again, in the first line I am linking a directory in my hidden wine (Windows API program) folder to my current location. When using ln your target file/directory is first and then you put your destination last. When I preform an ln, you can see our newly created link called “windows” in the Blog folder, our current location. Now when I cd (change directory) to our symbolic link “cd windows” it takes me right to “/home/user01/.wine/drive_c/Program\ Files/” without having to type in it's full path I just demonstrated. So again they are basically shortcuts to the specified folder or file.
Well that about wraps up Part 2 of the CLI HowTo. You get a bonus prize if you stayed with me for this long. See you next time. And,
Embrace the power of the CLI!
Many people in my opinion, are intimidated by the Linux world. When I mention to friends and family if they have every used Linux in their life time I get, "I don't know anything about programming." or "I wouldn't know what to do, I have never used it before.". Those statements are perfectly understandable. However, Linux is becoming easier to use for new and unfamiliar users by the day. Some Linux distributions that have been released such at Mint, Ubuntu, Fedora and many others, really strive to make the unknown Operating System tolerable and much more user-friendly. On top of that, the types of hardware that are now supported with Linux is greater than ever.
Take laptops for example. With my personal experience, getting a Linux distro to work on a laptop was an absolute headache. It was usually the hardware that was the source of the problem. Hardware such as the integrated graphics chips, the Wireless card, and the sound card. Not to mention the "Hot bar" that is on most laptops that provide shortcut buttons for specific functions.
Lately I have been using a dirto named Mint, and the version I am currently using is 9. Codenamed Isadora, which is wonderful. My first test with the distro was to install it on my laptop. That is usually my first test. Not only was it able to understand everything but installing the graphics card driver was a snap. All I had to do was enter the built in hardware tool, and Mint scans for any hardware that requires a driver. It pointed out that my GFX card needed one. All it took was a single button click and a reboot. I was ready to go.
A week or so after the laptop trial, I added it to my main PC and again, everything went perfectly. I am still currently using it at this point in time. Mint has since released their next version. Currently in RC stage. Other then that lets move on to sources that can help you out when it comes down to trying linux or just getting your daily information.
Distrowatch[dot]com : What a helpful site for keeping up with the latest distro news and popularity trends. This site is a must use. You can browse almost all of the public and common used flavors out there. When you do select a distro, it will provide you the current and past versions of the selected flavor you have picked. Including a list of commonly request applications that come pre-installed, along with that apps version. Link
Kernel[dot]org : This site is straight forward. The name about wraps it up. You can check the current (Stable or Dev) releases for any kernel version out there. Also included are download links to any version you need. Link
Linux[dot]org : Just like the kernel site, this one too speaks for itself. On this page you can find the basic information and breakdown about the Linux OS, what it offers, and news about updates and software. Link
Linuxforums[dot]com : If you ever run into a problem or just an issue in general, this is a good source to go to. Here you can chat with other Linux users, about Programming, Problems, Configuration, Suggestions and more. If needed people located here will gladly help you with an issues you might be having. Although if you are using the Ubuntu distro lets say, I would recommend going to their official forum first. Otherwise its a good site to check out. Link
Monday, November 8, 2010
(WARNING: Only make copies of production CDs/DVDs for your personal use ONLY. I will not be responsible for any redistribution of copy-right material.)
Hey everyone welcome back. For this post I will be showing you how to make an .iso (Disc Image) of a game CD and be able to use it instead of a physical disc to play the game. Keep in mind that some discs have things to try and prevent copying such as soft-bits. You will also need the programs DD, and the Windows API program Wine, in order to run windows applications. (You can obtain these programs from your distributions package manager if they are not already installed) Other then that, lets get started.
First things first. We need to create a folder to mount our .iso that we will create. For now lets do everything within you personal "Home" folder. As you see in Figure 1-1 we need to issue the command mkdir to creat a directory. For this example lets name it mnt-iso. (command is: mkdir mnt-iso) Good, you have now created the directory we are going to mount our .iso file to.
For this demonstration we will be making a .iso image of a disc from the game "Morrowind". The first thing we will do is insert the Morrowind CD into our CD or DVD rom drive. Once the disc is inserted we will need to create a copy of the disc. To do this we will issue the command, (dd if=/dev/cdrom of=Morrowind.iso). For the command DD, "if" means input file, and "of" is equal to the output file. The program DD, or data dump, will try to create an exact image of your CD or DVD bit for bit.
Doing the above process may take some time. Depending on how fast the disc is spinning, your drive speed and a few other factors. Once the image is created it is time to mount our image. As shown in Figure 1-1, we will need to issue the following command to mount our newly created .iso image. (mount -t iso9660 -o loop Morrowind.iso mnt-iso/) Please note, if you are not in your home folder you will have to give the full path. (In most cases you will need Admin "Root" privileges to mount something, so don't forget that)
Now that the .iso image is mounted, we need to let Wine know that the mnt-iso folder we created is a Virtual CD-Rom Drive. To do this we need to run the command (winecfg) in the command line to enter the Wine configuration tool. (See Figures 1-2 to 1-4 for more information) Once in winecfg, we need to goto the "Drives" tab at the top of the window. Once there click the "Add" button and choose a Drive Letter. Once created we need to give our newly created drive some more input. If you choose say drive letter "F:", click the letter F from the window above. Now click the "Browse" button and navigate to the "mnt-iso" directory we created earlier an click OK.
We are almost done. Next Click the "Show Advanced" button and change the type from Auto to CD-Rom. After that click Apply in the bottom right corner of the "Winecfg" menu and then click Ok. You are finished. Now eject the Physical "Morrowind" disc from the CD-rom/DVD drive and try to launch the game. If all was successful the game should run without the physical disk. You are now running off a digital copy of the physical disc on your hard-drive. That about wraps it up.
This trick can be used on things other then games. You can also use the .iso creating method to backup your physical discs. Hope you enjoyed and good luck.
(Click any to Enlarge)