Difference between revisions of "How To Use "ls" In Color"

From WebOS Internals
Jump to navigation Jump to search
m (moved link outside of category)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
You may also want to check out [[Colorful Bash Prompt]].
 +
 +
= Coreutils Method:=
 +
 +
=== Prerequisites:===
 +
1)  [[Portal:Accessing_Linux|Rooted]] Pre
 +
 +
2)  [[Next_steps|Ipkg-opt & unprivileged user]] installed & configured
 +
 +
3)  Dropbear/OpenSSH installed
 +
 +
4)  Connect & Log Into the Pre
 +
 +
=== Assumptions:===
 +
1)  You are using [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] to connect to the Pre
 +
 +
2)  You have made a SSH connection to the Pre.
 +
 +
=== Installing Coreutils in user mode:===
 +
 +
''Make sure ipkg-opt is up to date''
 +
<pre><nowiki>1)  sudo ipkg-opt update</nowiki></pre>
 +
 +
''Install coreutils to /opt/bin''
 +
<pre><nowiki>2)  sudo ipkg-opt install coreutils</nowiki></pre>
 +
 +
''Add an ls alias in /home/root/.profile or /etc/profile.d/optware-coreutils''
 +
<pre><nowiki>3)  Add the following line:  alias ls='/opt/bin/ls --color'</nowiki></pre>
 +
 +
''Test your changes by logging out and log back in''
 +
<pre><nowiki>
 +
4)  exit
 +
5)  reconnect to your Pre & log in
 +
6)  ls -l /
 +
</nowiki></pre>
 +
 +
If the directories in / are dark blue, you have succeeded! 
 +
 +
=== Rationale===
 +
Use of 'ls' segfaults as root with BusyBox when combined with --color (see above notes). rwhitby and eno helped to resolve this through the use of Coreutils, which takes up just slightly more space than busybox and can be more useful on Linux systems.  ''Credit:  ultraBlack''
 +
 
= BusyBox Method:=
 
= BusyBox Method:=
  
Line 18: Line 59:
  
 
=== Installing Busybox in User mode:===
 
=== Installing Busybox in User mode:===
//Make sure ipkg-opt is up to date//
+
''Make sure ipkg-opt is up to date''
 
<pre><nowiki>
 
<pre><nowiki>
 
1)  sudo ipkg-opt update
 
1)  sudo ipkg-opt update
 
</nowiki></pre>
 
</nowiki></pre>
//Install busybox to /opt/bin//
+
''Install busybox to /opt/bin''
 
<pre><nowiki>
 
<pre><nowiki>
 
2)  sudo ipkg-opt install busybox
 
2)  sudo ipkg-opt install busybox
 
</nowiki></pre>
 
</nowiki></pre>
//Verify /opt/bin is in your path//
+
''Verify /opt/bin is in your path''
 
<pre><nowiki>
 
<pre><nowiki>
 
3)  echo $PATH
 
3)  echo $PATH
Line 39: Line 80:
 
# update may require the alias to be made once more.
 
# update may require the alias to be made once more.
 
</nowiki></pre>
 
</nowiki></pre>
//Test your changes by logging out and log back in//
+
''Test your changes by logging out and log back in''
 
<pre><nowiki>
 
<pre><nowiki>
 
5)  exit
 
5)  exit
Line 49: Line 90:
 
''' If the directories are dark blue, you have succeeded!  Should the changes not apply, reboot the Pre.  If it still doesn't work, go back to step 1 and try again. '''
 
''' If the directories are dark blue, you have succeeded!  Should the changes not apply, reboot the Pre.  If it still doesn't work, go back to step 1 and try again. '''
  
//Optionally, if you want ls to display in color while logged in as root (sudo su -)..//
+
''Optionally, if you want ls to display in color while logged in as root (sudo su -)..''
 
<pre><nowiki>
 
<pre><nowiki>
 
9)  sudo su -
 
9)  sudo su -
Line 62: Line 103:
 
If you "sudo su -" without applying the above change and attempt to run /opt/bin/ls --color, it will segfault.  See above.  Rwhitby, eno, and ultraBlack have confirmed this bug.  This does not affect user mode; only as root in a specific circumstance.
 
If you "sudo su -" without applying the above change and attempt to run /opt/bin/ls --color, it will segfault.  See above.  Rwhitby, eno, and ultraBlack have confirmed this bug.  This does not affect user mode; only as root in a specific circumstance.
  
//(Needs Verification)// If you upgrade your WebOS, you may need to repeat steps 8-12 again to enable color as root user.
+
''(Needs Verification)'' If you upgrade your WebOS, you may need to repeat steps 8-12 again to enable color as root user.
  
 
=== Rationale:===
 
=== Rationale:===
Line 70: Line 111:
 
=== How To Undo:===
 
=== How To Undo:===
  
//User mode color//
+
''User mode color''
 
<pre><nowiki>
 
<pre><nowiki>
 
1)  sudo ipkg-opt remove busybox
 
1)  sudo ipkg-opt remove busybox
 
</nowiki></pre>
 
</nowiki></pre>
  
//Root user color//
+
''Root user color''
 
<pre><nowiki>
 
<pre><nowiki>
 
1)  Do step 1 above  
 
1)  Do step 1 above  
Line 84: Line 125:
 
6)  ls
 
6)  ls
 
