0% found this document useful (0 votes)
39 views

Linux Tricks: Tty Mode

This document discusses how to customize the command prompt and terminal colors in Linux. It explains that the PS1 variable controls the command prompt format and provides examples of special characters to customize it. To make the changes permanent, the PS1 line must be added to the ~/.bashrc file. It also demonstrates how to change directory and file colors in the terminal by modifying the LS_COLORS variable in ~/.bashrc and lists the color options. Reloading the bashrc file activates the new terminal color settings.

Uploaded by

john
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Linux Tricks: Tty Mode

This document discusses how to customize the command prompt and terminal colors in Linux. It explains that the PS1 variable controls the command prompt format and provides examples of special characters to customize it. To make the changes permanent, the PS1 line must be added to the ~/.bashrc file. It also demonstrates how to change directory and file colors in the terminal by modifying the LS_COLORS variable in ~/.bashrc and lists the color options. Reloading the bashrc file activates the new terminal color settings.

Uploaded by

john
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

LINUX TRICKS

TTY MODE

1.change font color

$ echo $PS1

[\u@\h \W]$

Customizing the PS1 Format

According to the PROMPTING section in the man page, this is the


meaning of each special character:

\u: the username of the current user.

\h: the hostname up to the first dot (.) in the Fully-Qualified Domain
Name.

\W: the basename of the current working directory, with $HOME


abbreviated with a tilde (~).

\$: If the current user is root, display #, $ otherwise.

For example, we may want to consider adding \! If we want to display


the history number of the current command, or \H if we want to display
the FQDN instead of the short server name.

Actually, we can customize 3 aspects of the prompt:


PS1="\e[41;4;33m[\u@\h \W]$ "

As good as it looks, this customization will only last for the current user
session. If you close your terminal or exit the session, the changes will
be lost.

In order to make these changes permanent, you will have to add the
following line to ~/.bashrc or ~/.bash_profile depending on your
distribution:
vi ~/.bashrc

then add at end of the file

PS1="\e[41;4;33m[\u@\h \W]$ "

2.Change terminal colors (TTY) in bashrc


To change your directory colors, open up your ~/.bashrc file with your
editor

vi ~/.bashrc

and make the following entry at the end of the file:

LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS

Some nice color choices (in this case 0;35 it is purple) are:

Blue = 34

Green = 32

Light Green = 1;32

Cyan = 36

Red = 31

Purple = 35

Brown = 33

Yellow = 1;33

White = 1;37

Light Grey = 0;37

Black = 30

Dark Grey= 1;30

The first number is the style (1=bold), followed by a semicolon, and


then the actual number of the color, possible styles are:
0 = default colour

1 = bold

4 = underlined

5 = flashing text

7 = reverse field

40 = black background

41 = red background

42 = green background

43 = orange background

44 = blue background

45 = purple background

46 = cyan background

47 = grey background

100 = dark grey background

101 = light red background

102 = light green background

103 = yellow background

104 = light blue background

105 = light purple background

106 = turquoise background


All possible colors:

31 = red

32 = green

33 = orange

34 = blue

35 = purple

36 = cyan

37 = grey

90 = dark grey

91 = light red

92 = light green

93 = yellow

94 = light blue

95 = light purple

96 = turquoise

These can even be combined, so that a parameter like:

di=1;4;31;42

in your LS_COLORS variable would make directories appear in bold


underlined red text with a green background!

You can also change other kinds of files when using the ls command by
defining each kind with:

di = directory

fi = file

ln = symbolic link

pi = fifo file

so = socket file

bd = block (buffered) special file

cd = character (unbuffered) special file

or = symbolic link pointing to a non-existent file (orphan)

mi = non-existent file pointed to by a symbolic link (visible when you


type ls -l)

ex = file which is executable (ie. has 'x' set in permissions).

*.rpm = files with the ending .rpm

After changing the bashrc file, you can activate your changes by
entering:

source ~\.bashrc

You might also like