I normally connect to internet through my mobile phone's SIM card. Its a GSM network.

To connect to internet in GUI manner I go to notification bar, click on network icon, and click on connections name. After connecting the network icon changes to indicate that I have connected to internet.

Can I do it in command line way?


The GUI is a front end to Network Manager, which is a daemon. You can ask the daemon to make a connection using the command line as well. This way, your configuration is shared between the GUI and command line methods.

The tool you can use for this is nmcli, which is installed with network-manager so should be present on your system already. To connect to a network called network-name in your GUI, type nmcli con up id network-name on the command line. Similarly, nmcli con down id network-name will disconnect. If the GUI (nm-applet) is running, then you will see its displayed status change accordingly.

See the nmcli manpage for further details. Manpages on newer releases include examples as well, although I can't find an online link to this.


All what need is right here

  1. sudo nano /etc/chatscripts/ispname

  2. Inside this file You will place following code:

    TIMEOUT 10  
    ABORT 'BUSY'  
    '' 'ATZ'  
    'OK' 'ATE1'  
    'OK' 'AT+CGDCONT=1,"IP","ispapn","",0,0'  
    'OK' 'ATDT*99#'  
    'CONNECT' '\c'  

    You should replace “ispapn” with your ISP access point name (APN.)

  3. if Your ISP is using PAP authentication so You must add user name and password provided by my ISP at the end of your /etc/ppp/pap-secrets file.

    sudo nano /etc/ppp/pap-secrets
  4. If your Internet service provider is using CHAP authentication do the same but use /etc/ppp/chap-secrets file.

    Also we must decide on remote name identification string that will be used in the next steps to instruct pppd to use right pap or chap credentials.

    I will use string “ispname” here. So here’s what I have placed at the end of my /etc/ppp/pap-secrets file (place your user name, password and string of your choice here instead of my “ispusername”, “isppassword” and “ispname”):

     "ispusername" "ispname" "isppassword"
  5. If your ISP isn’t using authentication and you don’t need to provide name and password to connect to Internet you can skip this step altogether.

  6. As a next step we must create so called peers file that will be used by pppd to dial chat script created in the first step using credentials stored in the second step. I will call my peers file “ispname” and place it into /etc/ppp/peers directory:

    sudo nano /etc/ppp/peers/ispname

    Inside my peers file I will place following code:

    connect "/usr/sbin/chat -v -f /etc/chatscripts/ispname"
    # Redial and interval
    holdoff 5
    # No compression
    # PAP authentication
    user "ispusername"
    remotename ispname
    # LCP echo messages settings
    lcp-echo-failure 4
    lcp-echo-interval 65535
  7. This is basic configuration to get you online. To dial your connection you would use sudo pon ispname and to disconnect you would use sudo poff ispname where “ispname” is you peers file name. To be able to dial without sudo you need to add your self to “dialout” group:

    sudo adduser $USER dialout
  8. Further you might want to create interface for your pppd connection so you could control your GSM mobile broadband connection using “ifup” and “ifdown” commands and/or dial automatically when your PC boot. You would achieve this by adding something like this to your /etc/network/interfaces file:

    auto ppp0  
    iface ppp0 inet ppp  
        pre-up sleep 10   
        provider ispname   
  • Something is broken. How do I find the location of USB device. I think that location is creating problem as I have many USB ports. – Santosh Kumar Oct 6 '12 at 16:25

Here is a link to an article about how to connect to the internet from the command line. I will not attempt to reproduce it here since it is clearly explained in the article.


I would assume that this will work with a phone like you are using, but I'm not sure if using a phone is different than typical wifi. Here is a thread in another forum that might help:


I hope this helps. Good luck.


You can also use wvdial

Install it using sudo apt-get install wvdial Then, run sudo wvdialconf

And edit the config file sudo gedit /etc/wvdial.conf

You will get something like

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
ISDN = 0
New PPPD = yes
Modem = /dev/ttyACM0
Phone = *91#
Username =  
Password = 
Baud = 460800

Enter the Username and Password if required (leave blank if it's not required) . Also provide the Phone number to dial. For eg: *91#,#777 ...etc If the phone is connected using USB, the Modem value will most probably be /tty/USB0 or something similar.

Finally, use the wvdial command to initiate connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.