Practicality
Let's tackle this question first. Command line is essential in Linux world. Many tasks have to be done through command line or at least are preferred to be done in, like debugging for instance. Certainly, you can go without learning command line, but you can have more control over your machine in command line instead of GUI. Plus you learn a lot.
For a newbie, the best way to learn command line is to make your learning process practical. For example, I am a college student, who is studying C programming right now. So far I've programmed exclusively in command line, using gcc compiler and nano text editor, and that's all I really need. I've learned a lot this way, much more when using GUI style applications (and don't even get me started on Microsoft's Visual Studio - yuck).
Another suggestion, that is also ties in with making things practical is, find command line solution to action you'd otherwise do with GUI . For instance, the internet connection sometimes drops at home, and I can't go to any website, even though network icon says connected. So I wrote a scrip that will turn wifi off and on, and network manager will automatically connect to my home network
#!/bin/mksh
printf "\n Turning wifi off";
nmcli nm wifi off;
sleep 2;
printf "\n Turning Wifi on"
nmcli nm wifi on;
#printf "\n Gonna observe how Network Manager reconnects\n Press Ctrl+C when done ";
#sleep 2;
watch -n1 nmcli dev status
I frequently fall asleep in front of my laptop, so I wrote a script to shutdown computer an hour after I execute that script.
#!/bin/mksh
sudo shutdown -P +60
This way I only have to type shut
in terminal and my sudo password, and no the whole nine yards. Another question yesterday asked to manually change brightness, so at least for my own machine I wrote a script that will open the file that controls brightness in nano text editor.
#!/bin/mksh
printf " \n Entering file to change brightness in 3 seconds\n remember - no new line after number. ";
sleep 3;
sudo nano /sys/class/backlight/acpi_video0/brightness
Do you see what I'm talking about ? All these commands can be done with GUI alternatives. But this way you learn command line with practical aspect. Like checking email in command line, or sending one, or checking battery power, or . . .(goes on into infinity)
And of course, find solutions to questions posted here, on askubuntu.com . Although I'm also still very new to Linux world (started with 13.10 in spring 2014), I've learned a lot by reading what others post and ask. It's very valuable to solve real-world problems.
Some other suggestions :
First program to start
If your only concerned with starting applications, you could use Classic Menu Indicator
and Gnome Do
. Gnome Do starts when you boot computer and is first thing you see when you log-in into GUI session. Type name of the app, and it will start. For instance, I saw your question on my phone, turned on laptop, logged in, typed "firefox" into Gnome Do, and here I am - typing this answer.
Opening a file without knowing which program to use
In terminal (aka command line), you also could use something called gnome-open
. For instance, if I wanted to open a pdf file called random.pdf, I'd type gnome-open random.pdf and voila - Document Viewer(aka Evince) opens my pdf file.
What if you wanted to find out which program opened that file ? Well you could go to about or help tab in drop down menu for that progra OR, you could run ps ax
in terminal. For instance, I opened a random text file with gnome-open, and it brought up some text editor, but i wanna know which it is. So , I executed ps ax
Do you see line with process 4149 ? It says gedit /home/sergiy/random
. So, my random text file was opened with gedit text editor.
And as other users pointed out here you can use which
command. How about source files or binary files for that command (because everything in unix is a file)? Use where is command, e.g. whereis bash
. Locate a specific file file ? no problem ! locate random.txt
Learning command line in general
Every type of learning needs sources. Make sure you research internet and read books. Personally, I started with very very very old Unix System V book, and now I have "Ubuntu Linux Toolbox" book, which is all about command line.
Now, I wanted to write something for Linux as my final coding project, so what I use now is Advanced Linux Programming - an online book. Both practical and educational, and you still learn command line.
Conclusion:
Learning command is very rewarding, fun, and will give you greater appreciation of what's under the hood of your OS. It's like a car - sure you can drive without ever opening the hood, but when a problem arises, you'll have idea about at least something of what you're doing, and don't have to run to a shop. Just remember what i said - learning has to be practical, and you yourself have to make it practical.
Bonus:
Here's some of the command line tools I love to use:
- elinks - this command line browser comes handy when i mess up my gui,
and have nothing but command line in tty (Ctrl+Alt+F1).
- byobu - sometimes it is nice to have bunch of indicators or tabs
like in gui. Byobu gives you exactly that in command line
- moc player - very valuable when you mess up gui, and have to fix for
hours, and while you do that - listen to music
- Htop - viewing processes, alternative to top
- nano - command line text editor. Most writing I do now is there
- olive - reading news in command line
- mutt and alpine - emails; take hours to configure, though.
- doc2txt - I'm pretty sure this item is part of another package. I usually use it to convert my professor's HW assignment into text i can read, in command line, of course
xdg-open
, a CL tool that opens files always with their predefined default applications.