</nowiki></pre>
 
</nowiki></pre>
 
= Coreutils Method:=
 
 
=== Prerequisites:===
 
1)  [[Portal:Accessing_Linux|Rooted]] Pre
 
 
2)  [[Next_steps|Ipkg-opt & unprivileged user]] installed & configured
 
 
3)  Dropbear/OpenSSH installed
 
 
4)  Connect & Log Into the Pre
 
 
=== Assumptions:===
 
1)  You are using [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] to connect to the Pre
 
 
2)  You have made a SSH connection to the Pre.
 
 
=== Installing Coreutils in user mode:===
 
 
//Make sure ipkg-opt is up to date//
 
<pre><nowiki>1)  sudo ipkg-opt update</nowiki></pre>
 
 
//Install coreutils to /opt/bin//
 
<pre><nowiki>2)  sudo ipkg-opt install coreutils</nowiki></pre>
 
 
//Add an ls alias in /home/root/.profile or /etc/profile.d/optware-coreutils//
 
<pre><nowiki>3)  Add the following line:  alias ls='/opt/bin/ls --color'</nowiki></pre>
 
 
//Test your changes by logging out and log back in//
 
<pre><nowiki>
 
4)  exit
 
5)  reconnect to your Pre & log in
 
6)  ls -l /
 
</nowiki></pre>
 
 
If the directories in / are dark blue, you have succeeded! 
 
 
=== Rationale===
 
Use of 'ls' segfaults as root with BusyBox when combined with --color (see above notes). rwhitby and eno helped to resolve this through the use of Coreutils, which takes up just slightly more space than busybox and can be more useful on Linux systems.  //Credit:  ultraBlack//
 

Latest revision as of 03:03, 3 August 2009

You may also want to check out Colorful Bash Prompt.

Coreutils Method:

Prerequisites:

1) Rooted Pre

2) Ipkg-opt & unprivileged user installed & configured

3) Dropbear/OpenSSH installed

4) Connect & Log Into the Pre

Assumptions:

1) You are using PuTTY to connect to the Pre

2) You have made a SSH connection to the Pre.

Installing Coreutils in user mode:

Make sure ipkg-opt is up to date

1)  sudo ipkg-opt update

Install coreutils to /opt/bin

2)  sudo ipkg-opt install coreutils

Add an ls alias in /home/root/.profile or /etc/profile.d/optware-coreutils

3)  Add the following line:  alias ls='/opt/bin/ls --color'

Test your changes by logging out and log back in

4)  exit
5)  reconnect to your Pre & log in
6)  ls -l /

If the directories in / are dark blue, you have succeeded!

Rationale

Use of 'ls' segfaults as root with BusyBox when combined with --color (see above notes). rwhitby and eno helped to resolve this through the use of Coreutils, which takes up just slightly more space than busybox and can be more useful on Linux systems. Credit: ultraBlack

BusyBox Method:

If you've been spoiled by other Linux OS distros that use color to help easily identify files & directory structures, and found the Pre to be somewhat wanting in this area, read on:

Prerequisites:

1) Rooted Pre

2) Ipkg-opt & unprivileged user installed & configured

3) Dropbear/OpenSSH installed

4) Connect & Log Into the Pre

Assumptions:

1) You are using PuTTY to connect to the Pre

2) You have made a SSH connection to the Pre

Installing Busybox in User mode:

Make sure ipkg-opt is up to date

1)  sudo ipkg-opt update

Install busybox to /opt/bin

2)  sudo ipkg-opt install busybox

Verify /opt/bin is in your path

3)  echo $PATH

# If /opt/bin is listed in the path, then you have correctly fulfilled prerequisite #2 
# Example: /usr/local/bin:/usr/bin:/bin:/opt/bin

4)  sudo alias ls='/opt/bin/ls --color'

# It is not necessary to add alias to /etc/profile or /etc/profile.d/optware.
# The alias will persist after rebooting the Pre, however a WebOS 
# update may require the alias to be made once more.

Test your changes by logging out and log back in

5)  exit
6)  reconnect to your Pre & log in
7)  cd /
8)  ls

If the directories are dark blue, you have succeeded! Should the changes not apply, reboot the Pre. If it still doesn't work, go back to step 1 and try again.

Optionally, if you want ls to display in color while logged in as root (sudo su -)..

9)  sudo su -
10)  cd /bin
11)  mv ls ls.old
12)  ln -s /opt/bin/busybox /bin/ls
13)  ls

Caveats:

If you "sudo su -" without applying the above change and attempt to run /opt/bin/ls --color, it will segfault. See above. Rwhitby, eno, and ultraBlack have confirmed this bug. This does not affect user mode; only as root in a specific circumstance.

(Needs Verification) If you upgrade your WebOS, you may need to repeat steps 8-12 again to enable color as root user.

Rationale:

There are several issues with Palm's implementation of busybox, including the inability to specify --color. Palm's busybox will error out. This method is designed to give user mode color while root gets the default B&W //unless you apply the optional root change//. Following steps 1-7 will allow root to behave as if busybox-opt wasn't installed.

How To Undo:

User mode color

1)  sudo ipkg-opt remove busybox

Root user color

1)  Do step 1 above 
2)  sudo su -
3)  cd /bin
4)  rm ls
5)  mv ls.old ls
6)  ls