Tuesday, July 10, 2012

How to Use a Mobile Phone as Modem in Linux


Last month, my home internet connection got disconnected a couple of times. However, I'm glad and lucky that I have a cell phone that I can use as a modem for my Linux box every time my internet provider messes up.

I'm going to share to all of you how I use my Nokia 9500Communicator mobile phone as Modem.

Note: this may also work with other Nokia cellular phone models that have internet capability.

1. Connect your phone to the computer via USB cable.

2. Open a terminal and type:

lsusb

3. You will get an output almost similar to this one:
jda@linux-lab:~$ lsusb
Bus 003 Device 004: ID 0421:0405 Nokia Mobile Phones 9500 GSM Communicator
Bus 003 Device 002: ID 05e3:0606 Genesys Logic, Inc.
Bus 003 Device 001: ID 0000:0000
Bus 001 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
4. Notice the numbers 0421 & 0405 on the line in which 'Nokia Mobile Phones' is displayed. 0421 is the Vendor ID (VID), while 0405 is the Product ID (PID). We will use these numbers later as 0x421 & 0x405.

5. Enter this command:

sudo /sbin/modprobe usbserial vendor=0x(VID) product=0x(PID)

eg, in my case: sudo /sbin/modprobe usbserial vendor=0x421 product=0x405

6. Now enter this command:

wvdialconf create

7. You will get an output which will be similar to this:

