Supercharge your Chromebook Linux Shell..

Supercharge your Chromebook Linux Shell..

Theres no doubt ChromeOS is a solid OS and its gaining traction fast. For me one of the most powerful areas of the eco system is the Linux Shell provided as part of the OS.

Coming from Linux desktops to have a command line available to me it a huge reason why I enjoy using Chromebooks.

Based on Debian the Linux container which is spun up when you enable Linux (Beta) on a Chromebook is a good solid base install of Debian and will work for most of your linux needs.

This post however is about sprucing up that container a little and pushing your linux environment just a little further and hopefully make it a bit more useful to use.

It goes without saying that all of these tools will run on most linux distros as well and within the links supplied there will be instructions on install and configuration. This post however is focussed on the Chromebook Linux Container.

Disclaimer:

I put these together, and I do it mainly for myself. I put them on the internet because others might want to read them and maybe learn something new or inform me if i'm wrong. While writing them the spelling and grammar will be off. Focus on the content, not the writing..

11 Linux Shell Command line tools

This isn't a deep dive, i've inclueded links so you can learn more about configuration of the tool. I'll go through the install and basic setup and a few standout features

1) Fish

fish shell
A smart and user-friendly command line shell

Fish is a replacement shell which is like bash but adds functionality, as an example tab completing, in the example below i typed in

ls

and pressed tab

I can then use the tab keys to cycle round the files in the directory (better cample might be cat).

Other nicities are the config is done via a web page, the colour palette is quickly changed and it does some good completion of man pages.

Install

sudo apt -y install fish 

Launch each time

To have fish launch each time you open the Linux shell or a new tab runthe command where <username> is the username in your shell.

sudo usermod -s /usr/bin/fish <username>

example

sudo usermod -s /usr/bin/fish david

Config File

Fish will use a config file which you need to create (nano, vi) whcih will run commands when fish launches and we will use this for some of the commands below.

.config/fish/config.fish

The layout is simply

command1
command2
command3

2) Neofetch

dylanaraps/neofetch
🖼️ A command-line system information tool written in bash 3.2+ - dylanaraps/neofetch

Neofetch is eye candy, its a predefined output which can be setup to display when running the command which outputs like this:

       _,met$$$$$gg.          david@penguin 
    ,g$$$$$$$$$$$$$$$P.       ----------------- 
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 10 (buster)
 ,$$P'              `$$$.     Host: crosvm 
