Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, September 14, 2010

Shorthand at the Command Prompt

0 comments
  • / - root directory

  • ./ - current directory

  • ./command_name - run a command in the current directory when the current directory is not on the path

  • ../ - parent directory

  • ~ - home directory

  • $ - typical prompt when logged in as ordinary user

  • # - typical prompt when logged in as root or superuser

  • ! - repeat specified command

  • !! - repeat previous command

  • ^^ - repeat previous command with substitution

  • & - run a program in background mode

  • [Tab][Tab] - prints a list of all available commands. This is just an example of autocomplete with no restriction on the first letter.

  • x[Tab][Tab] - prints a list of all available completions for a command, where the beginning is ``x''

  • [Alt][Ctrl][F1] - switch to the first virtual text console

  • [Alt][Ctrl][Fn] - switch to the nth virtual text console. Typically, there are six on a Linux PC system.

  • [Alt][Ctrl][F7] - switch to the first GUI console, if there is one running. If the graphical console freezes, one can switch to a nongraphical console, kill the process that is giving problems, and switch back to the graphical console using this shortcut.

  • [ArrowUp] - scroll through the command history (in bash)

  • [Shift][PageUp] - scroll terminal output up. This also works at the login prompt, so you can scroll through your boot messages.

  • [Shift][PageDown] - scroll terminal output down

  • [Ctrl][Alt][+] - switch to next X server resolution (if the server is set up for more than one resolution)

  • [Ctrl][Alt][-] - change to previous X server resolution

  • [Ctrl][Alt][BkSpc] - kill the current X server. Used when normal exit is not possible.

  • [Ctrl][Alt][Del] - shut down the system and reboot

  • [Ctrl]c - kill the current process

  • [Ctrl]d - logout from the current terminal

  • [Ctrl]s - stop transfer to current terminal

  • [Ctrl]q - resume transfer to current terminal. This should be tried if the terminal stops responding.

  • [Ctrl]z - send current process to the background

  • reset - restore a terminal to its default settings

  • [Leftmousebutton] - Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode.

  • [Middlemousebutton] - Copies text from the text buffer and inserts it at the cursor location. With a two-button mouse, click on both buttons simultaneously. It is necessary for three-button emulation to be enabled, either under gpm or in XF86Config.
source: http://www.er.uqam.ca/nobel/r10735/unixcomm.html

Tuesday, August 10, 2010

Color in bash

0 comments
  • echo -e '\E[COLOR1;COLOR2mSome text goes here.'

ColorForegroundBackground
black3040
red3141
green3242
yellow3343
blue3444
magenta3545
cyan3646
white3747


Example:

  • bash$ echo -e '\E[34;47mThis prints in blue.'; tput sgr0
  • bash$ echo -e '\E[33;44m'"yellow text on blue background"; tput sgr0
       
The tput sgr0 restores the terminal settings to normal. Omitting this lets all subsequent output from that particular terminal remain blue.

The simplest, and perhaps most useful ANSI escape sequence is bold text, \033[1m ... \033[0m. The \033 represents an escape, the "[1" turns on the bold attribute, while the "[0" switches it off. The "m" terminates each term of the escape sequence.

  • bash$ echo -e "\033[1mThis is bold text.\033[0m"
       



Tuesday, July 27, 2010

Linux Bash Scripts

0 comments