Ah, the command line. So misunderstood, and yet so useful.
There are still some people who shy away from Linux because they believe that regularly jumping to the terminal is a must when using it. Power users often reside there, that’s true, but I know more than a few people who’ve been using Linux for years and who’ve never once been on the command line.
While I don’t believe that you need to use the command line to get the most out of Linux, a little knowledge of the command line can go a long way. Let’s look at three useful terminal commands. You might not always use them, but they can come in handy when you need them.
Use ps to display information about the applications and processes that are running on your computer. The command displays several bits of information including a numeric identifier for an application or process (called its PID), the name of the user who started application, and more.
The ps command has a number of options, but you really only need to know one of them. To see what applications and processes are currently running, type:
ps -u [your-user-name]
Where [your-user-name] is just that. In my case, for example, that’s scott.
What you wind up with is a long list. You’ll need to scroll up in the terminal window to see all of it. You can get around that by typing:
ps -u [your-user-name] | more
Adding | more to the command puts what’s essentially a page break what ps spits out. Here’s an example:
Press the spacebar on your keyboard to move to the next page.
Use the kill command to shut down an unresponsive program. The program that you’re shutting down doesn’t need to be a command line program, either — it can be one running on your desktop, too.
To use the kill command, you first need to get the PID of the program that’s frozen using the ps command. A program’s PID is the number on the left side of the screen, as shown below:
Once you have the PID, type this at the command line:
Let’s say that the Firefox web browser has decided to stop responding. Use the ps command to get it’s PID — here’s an example:
In this case, Firefox’s PID is 4109. Now, type this at the command line:
If that doesn’t work, you can add -9 to the command to brute force the shutdown of Firefox (or any stubborn program), like this:
kill -9 4109
Use the which command to find the executable file for an application. It searches the directories listed in the
PATH environment variable set in a file called .profile, which resides in your /home directory.
Why use it? I find which to be useful when I need to add an application to a menu using a utility like Pin It! Using which is faster than stumbling around in a file picker.
To run the command, type this in a terminal window:
So, if you want to find where the executable pdflatex resides, type:
The command display the full path to the executable file — for example, /usr/bin/pdflatex.
As I mentioned at the top of this post, you might only use these commands once in a while. But they’re definitely handy when you need them.