May 17, 2008

Running multiple commands

Running multiple commands

When you become more familiar with the command line, you probably will need to run multiple commands. The shell let's you insert special queuing characters between commands. Here is how it is done.

[user1@server2 collections]$ command1 ; command2

The command is executed in the order it was written, but command 2 is executed even if there was an error in command 1.

[user1@server2 collections]$ command1 && command2

The command command2 is executed only if command1 was successful, no errors.

Note. You can write more than just two commands…

Multiple Virtual Terminals

Now if you really want to get fancy and execute all that you have learned…you can work on several virtual terminals or consoles. For example you might want to leave one process running in one terminal while you keep working in a different one. These terminals are called /tty1 through /tty7.

Your graphical interface normally runs on terminal seven also known as vt7 even though you are logged into a tty#.

When you execute startx you are automatically ported to vt7. By pressing the combination ATL key and any of the F1 through F7, you are switched to a different terminal, no matter if you are on your desktop.

If you are on a terminal, and you are also running the graphical interface, you can get back to your desktop by pressing, ALT & F7.

All commands you have been typing so far are running in terminal mode, which means that if you close the terminal, all the processes under that term are terminated. However on the same terminal you can run commands in the background and release the terminal for a new task.

So this is how it is done, all you have to do is place & right after command:

[user1@server2 user1]$Command &

To see which jobs have been sent to the background, type jobs at the prompt.

[user1@server2 user1]$ jobs [1]+ Running application &

Keep in mind that some commands requires super user in order to run.

No comments:

Post a Comment

Popular Posts