',$$P       ,ggs.     `$$b:   Kernel: 5.4.88-12224-gf05236dbdecf 
`d$$'     ,$P"'   .    $$$    Uptime: 11 hours, 49 mins 
 $$P      d$'     ,    $$P    Packages: 1014 (dpkg), 7 (flatpak) 
 $$:      $$.   -    ,d$$'    Shell: fish 3.0.2 
 $$;      Y$b._   _,d$P'      Resolution: 2256x1504, 6144x1920 
 Y$$.    `.`"Y$$$$P"'         Theme: CrosAdapta [GTK2/3] 
 `$$b      "-.__              Icons: CrosAdapta [GTK2/3] 
  `Y$$                        Terminal: ld-linux-x86-64 
   `Y$$.                      CPU: 06/8e (8) @ 2.304GHz 
     `$$b.                    GPU: Red Hat, Inc Virtio GPU 
       `Y$$b.                 Memory: 13MiB / 6604MiB 
          `"Y$b._
              `"""                                    

The logo will adapt to the OS you're running.

running --help at the end of the neofetch command line displays a large number of switches for customisation.

Install

sudo apt install neofetch

Config File

To make neofetch run when you open a new shell, if you have fish running is as simple as

nano .config/fish/config.fish

and add the line (file may be empty if you've not added any other startup options

neofetch

Save and close the file.

Open a new Shell tab

3) Starship

Starship: Cross-Shell Prompt
Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, and Powershell.

Starship is a prompt customisation tool which uses Toml files to configure your bash/fish prompt.

Install

curl -fsSL https://starship.rs/install.sh | sudo bash

Add to Fish

Add to the fish config in .config/fish/config.fish

nano .config/fish/config.fish

the line

starship init fish | source 

Open a new tab.

Config

A config file needs to be created

mkdir -p ~/.config && touch ~/.config/starship.toml

An example config file looks like this

# Don't print a new line at the start of the prompt
add_newline = false

# Replace the "❯" symbol in the prompt with "➜"
[character]                            

# The name of the module we are configuring is "character"

success_symbol = "[➜](bold green)"     

# The "success_symbol" segment is being set to "➜" with the color "bold green"

# Disable the package module, hiding it from the prompt completely
[package]
disabled = true

# Use custom format
format = """
[┌───────────────────>](bold green)
[│](bold green)$directory$rust$package
[└─>](bold green) """

# Wait 10 milliseconds for starship to check files under the current directory.
scan_timeout = 10

# Disable the newline at the start of the prompt
add_newline = false

#add username to the prompt
[username]
style_user = "white bold"
style_root = "red bold"
format = "user: [$user]($style) "
disabled = false
show_always = true

#follow the username with the hostname
[hostname]
ssh_only = false
format =  "on [$hostname](bold red) "
disabled = false

Gives me a prompt that looks like this

The configuration options are plenty and various and found here

Starship: Cross-Shell Prompt
Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! Shows the information you need, while staying sleek and minimal. Quick installation available for Bash, Fish, ZSH, Ion, and Powershell.

Examples

If i run a

sudo apt update

then i get the expected output of

➜ sudo apt update
Hit:1 http://ppa.launchpad.net/ansible/ansible/ubuntu trusty InRelease
Hit:2 http://packages.microsoft.com/repos/code stable InRelease           Hit:3 https://download.docker.com/linux/debian buster InRelease           Get:4 https://deb.termius.com squeeze InRelease [4,310 B]
Hit:5 https://deb.debian.org/debian buster InRelease
Hit:6 https://deb.debian.org/debian-security buster/updates InRelease
Ign:7 https://storage.googleapis.com/cros-packages/89 buster InRelease
Hit:8 https://storage.googleapis.com/cros-packages/89 buster Release
Get:9 https://deb.termius.com squeeze/main amd64 Packages [838 B]
Hit:11 https://apt.syncthing.net syncthing InRelease          
Fetched 5,148 B in 6s (911 B/s)                    
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
~/cert took 6s 

The prompt has told me how long it takes to run the command

 ~/cert took 6s

4) tmux

tmux/tmux
tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.

Theres so much you can do with tmux is crazy, at its heart is a system which you can launch, run commands withing a screen, detatch from that screen then come back to it later to see if the process has finished. However it can also be a system where you split a terminal into windows and run commands in each window.

If you spend a lot of time running proceses in linux or want to run several command line applications at the same time while troubleshooting, or ssh into multiple remote servers in the same screen, this may be the tool for you.

Install

sudo apt install tmux

Config

The internet is full of tmux cheat sheets so I won't run through it here have a look at these two pages for an overview

tmux/tmux
tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.
Tactical tmux: The 10 Most Important Commands | Daniel Miessler
Shows you how to install and use Tmux in the shortest time possible, from installation to creating and managing sessions…

Example

If i wanted to  run some cli applications I could run

tmux new-session \; \
send-keys 'mytop' C-m \; \
split-window -v \; \
send-keys 'sudo lazydocker' C-m \; \
split-window -h \; \
send-keys 'top' C-m \;

Which runs bpytop across the top of the termina, lazydocker to the bottom left and top to the bottom right as displayed here.

5) tmate

tmate • Instant terminal sharing

Once you've got your head around tmux, tmate is an interesting bit of software for charing ssh sessions so others can see/use them.

Install

sudo apt-get install tmate

Run

In this vide i have two tabs open, in reality these will be two different machines. I run tmate in one tab and then copy the generated ssh command and run that in the 2nd tab at which point i'm able to see the same output on both tabs

This is useful for training or remote viewing of tmux sessions. Its also interesting because i'm able to view the session on my Linux shell on a chromebook from a remote server.

6) bpytop

aristocratos/bpytop
Linux/OSX/FreeBSD resource monitor. Contribute to aristocratos/bpytop development by creating an account on GitHub.

Having provided Fish instead of stock Bash, and setup the command prompt this is an enhanced version of the top tool for seeing in a very pretty way what is happening in your linux container.

You will need pip3 installed.

Install

pip3 install bpytop --upgrade

Configure

Once installed a message will be displayed with the following:

The script bpytop is installed in '/home/fieldymac/.local/bin' which is not on PATH.Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

I "solved" this by running this (i've used mytop because I keep forgetting the name of the program)

sudo ln -s /home/fieldymac/.local/bin/bpytop /usr/local/bin/mytop

and running

mytop


7) glances

Glances - An Eye on your system
Glances is a cross-platform curses-based system monitoring tool written in Python.

Glances is very similar to bpytop its an enhanced top command cli tool with the addition that you can also see the output in your web browser

Install

sudo pip3  install glances
sudo pip3 install bottle

Usage

Running glances on the command line on its own in the command line

glances

and running glances with -w provides

glances -w

Glances Web User Interface started on http://0.0.0.0:61208/

So navigate to

http://penguin.linux.test:61208/

In Chrome and you will see a realtime process output in your browser for the Linux container.

8) lazydocker

jesseduffield/lazydocker
The lazier way to manage everything docker. Contribute to jesseduffield/lazydocker development by creating an account on GitHub.

I fun docker-ce in my Linux container on the Chromebook mainly for testing before i deploy something I've written. I recently found lazydocker as a nice CLI GUI for looking at the docker containers. There are tools like portainer.io for doing this in the web, however something in the command line with TMUX makes for a very useful setup.

Install

sudo curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash

Run

sudo lazydocker

Example

A quick run through with the lazy docker command.

9) thefuck

nvbn/thefuck
Magnificent app which corrects your previous console command. - nvbn/thefuck

Other than being the best, most aptly named project on Github if you are learning linux or have fat fingers like me this is a great command. Essentailly if a command fails, it attempts to tell you what you should be typing and gives that a go (with a y/n prompt)

Install

sudo pip3 install thefuck
Seems like fuck alias isn't configured!Please put thefuck --alias | source in your ~/.config/fish/config.fish and apply changes with fish or restart your shell.

Configure

Add to the fish config in .config/fish/config.fish

nano .config/fish/config.fish

the line

thefuck --alias | source 

Open a new tab.

Example

A simple example of misspelling apt-get

❯ aptget install nmap
fish: Unknown command aptget

~/cert❯ fuck
​​​​​​​​​​apt-get install nmap [enter/↑/↓/ctrl+c]

10) iptraf

IPTraf - An IP Network Monitor

If you want to see what is happening on any of the network cards on your Linux shell

Install

sudo apt install iptraf

Run

sudo iptraf-ng

Examples

For such a small command it does a lot, the --help swith is really useful if you want to capture what is going on on a specific port and output that to a log for a specific time which lends itself to some great scripting capabilities.

 sudo iptraf-ng --help
usage: iptraf-ng [options]
   or: iptraf-ng [options] -B [-i <iface> | -d <iface> | -s <iface> | -z <iface> | -l <iface> | -g]

-h, --help            show this help message

-i <iface>            start the IP traffic monitor (use '-i all' for all interfaces)
-d <iface>            start the detailed statistics facility on an interface
-s <iface>            start the TCP and UDP monitor on an interface
-z <iface>            shows the packet size counts on an interface
-l <iface>            start the LAN station monitor (use '-l all' for all LAN interfaces)
-g                    start the general interface statistics

-B                    run in background (use only with one of the above parameters
-f                    clear all locks and counters
-t <n>                run only for the specified <n> number of minutes
-L <logfile>          specifies an alternate log file

11) lazygit

jesseduffield/lazygit
simple terminal UI for git commands. Contribute to jesseduffield/lazygit development by creating an account on GitHub.

From the person who brought LazyDocker into my life is also LazyGit a cli git interface which responds to mouse input.

Install

go get github.com/jesseduffield/lazygit
sudo ln -s /home/**<USER**/go/bin/lazygit /usr/local/bin/lazygit

Run

From a folder with a git repo in it run

lazygit

or run

lazygit -p </path/to/git/repo/>

Further Reading

The Chromebook Linux Shell (Update 3)
The Linux shell is an amazing thing and I’m just starting to learn what can be one using it in Crostini.
agarrharr/awesome-cli-apps
🖥 📊 🕹 🛠 A curated list of command line apps. Contribute to agarrharr/awesome-cli-apps development by creating an account on GitHub.
16 Useful Bandwidth Monitoring Tools to Analyze Network Usage in Linux
In this article, we will review 16 useful system and network bandwidth monitoring tools to analyze network traffic usage on a Linux system.

Share Tweet Send
0 Comments
Loading...
You've successfully subscribed to Tech Blog Posts - David Field
Great! Next, complete checkout for full access to Tech Blog Posts - David Field
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.