Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My Ubuntu is 12.04.

I have just started learning Linux and Ubuntu in particular. To remember commands quicker, I'd like to decline GUI.

But there are some problems. I don't know where installed programs are to launch them.

For example, I have a pdf file. I know that there is a program to view such files. Should it be the case of GUI, I would just click on the pdf-file, and have a look that I use Document Viewer 3.4.0.

Then I would like to launch Firefox Web Browser. Even if I know it is installed, how to find the file to be launched using just CLI is a mystery to me.

Could you suggest me anything.

share|improve this question
    
how to disbale GUI: askubuntu.com/questions/196603/… –  user61928 Oct 5 '12 at 11:06
3  
My suggestion is don't decline GUI completely. Sometimes you need it. Try learning commands and using GUI simultaneously. For learning commands, you can refer to answers given below :) –  mac Oct 5 '12 at 11:17
    
This is a very open question, so it's hard to find a definitive answer. But pertaining to your problems with opening files form the CLI in particular, I would advise you to use xdg-open, a CL tool that opens files always with their predefined default applications. –  Glutanimate Oct 5 '12 at 11:23
1  
This may also interest you: askubuntu.com/questions/126268/… –  Takkat Oct 5 '12 at 11:23

5 Answers 5

Honestly, for most of these programs it is enough to simply know their name. When installed from a repo, they tend to add themselves into your path, or a symbolic link to the applications binary is added into a folder in your path already.

Also, man (manuals!) is your best friend!

man apt-get | less

Then you can scroll up and down, line by line rather than having to go by entire pages, (depending on your version/distro, this may be the default functionality of man) it can be very useful when trying to get that next line of output.

And last, but definitely not least, if you are new to linux, your package manager apt-get, is going to be your best friend. For experience you should install some programs from source, but knowing your package manager and being able to search it will be invaluable as a time saver.

Hopefully this helps some.

share|improve this answer
    
"pipe man output into something like less" - can you add a simple example for us noobs? –  Torben Gundtofte-Bruun Sep 1 '13 at 20:05

Most of your executables are in /bin or /usr/bin. For example, you can find firefox in /usr/bin/firefox. Those two paths are in your $PATH, so you can choose your app with tab-completion

share|improve this answer

As stated in other answers, usually when you install a package its executables are added to common paths, so if you know the name of the application you want to use, you just have to write its name.

If you want to know the command to execute a specific application this trick can help you:

xprop | grep WM_CLASS

this will let you click in any window you have currently open and probably get you the command needed to start that application. For example, clicking in a Document Viewer (pdf reader) window i get WM_CLASS(STRING) = "evince", "Evince", being evince the command used to open Document Viewer. If it don't works you can try replacing WM_CLASS with WM_COMMAND or WM_DESKTOP_FILE (this last will show the location of the .desktop file).

If you need to know which application provides the "command" you can use which

which evince
/usr/bin/evince

But sometimes the program you are installing put their executables in some uncommon location. Take for example PostgreSQL. If you install any of the versions available in the repositories their executables are placed in /usr/lib/postgresql/<version>/bin/. If you try to execute initdb (a PostgreSQL command) the system will not be able to find the command. In a situation like this you can use apt-file to search which package provides the initdb program and where it will be placed after installing the package

apt-file search initdb
<omitted results>
postgresql-9.1: /usr/lib/postgresql/9.1/bin/initdb
<omitted results>

Also you can use locate to try to find where the command you need is. Using again initdb as an example:

locate initdb
/etc/alternatives/initdb.1.gz
/usr/lib/postgresql/9.1/bin/initdb
/usr/share/man/man1/initdb.1.gz
/usr/share/postgresql/9.1/man/man1/initdb.1.gz

Hope those tips help you.

share|improve this answer

You must know the command to each application and you can just launch that application by wrirting the command in the terminal

For example to launch firefox web browser you can just write firefox in terminal

To open gedit the same or sudo gedit to save or read for a secured directory and like that

share|improve this answer

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

enter image description here

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
share|improve this answer
    
Oh, I forgot to add midnight commander ! Command line file manager ! –  Xieerqi yesterday
    
Oh, and small note, mksh in scripts means i use Korn shell. You'd have to change that to bash, unless you're also using Korn shell –  Xieerqi yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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