Showing posts with label FOR DUMMY. Show all posts
Showing posts with label FOR DUMMY. Show all posts

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.

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.

Monday, June 25, 2012

3 Ways to Automate Tasks on Linux


Linux is, and always was, one of the most powerful operating systems on the planet. From Android to Ubuntu, Linux’s versatility has made it quite popular with developers, system admins, hackers, and of course, end users. Though simple to use and learn, Linux’s untapped prowess can be used to accomplish many tasks in your daily life. From running a garden sprinkler to rocking a baby’s cradle, Linux is just about as awesome as Chuck Norris.

Don’t worry if you are not that adventurous, because the penguin can also help you save the time you spend on simple repetitive tasks by automating them. Tasks like backing up your important folders, rebooting your computer, and even downloading torrents. So, whether you’re a little lazy (as all geeks are) or just someone who doesn't have much time, this article will guide you in saving a few precious hours in your life by automating boring repetitive tasks for you.


Take Automatic Backups
If you’re worried about losing your data, then backing it up safely is the best solution. We've already listed some of the best backup tools for Linux; however, the shining newDeja Dup is our favorite these days. Its simplicity as well as its inclusion as the default backup application in Ubuntu has made it a reliable choice. Deja Dup, once set up, can allow you to take automatic backups of your data without you having to manually do it. To get started, simply open Deja Dup by searching for it using the launcher (Super key).

Now, once the application starts, go to the “schedule” tab and select the frequency that suits you best. Also, don’t forget to choose whether to keep backups forever or for a set period of time. You don’t want to have your hard disk or online account bloated with just backups.

Then, once you are set, go back to the ‘Overview’ tab and turn ‘Automatic Backups’ on. This will ensure that your data is safe even when you’re not using the computer. Of course, you’ll have to leave your computer on for this.


Reboot or Shutdown your computer
Using the ‘at’ command you can shutdown or reboot your Linux device even while you’re away from it. So, let’s say you want to shutdown your computer at 3 PM. To get started, open the terminal first (Ctrl + Alt + T), then punch in the following command:

at 3pm
Now, the command will take you to a prompt mode wherein you’ll instruct ‘at’ to do a particular job. There, simply enter the command ‘halt’ without quotes. Press Ctrl+D to exit.

Now, you've instructed the computer to halt (that is to shut down) at 3pm. You can, in the same way, add more commands to the list. To check on the current pending jobs, simply enter the ‘atq’ command without quotes. To remove a particular job, use the ‘atrm’ command.


Auto-start torrent downloads
If you’re sleeping or out of the house and wanted to auto-start a download at a specific time, then Linux can be your best friend. Say, you’re leaving your house at 10 AM, you can then schedule Linux to start Transmission (popular torrent client) at 2 PM using the following command.

sleep 4h && transmission-gtk
The above command will start Transmission exactly 4 hours after you've issued it. If you want Transmission to run after 3 and a half hours, simply enter this command:

sleep 3h && sleep 30m && transmission-gtk
This can be very useful for people who use data plans where in the ISPs provide unlimited downloading at night. Also, if you want to stop the download before you wake up, or at a specific time, you can issue the following command:

sleep 8h && pkill transmission-gtk