Sunday, January 6, 2013

How long does it take for a Linux terminal command to process or complete?

Q. This might be an impossible question to answer, but I would like to know, trying to write something in Bash so I need this question answered.

Maybe showing system specs might help:
233 Mhz Pentium II
64 MB RAM
Terminal is loaded on HDD

The computer I am using is an old Toshiba Satellite 4000CDT.

So how long do you think it would take to execute a bash command, such as
"echo"?

A. just remember to press CTRL + C to break the command if its taking too long

In Ubuntu Linux what is the Terminal command to close a window?
Q. I have an application that opens at launch to allow me to use my Gamepad to control the mouse and arrow keys. This application also opens a window so I would like a terminal command that I can program to close the window at startup. Thank you.

A. Your question is worded a bit oddly but I think you're looking for System > Preferences > Startup Applications

=) hope that helps!

How do I set Linux terminal to change font color/size for my commands vs. output?
Q. I would like terminal to display my commands in a different color or size (so that they stand out) than the output after running the command. Any suggestions?

A. Most unix shells (including BASH, which is probably what you're using if you're on a modern Linux distro) support customizing your shell prompt using the PS1 environment variable. While you _could_ set up colours in your terminal shell program (assuming it supports this), I'd recommend the PS1 approach, because: 1) It'll work regardless of which terminal shell program you use, and 2) if you connect to multiple machines, then you can easily make this change on all of them by just copying the BASH config onto each machine.

Typically you'd set the value of PS1 in your bash profile or rc file file (I'd recommend .bashrc in your home-directory). From that point forward, anytime you open up a terminal, it'll show whatever prompt you set up in PS1. You can customize what text appears (e.g. the hostname, current working directory, etc), and also set colours. For example, here is what I typically have at the end of my .bashrc file for my custom prompts:

# Shell prompt and fields
export PS1_USERNAME='\[\e[1;36m\]\u\[\e[m\]\100'
export PS1_HOSTNAME='\[\e[1;33m\]\h\[\e[m\]:'
export PS1_DIR='\[\e[1;32m\]\w\[\e[m\]'
export PS1_PROMPT='\[\e[1;31m\]\$\[\e[m\]'

export PS1='['${PS1_USERNAME}${PS1_HOSTNAME}${PS1_DIR}'] '${PS1_PROMPT}' '


What this shows is a prompt like the following (assuming I'm user "jsmith" on machine "bigbox" in directory "/var/log":

[jsmith@bigbox:/var/log] #

Where the username's in cyan, the machine name's in yellow, the directory's in green, and the # character's in red. Actual commands I type in are in the standard white (you can change this by not resetting the colour at the end of the PS1 prompt).

Output is harder to change the colour for. So if you want your typed commands to be coloured differently than your output, simply change the colour of your typed commands in PS1 instead.

You can create incredibly customized (and complicated) prompts with a bit of effort. Take a look at the two links in my Source(s) section below, for some good help on this subject.

Hope this helps;

Wire




Powered by Yahoo! Answers

No comments:

Post a Comment