Let your solaris in ls command become color

Source: Internet
Author: User

The directories or files displayed after the default LS is not colored in Solaris, and if you want to make it look like Linux, you need the following steps

First, go to www.sunfreeware.com download coreutils-4.5.4-sol9-sparc-local.gz

Second, the following 10 steps to complete

1. Color output is a feature of the gun version of LS command, so you have to get this version first, you can download sunfreeware.com here.

2. Install the package using the following command:

Root@host/var/tmp> pkgadd-d coreutils-4.5.4-sol9-sparc-local

You will be prompted that the following packages will be used:

1 Smccoreu coreutils (SPARC) 4.5.4

Select package (s) you wish to process (or ' all "to process)

All packages). (Default:all) [?,??, Q]: Enter

--output ommitted--

3. This process will install and gun LS as well as other useful programs to/usr/local/bin. Check this directory.

4. The documentation information for these commands can be found in the/usr/local/doc and/usr/local/man directories to read the new commands, such as color display:

User@host ~> man-m/usr/local/man dircolors

Later, confirm that Manpath variable contains/usr/local/man.

5. You can add color display settings to the entire system, and if so, you need to create a dir_colors file in the/etc directory. That's about it:

User@host ~> cat/etc/dir_colors

# Configuration file for the color LS utility

# This file is goes in The/etc directory, and must is world readable.

# You can copy this file to. dir_colors into your $HOME directory to override

# The system defaults.

# COLOR needs one of these arguments: ' TTY ' colorizes output to ttys, but not

# pipes. ' All ' adds color characters to all output. ' None ' shuts colorization

# off.

COLOR TTY

# Extra command line options for LS go.

# basically these ones are:

#-F = Show '/' for dirs, ' * ' for executables, etc.

#-T 0 = don ' T trust tab spacing when formatting ls output.

Options-f-T 0

# Below, there should be one TERM entry to each TermType this is colorizable

TERM Linux

TERM Console

TERM con132x25

TERM con132x30

TERM con132x43

TERM con132x60

TERM con80x25

TERM con80x28

TERM con80x30

TERM con80x43

TERM con80x50

TERM con80x60

TERM CONS25

TERM xterm

TERM RXVT

TERM Xterm-color

TERM Color-xterm

TERM VT100

TERM Dtterm

TERM Color_xterm

# eightbit, followed by ' 1 ' for On, ' 0 ' for off. (8-bit Output)

Eightbit 1

# Below are the color init strings for the basic file types. A Color Init

# string consists of one or more of the following numeric codes:

# Attribute Codes:

# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed

# Text Color Codes:

# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white

# Background Color Codes:

# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

NORMAL # Global default, although everything should be something.

File # Normal file

DIR 01;34 # Directory

Link 01;36 # Symbolic link

FIFO 40;33 # Pipe

Sock 01;35 # socket

BLK 40;33;01 # block device driver

CHR 40;33;01 # character device driver

Orphan 01;05;37;41 # orphaned Syminks

MISSING 01;05;37;41 # ... and the files they point to

# This is to files with Execute permission:

EXEC 01;32

# List Any file extensions like '. Gz ' or '. Tar ', would like LS

# to Colorize below. Put the extension, a space, and the color init string.

# (and any comments your want to add after a ' # ')

. cmd 01;32 # executables (bright green)

. exe 01;32

. com 01;32

. BTM 01;32

. bat 01;32

. SH 01;32

. CSH 01;32

. tar 01;31 # Archives or Compressed (bright red)

. tgz 01;31

. ARJ 01;31

. Taz 01;31

. LZH 01;31

. zip 01;31

. z 01;31

. Z 01;31

. GZ 01;31

. bz2 01;31

. BZ 01;31

. TZ 01;31

. RPM 01;31

. Cpio 01;31

. jpg 01;35 # image formats

. gif 01;35

. bmp 01;35

. XBM 01;35

. xpm 01;35

. png 01;35

. tif 01;35

6. Test whether the new settings are available and use the/usr/local/bin/ls--color command under several folders.

If you can see different colors, proceed to the next step.

7. Now we don't want to enter/usr/local/bin/ls--color every time. You can change the path variable to solve the problem:

User@host ~> export Path=/usr/local/bin: $PATH

In this way, when you enter LS, you will first search for the LS name from the/usr/local/bin path, rather than the default/usr/bin.

8. We can now call this command, but we still feel trouble because we have to enter the--color option every time. So you might want to give it an alias:

User@host ~> alias ls= ' ls--color '

It is possible that this alias cannot be used under shell/sbin/sh. You need to use a more advanced shell such as bash or Ksh.

9. Of course, when we log off, all the settings also disappear, so we need to write this setting in your shell configuration file, such as ~/.BASHRC:

User@host ~> Echo ' export path=/usr/local/bin: $PATH ' >> ~/.BASHRC

User@host ~> echo "Alias ls= ' ls--color '" >> ~/.BASHRC

10. In order for this command to be valid for all users of the system, the last two lines are written to the echo "Alias ls= ' ls--color '" >>/etc/profile.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.