Editing `create'.

Scanning your serial ports for a modem.

WvModem<*1>: Cannot set information for serial port.
ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyACM0<*1>: ATQ0 V1 E1 -- OK
ttyACM0<*1>: ATQ0 V1 E1 Z -- OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyACM0<*1>: Modem Identifier: ATI -- Nokia
ttyACM0<*1>: Speed 4800: AT -- OK
ttyACM0<*1>: Speed 9600: AT -- OK
ttyACM0<*1>: Speed 19200: AT -- OK
ttyACM0<*1>: Speed 38400: AT -- OK
ttyACM0<*1>: Speed 57600: AT -- OK
ttyACM0<*1>: Speed 115200: AT -- OK
ttyACM0<*1>: Speed 230400: AT -- OK
ttyACM0<*1>: Speed 460800: AT -- OK
ttyACM0<*1>: Max speed is 460800; that should be safe.
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK

Found an USB modem on /dev/ttyACM0.
Modem configuration written to create.
ttyACM0: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

8. Find the location of the modem, in my case at /dev/ttyACM0, and also the Max speed which is 460800.

9. Now enter this command:

sudo vi /etc/wvdial.conf
Note: You can use any text editors. I used Vi here.

10. A file will open. Delete everything in that file and replace it with the following: (Don't forget to put the 'modem location' and 'max speed')

[Dialer Defaults]
Modem = PUT MODEM LOCATION HERE
Baud = PUT MAX SPEED HERE
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
Phone = *99#
Username = username
Password = password
Stupid Mode = 1

11. Save the file, and the setup is done.

12. You can connect by opening a terminal and then typing the command: wvdial. You will then get an output like shown below if everything worked as expected.
jda@linux-lab:~$ wvdial
WvDial<*1>: WvDial: Internet dialer version 1.56
WvModem<*1>: Cannot get information for serial port.
WvDial<*1>: Initializing modem.
WvDial<*1>: Sending: ATZ
WvDial Modem<*1>: ATZ
WvDial Modem<*1>: OK
WvDial<*1>: Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
WvDial Modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
WvDial Modem<*1>: OK
WvDial<*1>: Modem initialized.
WvDial<*1>: Sending: ATDT*99#
WvDial<*1>: Waiting for carrier.
WvDial Modem<*1>: ATDT*99#
WvDial Modem<*1>: CONNECT
WvDial Modem<*1>: ~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
WvDial<*1>: Carrier detected. Starting PPP immediately.
WvDial: Starting pppd at Wed Feb 6 21:53:10 2008
WvDial: Warning: Could not modify /etc/ppp/pap-secrets: Permission denied
WvDial: --> PAP (Password Authentication Protocol) may be flaky.
WvDial: Warning: Could not modify /etc/ppp/chap-secrets: Permission denied
WvDial: --> CHAP (Challenge Handshake) may be flaky.
WvDial: Pid of pppd: 5936
WvDial<*1>: Using interface ppp0
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: local IP address 10.157.42.199
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: remote IP address 10.6.6.6
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: primary DNS address 121.1.3.208
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]
WvDial<*1>: secondary DNS address 121.1.3.199
WvDial<*1>: pppd: ��[06][08]ؗ[06][08]

13. You are now connected. Disconnect by hitting Ctrl+c.

Overcoming the Fear of Linux Terminal


Fear is a painful emotion by the expectation of evil, or the apprehension of impending danger; anxiety; solicitude; alarm; dread; like our fear of ghosts and zombies as a child, and our fear of failure and death as an adult. I’m here to help Linux newbies defeat their fear, but not the kind of fear that I was talking about. Instead, I’m here to assist those who are suffering from CLI-phobia, or the “fear of Command Line Interface”. I will list some indispensable commands and keyboard shortcuts with their corresponding functions to guide the fearful in their journey to conquer the horror of using the Linux terminal.
Here are some of the most essential Linux terminal commands andkeyboard shortcuts:

*Essential Commands
Commands - Functions
Directory navigation
Pwd - "Print working directory" - show what dir you're in.
ls - List the contents of a dir.
ls –l - List the contents of a dir and show additional info of the files.
ls –a - List all files, including hidden files.
cd - Change directory.
cd - Go to the parent directory.
Examining files
file - Determine the type of a file.
cat - Concatenate a file.
less - View text files and paginate them if needed.
Manipulating files and directories
p - Copy a file.
cp –i - Copy a file and ask before overwriting.
cp –r - Copy a directory with its contents.
mv - Move or rename a file.
mv –i - Move or rename a file and ask before overwriting.
rm - Remove a file.
rm –r - Remove a directory with its contents.
rm –i - Ask before removing a file. Good to use with the -r option.
mkdir - Make a directory.
rmdir - Remove an empty directory.

*Essential Keyboard Shortcuts
Ctrl + Alt + F1
Switch to the first virtual terminal. In Linux, you can have several virtual terminals at the same time. The default is 6.

Ctrl + Alt + Fn
Switch to the nth virtual terminal. Because the number of virtual terminals is 6 by default, n = 1...6.

tty
Typing the tty command tells you what virtual terminal you're currently working in.

Ctrl + Alt + F7
Switch to the GUI. If you have X Window System running, it runs in the seventh virtual terminal by default. If X isn't running, this terminal is empty.

Ctrl + Alt + +
Switch to the next resolution in the X Window System. This works if you've configured more than one resolution for your X server. Note that you must use the + in your numpad.

Ctrl + Alt + -
Switch to the previous X resolution. Use the - in your numpad.

MiddleMouseButton
Paste the highlighted text. You can highlight the text with your left mouse button (or with some other highlighting method, depending on the application you're using), and then press the middle mouse button to paste. This is the traditional way of copying and pasting in the X Window System, but it may not work in some X applications.

If you have a two-button mouse, pressing both of the buttons at the same time has the same effect as pressing the middle one. If it doesn't, you must enable 3-mouse-button emulation.

This works also in text terminals if you enable the gpm service.

Ctrl + Alt + Backspace
Kill the X server. Use this if X crashes and you can't exit it normally. If you've configured your X Window System to start automatically at bootup, this restarts the server and throws you back to the graphical login screen.

Home or Ctrl + a
Move the cursor to the beginning of the current line.

End or Ctrl + e
Move the cursor to the end of the current line.

Alt + b
Move the cursor to the beginning of the current or previous word. Note that while this works in virtual terminals, it may not work in all graphical terminal emulators, because many graphical applications already use this as a menu shortcut by default.

Alt + f
Move the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier, this may not work in all graphical terminal emulators.

Tab
Autocomplete commands and file names. Type the first letter(s) of a command, directory or file name, press Tab and the rest is completed automatically! If there are more commands starting with the same letters, the shell completes as much as it can and beeps. If you then press Tab again, it shows you all the alternatives.

This shortcut is really helpful and saves a lot of typing! It even works at the lilo prompt and in some X applications.

Ctrl + u
Erase the current line.

Ctrl + k
Delete the line from the position of the cursor to the end of the line.

Ctrl + w
Delete the word before the cursor.

Shift + PageUp
Scroll terminal output up.

Shift + PageDown
Scroll terminal output down.

clear
The clear command clears all previously executed commands and their output from the current terminal.

Ctrl + l
Does exactly the same as typing the clear command.

reset
If you mess up your terminal, use the reset command. For example, if you try to cat a binary file, the terminal starts showing weird characters. Note that you may not be able to see the command when you're typing it.

history
When you type the history command, you'll see a list of the commands you executed previously.

ArrowUp or Ctrl + p
Scroll up in the history and edit the previously executed commands. To execute them, press Enter like you normally do.

ArrowDown or Ctrl + n
Scroll down in the history and edit the next commands.

Ctrl + r
Find the last command that contained the letters you're typing. For example, if you want to find out the last action you did to a file called "file42.txt", you'll press Ctrl + r and start typing the file name. Or, if you want to find out the last parameters you gave to the "cp" command, you'll press Ctrl + r and type in "cp".

Ctrl + c
Kill the current process.

Ctrl + z
Send the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don't want to exit the program completely. Then just send it to background with Ctrl+z, do whatever you want, and type the command fg to get the process back.

Ctrl + d
Log out from the current terminal. If you use this in a terminal emulator under X, this usually shuts down the terminal emulator after logging you out.

Ctrl + Alt + Del
Reboot the system. You can change this behavior by editing /etc/inittab if you want the system to shut down instead of rebooting.
Other Essential CLI Related Help Sites:
http://www.er.uqam.ca/nobel/r10735/unixcomm.html
http://www.computerhope.com/unix.htm
http://www.tuxfiles.org/
http://www.freesoftwaremagazine.com/articles/command_line_intro
http://linux.about.com/od/linux101/l/blnewbie5_1.htm

"Fear is the main source of superstition, and one of the main sources of cruelty. To conquer fear is the beginning of wisdom."
Bertrand Russell (1872 - 1970), Unpopular Essays (1950), "Outline of Intellectual Rubbish"

Happy Halloween!

You may also want to check out our list of Linux terminal emulators.

8 Most Useful Commands and Keyboard Shortcuts Linux Newbies Should Know


To use Linux nowadays, you don't have to touch the command line to get going. This may be true. However, I still find it important that newbies and those who are still planning to use Linux should know some of the basic commands and keyboard shortcuts to make the most out of their Linux desktop and to start having a good time.

So here I made a list of 8 most useful Linux terminal commands and keyboard shortcuts that I think newbies should know:



1. ls 

With this command, you can view the content of your current working directory. ls is often paired with options -l(to view a detailed list of files) and -a (to view the hidden files).

Use it like this:

ls -al

2. sudo 

Allow users to run programs with the security privileges of another user (normally the superuser). By default, sudo will prompt for a user password but it may be configured to require the root password.

Use it like this:

sudo gedit

3. Ctrl-Alt-Esc

When an application hangs or fails to close, never worry. Pressing this keyboard shortcut and then clicking on the troubled application will kill or end its process.

4. find

This is probably the most efficient command to use when you are looking for some files.find searches through one or more directory trees of a filesystem, locating files based on some user-specified criteria. By default, find returns all files below the current working directory.

To recursively search for files that starts with letter j starting from the /home directory use:

find /home -name j*

5. apt-get

Since most Linux newbies are probably using Ubuntu, they should know how to use this command.

To install a package:
sudo apt-get install package-name

To remove:
sudo apt-get remove package-name

6. Ctrl-Alt-Backspace

This keyboard shortcut will kill the X server. Use this if X crashes and you can't exit it normally. This restarts the server and throws you back immediately to the graphical login screen.

7. mv, cp, rm

I know that it is a lot easier to move, copy, and delete files using the mouse. But, I find it important that newbies should also know how to do it from the command line just in case of emergency.

Use them like these:
move
mv oldfilename.txt newfilename.txt
copy
cp oldfilename.txt newfilename.txt
delete
rm oldfilename.txt

8. man

Most Linux commands and applications have manual pages, so man is really handy if you you want to learn more about a particular command or programs.

Use it like this:
man bash

8 Best Linux Terminal Emulators You May Have Never Heard Of


8 Best Linux Terminal Emulators You May Have Never Heard Of: For some Linux users, the terminal or command line shell is a useful and powerful tool that can help accomplish tasks (from simple to complex) in a more efficient and often quicker way. Although it is not a necessity anymore, I think it would still be handy to have some basic command line skills. To those of you who are afraid to use the Linux terminal, perhaps you should get or download some Linux/UNIX command cheat sheets.

Since majority of popular Linux distributions utilizes either KDE or GNOME desktop environment, you may have only used terminal emulators such as Konsole, GNOME Terminal, and xterm. But did you know that there are capable and unique terminal emulators for Linux other than those I've mentioned?

Here is a list of some of the best Linux terminal emulators you may have never heard of (in no particular order):


Terminator
Terminator is currently my favorite Linux terminal emulator. It allows me to easily organize multiple command line sessions into resizable split panes within the same window. This way, I can do some command-line multitasking in a more efficient manner, minus the desktop clutter. Terminator is written in Python, and it will work on any modern POSIX system with Java 5 or later, which means it can also run on other operating system platforms aside from Linux such as Windows and Mac OS X.



Guake
Guake is a top-down terminal emulator for GNOME Desktop Environment that has a design inspired by consoles in computer games such as Quake and Doom. It can quickly slide down from the top of the screen using a single keystroke, and can be hidden by pressing the same key. The advantage of using Guake when compared to the standard terminal is that it is faster to open since the program is already loaded into the computer memory.



Yakuake
Yakuake (Yet Another Kuake) is a drop-down KDE terminal emulator with features almost similar to that of Guake. Its design was also inspired by consoles in computer games. Like Kate, Konqueror, and other KDE applications, Yakuake depends on Konsole for its terminal functionality.



rxvt
rxvt is a simple and lightweight terminal emulator that is aimed to be a slimmed-down replacement for the already slim xterm, removing several of its little-used features, like Tektronix 4014 emulation and toolkit-style configurability. Apart from features like those controlled by resource files, the terminal emulation of rxvt differs from xterm in a few important ways.



Tilda
Tilda is a slide-down GTK+ terminal emulator similar to that of Guake and Yakuake. The program also runs invisibly in the background allowing it to quickly slide up and down once a hotkey is pressed.



mrxvt
mrxvt is a multi-tabbed terminal emulator based on rxvt that provides DEC VT102 compatible terminals. Like rxvt, it is fast, lightweight, and flexible without depending on desktop environments such as GNOME or KDE. The main features of mrxvt include multiple tabs, dynamically changeable tab titles, customizable command for each tab, input broadcasting, fast pseudo-transparency with tinting, user supplied background images, multi-language support, Freetype font, logging, and more.



Wterm
Wterm is a fork rxvt that is also very fast and lightweight. Its look was designed for NeXTSTEP style window managers like Window Maker. It has terminal support for Latin, Chinese, and Greek characters and features customizable background images, background color tinting, and zero overhead pseudo-transparent background.



aterm
aterm is the AfterStep terminal emulator for the X Window System that is based (again) on rxvt. As described from its project webpage, aterm is designed to provide pleasing visual effects, while performing such a mundane function as terminal emulation under X.



If you know of other capable terminal emulators for Linux that I fail to include on the above list, please share them with us via comment.

10 Essential UNIX/Linux Command Cheat Sheets


Linux has become so idiot proof nowadays that there is less and less need to use the command line. However, the commands and shell scripts have remained powerful for advanced users to utilize to help them do complicated tasks quickly and efficiently.

To those of you who are aspiring to become a UNIX/Linux guru, you have to know loads of commands and learn how to effectively use them. But there is really no need to memorize everything since there are plenty of cheat sheets available on the web and on books. To spare you from the hassles of searching, I have here a collection of 10 essential UNIX/Linux cheat sheets that can greatly help you on your quest for mastery:

UNIX Tutorial for Beginners
This is a quick and easy UNIX/Linux tutorial page that is aimed at beginners. It gives a subtle introduction to some of the most important UNIX/Linux commands.


Learning the Shell
Aside from showing you how to apply the most basic UNIX/Linux commands, “Learning the Shell’ will teach you the utmost importance of using the command line.


Learn UNIX in 10 Minutes
From the page: This is something that I had given out to students (CAD user training) in years past. The purpose was to have on one page the basics commands for getting started using the UNIX shell (so that they didn't call me asking what to do the first time someone gave them a tape).


FOSSwire Unix/Linux Command Cheat Sheet
A one page UNIX/Linux command reference that you can download in PDF format. You can easily print it, and then paste it on your wall.

UNIX Toolbox
From the page: This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations; however the reader is supposed to know what s/he is doing.


Practical Linux Command Line Reference
This is another handy one-page cheat sheet for common command line operations. All of the commands have been tested on Fedora and Ubuntu.


How to Look Like a UNIX Guru
From the page: This lecture takes you through the basic commands and then shows you how to combine them in simple patterns or idioms to provide sophisticated functionality like histogramming. This lecture assumes you know what a shell is and that you have some basic familiarity with UNIX.



A Directory of Linux Commands (in alphabetical order)
From the O'reilly book “Linux in a Nutshell, 5th Edition”, it features an alphabetical list of 687 commands and a short description on each one of them.

Linux Security Quick Reference Guide
This quick reference guide (in PDF) will serve as your aid on improving the security of your Linux system. It provides some pointers to more in-depth security information that could help you become a good UNIX/Linux system administrator.


Bash Programming Cheat Sheet
From the page: A quick cheat sheet for programmers who want to do shell scripting. This is not intended to teach programming, etc. but it is intended for someone who knows one programming language to begin learning about bash scripting.


Through comments, feel free to share some links to other essential UNIX/Linux cheat sheets that I failed to include here.

How to install/upgrade/increase RAM


How to install/upgrade/increase RAM: Every once in a while, I will be posting an easy-to-follow and easy-to-do computer hardware and software tips and tutorials. My main aim is to provide in my own little way some technical help and advice to those who are still lacking the know-how on fixing or doing the most basic computer related tasks.

So here is my first uncomplicated tutorial, and it’s about the proper way of installing RAM:

What is RAM?
RAM is short for Random Access Memory. It is the area where your computer stores programs that you are currently running and data that you are currently working on. RAM is different from disk storage, e.g. hard-drive. Each and every one of your programs and data are held by disk storage whether you are running them or not. The moment you turn off the computer, the contents of RAM will instantaneously disappear, but the contents of your disk storage will remain in tacked. RAM is also different from ROM. ROM (Read Only Memory) are memory chips that have had data stored on them which cannot be changed at all. ROM chips can be usually found on a computer motherboard.

Why upgrade or increase RAM?

The main reason for upgrading RAM is speed. More and faster RAM means quicker and more responsive computer performance. Upgrading RAM is considered as one of the cheapest if not the cheapest way to speed-up a computer.

When to upgrade or increase RAM?

When your computer is running sluggish while performing memory demanding tasks like video and graphics editing, CD/DVD burning, or while running several applications simultaneously, then upgrading RAM is one of the best available solutions.

How to install RAM?
Before adding RAM, be sure to read these important tips and reminders first:

*If you have a new motherboard, check the owner’s manual or manufacturer, this is the sure way to purchase the correct type when you're adding computer RAM.

*If you want to add RAM to your current motherboard, the easiest way is to see which type of RAM you currently have. First open your computer case. Remove your current RAM by pushing down on both of the retaining clips holding the RAM in place. Your RAM should have the type and speed printed on it. That's the type you need!

*You can mix different memory speeds and sizes but not of different types. Like a DDR and DDR2 cannot be used together.

*Stand on uncarpeted flooring to reduce static electricity. Touch as little as possible inside your machine and especially avoid touching any computer chips. Static damage, and even oil from fingertips, may cause a failure months later.

Instead of illustrating the procedures on how to install, upgrade or increase RAM myself, I'm going to refer you to these existing good tutorial sites that can be found here and here. If you have some questions or needed extra help, you can always ask me later thru a comment. And then there’s always Google, when all else fails.