Basic Linux command line terms to know
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4044
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
if something isn't working, say a sound app that's crashed then won't restart or play properly, open up your terminal window:

type in: ps aux
hit enter, this will give you a list of processes the system is using, you can then use:

kill [process PID number]

something like:

kill 3678

That will get rid of the crashed thing and allow the app to run again, all things going well. You only have to kill the first process listed for that application listed, at least that's what I've found so far.

To get a list of the top processes running in real time, type in:
and you'll see a live updating of the current processes and what system resources are being used, pretty interesting if things like that interest you.
[ read more at techrepublic]
To find the path to a program, maybe to add it as a default type somewhere, type in:
which [program name]

for example,
which firefox

will give you path to your firefox application, perhaps

Then you can use that information to navigate to the program, if you want to make a shortcut or something.
For more commands, check out this informative site, they've got a nice index of the basic commands, click on each and it gives more options, switches, and so on, and other possible commands, very nicely done.
Back to top
Command Line Crazy!
Status: Interested
Joined: 15 Oct 2004
Posts: 13
Reply Quote
Saying goodbye to the good ol GUI and working from the command line can be extremely frustrating, extremely fun, and an extremely rewarding computing experience (usually all at the same time). Nobody is about to argue that UNIX *style* Operating Systems Including Linux and UNIX itself have the best command line environments on the planet. I'll try to post some interesting and useful command line acrobatics here periodically for amusement.

UNIX has always been a multi-user, multi-tasking operating system. The ability for multiple users to run multiple jobs was one of the main things that kept it on top even when significantly cheaper alternative such as MS-DOS were so commonplace. The problem is... how could you possibly perform more than one task from one command line? The answer is Jobs.

A job is a process or group of processes associated with a task that you are performing on the machine. Jobs are a way that your shell lets you switch between tasks, pause tasks, run tasks in the background, etc. The most basic and most common job manipulation tools are as follows:

& (put it at the end of a command line to run the job in the background and get your command line back immediately)

jobs (Displays a list of all jobs running in your session)

fg (jobnumber/name) (brings the specified job number/name back to the foreground of your terminal)

bg (jobnumber/name) (puts the specified job number/name in the background of your terminal)

control-z (takes the command that is currently in the FG, pauses it, and gives you your command line back)

Here is a real life example of how a job would work.

lets say you've got a command that takes a long time to complete, such as updatedb. updatedb is a command that catalogs ever file on your machine, and puts it into a text file so the locate command can search for a file quickly and easily without actually listing the entire contents of the computer (like the find command and Windows Search tool do).

Ok, lets say that you know it is going to take a long time and want to have it run in the background from the get go. All you would need to do is put a & at the end of the command, and it will run in the background.

:: Code ::
[root@damachine root]# updatedb &
[1] 23895

Now lets examine what we've got here. [root@damachine root]# is simply the command prompt looks on my machine when I am logged in as root. We'll ignore this part for the rest of the examples. Now the next part, [1] , is the Job number. You can refer to the job number when using any of the commands associated with manipulating jobs. The number 23895 is what's known as the PID. The PID can be used with various commands. The previous post by techAdmin showed us how we can use the PID with the kill command.

So great, we've got a "backgrounded" command, what's next? Well, if we just let it sit there, after the command completed, the next time we hit enter at that terminal it would tell us:

:: Code ::
[root@damachine root]#
[1]+  Done                    updatedb

This kindly lets us know that the job has completed without errors.

What if we wanted to do something with it? What can we do with it? First of all, lets find out how we list the running jobs in a terminal.

:: Code ::
[root@damachine root]# jobs
[2]+  Stopped                 gcc ./hello.c
[3]-  Running                 updatedb &

Much like when our command has completed, this shows us the job number, status, and command name. Here we can see that I have stopped a job called "gcc ./hello.c". (this would use the gcc C compiler to compile the hello.c file, and in the middle of that job, I pressed control-z to stop or pause the job) and one job running in the background called "updatedb &". We can bring either of these jobs to the foreground by typing fg (jobnumber). Any stopped (paused) job that is running can be put in the background by simply saying bg (jobnumber)

Especially if your GUI is broken, or you have to work over SSH without X11 forwarding, jobs can be one of those things that makes a pain in the neck of a situation just a little bit better.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours