What is Nu Shell? Linux systems always strive to create tools that favor our day-to-day Linux activities. Use of Linux terminal is quite crucial for System Administrators and developers, and we always require tools that can fast and easily output what we want. In this guide we will look at how to install and use Nu Shell on Linux.

Nu shell is a new Linux and Windows shell, still being developed and improved but it aims at simplifying command outputs with pipe. It comes with interesting built-in commands, is fast and easy to use. The focus of Nu shell is Pipelining which enables terminal users to own the terminal, commanding it to produce the output as needed.

Nu shell gets inspiration from other projects such as powershell and functional programming languages. Each input, for example, is seen as a sort of a structure that can be output into tables of rows which can further be piped depending on user needs. Operations such as listing and opening files or directories and output is a tabular manner. Nu shells takes pipelining a step higher allowing users to take control of their terminals. Let’s now dive to how to install and use Nu Shell in Linux.

Install Nu Shell on Linux

There are a number of ways to install Nu shell on Linux. Let us look at the various methods as below:

Option 1: Install Latest version from release pages

Run the below command on your terminal to download the latest release of Nu shell. As of this writing, the latest version is 0.24.1.

curl -s https://api.github.com/repos/nushell/nushell/releases/latest | grep browser_download_url |  cut -d '"' -f 4 | grep linux | wget -i -

Extract the archived file as below:

tar xvf nu_*_linux.tar.gz

Now copy the extracted content to your path for it to be executable

cd nu_*_linux/nushell-*/
sudo cp -R * . /usr/local/bin/

Check version of nu shell installed:

$ nu --version
nushell 0.24.1

To start Nu shell, simply use the command nu as below:

$ nu
Welcome to Nushell 0.24.1 (type 'help' for more info)
/home/lorna> 

Option 2: Install Nu Shell on Linux from crates.io

We first need to install dependencies required for Nu Shell functionality. Run the below comands depending on your distribution.

# Ubuntu/ Debian
sudo apt update
sudo apt install build-essential pkg-config libssl-dev gcc-multilib
sudo apt install libxcb-composite0-dev libx11-dev

# RHEL based distros
sudo yum -y install libxcb openssl-devel libX11-devel

# macOS
brew install openssl cmake

Nu shell is build in rust and we need to install it on our Linux system for Nu installation.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Also ensure to install the latest stable compiler using the below command:

rustup install stable

To install Nu shell on Linux, run the command below:

cargo install nu

If you need to install with more features, use the command:

cargo install nu --features=extra

Option 3: Running Nu Shell with Docker

Since I’m using Ubuntu 20.04, I need to first have Docker installed. To install Docker on Ubuntu 20.04, run the below commands

# Install dependency packages with the below command
sudo apt install apt-transport-https ca-certificates curl software-properties-common

# Add docker GPG key and docker repository to your hosts with the following commands:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

# Update packages and install Docker CE
$ sudo apt-get update

# Install Docker
sudo apt install docker-ce

Now install and run Nu Shell with Docker

$ sudo docker run -it quay.io/nushell/nu:latest
Unable to find image 'quay.io/nushell/nu:latest' locally
latest: Pulling from nushell/nu
171857c49d0f: Pull complete 
419640447d26: Pull complete 
61e52f862619: Pull complete 
7495ba04a596: Pull complete 
0b92b4a420ad: Pull complete 
Digest: sha256:81aa04e65b58232a863f243ed06bd3ccc38992880ad8623f4a508baf4e5e5d82
Status: Downloaded newer image for quay.io/nushell/nu:latest
Welcome to Nushell 0.21.0 (type 'help' for more info)
/> 

Using Nu Shell on Linux

You will notice a command like ls, instead of the normal list, it gives a structured table as below

> ls 
────┬────────────────────┬──────┬──────────┬───────────── 
#  │        name        │ type │   size   │  modified    
────┼────────────────────┼──────┼──────────┼───────────── 
 0 │ CODE_OF_CONDUCT.md │ File │   3.4 KB │ 1 hour ago   
 1 │ CONTRIBUTING.md    │ File │   1.7 KB │ 1 hour ago   
 2 │ Cargo.lock         │ File │ 156.4 KB │ 1 hour ago   
 3 │ Cargo.toml         │ File │   7.3 KB │ 1 hour ago   
 4 │ LICENSE            │ File │   1.1 KB │ 1 hour ago   
 5 │ Makefile.toml      │ File │    449 B │ 1 hour ago   
 6 │ README.build.txt   │ File │    192 B │ 1 hour ago   
 7 │ README.md          │ File │  15.9 KB │ 1 hour ago   
 8 │ crates             │ Dir  │   4.1 KB │ 1 hour ago   
 9 │ debian             │ Dir  │   4.1 KB │ 1 hour ago   
10 │ docker             │ Dir  │   4.1 KB │ 1 hour ago   
11 │ docs               │ Dir  │   4.1 KB │ 1 hour ago   
12 │ images             │ Dir  │   4.1 KB │ 1 hour ago   
13 │ pkg_mgrs           │ Dir  │   4.1 KB │ 1 hour ago   
14 │ rustfmt.toml       │ File │     16 B │ 1 hour ago   
15 │ samples            │ Dir  │   4.1 KB │ 1 hour ago   
16 │ src                │ Dir  │   4.1 KB │ 1 hour ago   
17 │ target             │ Dir  │   4.1 KB │ 28 mins ago  
18 │ tests              │ Dir  │   4.1 KB │ 1 hour ago   
19 │ wix                │ Dir  │   4.1 KB │ 1 hour ago   
────┴────────────────────┴──────┴──────────┴─────────────

We are going to sort our table above with sizes

> ls | sort-by size | reverse
────┬────────────────────┬──────┬──────────┬──────────────
 #  │        name        │ type │   size   │   modified   
────┼────────────────────┼──────┼──────────┼──────────────
  0 │ Cargo.lock         │ File │ 156.4 KB │ 18 hours ago 
  1 │ README.md          │ File │  15.9 KB │ 18 hours ago 
  2 │ Cargo.toml         │ File │   7.3 KB │ 18 hours ago 
  3 │ wix                │ Dir  │   4.1 KB │ 18 hours ago 
  4 │ tests              │ Dir  │   4.1 KB │ 18 hours ago 
  5 │ target             │ Dir  │   4.1 KB │ 2 hours ago  
  6 │ src                │ Dir  │   4.1 KB │ 18 hours ago 
  7 │ samples            │ Dir  │   4.1 KB │ 18 hours ago 
  8 │ pkg_mgrs           │ Dir  │   4.1 KB │ 18 hours ago 
  9 │ images             │ Dir  │   4.1 KB │ 18 hours ago 
 10 │ docs               │ Dir  │   4.1 KB │ 18 hours ago 
 11 │ docker             │ Dir  │   4.1 KB │ 18 hours ago 
 12 │ debian             │ Dir  │   4.1 KB │ 18 hours ago 
 13 │ crates             │ Dir  │   4.1 KB │ 18 hours ago 
 14 │ CODE_OF_CONDUCT.md │ File │   3.4 KB │ 18 hours ago 
 15 │ CONTRIBUTING.md    │ File │   1.7 KB │ 18 hours ago 
 16 │ LICENSE            │ File │   1.1 KB │ 18 hours ago 
 17 │ Makefile.toml      │ File │    449 B │ 18 hours ago 
 18 │ README.build.txt   │ File │    192 B │ 18 hours ago 
 19 │ rustfmt.toml       │ File │     16 B │ 18 hours ago 
────┴────────────────────┴──────┴──────────┴──────────────

Sort table above where size is greater than 1kb

> ls | where size > 1kb
────┬────────────────────┬──────┬──────────┬──────────────
 #  │        name        │ type │   size   │   modified   
────┼────────────────────┼──────┼──────────┼──────────────
  0 │ CODE_OF_CONDUCT.md │ File │   3.4 KB │ 18 hours ago 
  1 │ CONTRIBUTING.md    │ File │   1.7 KB │ 18 hours ago 
  2 │ Cargo.lock         │ File │ 156.4 KB │ 18 hours ago 
  3 │ Cargo.toml         │ File │   7.3 KB │ 18 hours ago 
  4 │ LICENSE            │ File │   1.1 KB │ 18 hours ago 
  5 │ README.md          │ File │  15.9 KB │ 18 hours ago 
  6 │ crates             │ Dir  │   4.1 KB │ 18 hours ago 
  7 │ debian             │ Dir  │   4.1 KB │ 18 hours ago 
  8 │ docker             │ Dir  │   4.1 KB │ 18 hours ago 
  9 │ docs               │ Dir  │   4.1 KB │ 18 hours ago 
 10 │ images             │ Dir  │   4.1 KB │ 18 hours ago 
 11 │ pkg_mgrs           │ Dir  │   4.1 KB │ 18 hours ago 
 12 │ samples            │ Dir  │   4.1 KB │ 18 hours ago 
 13 │ src                │ Dir  │   4.1 KB │ 18 hours ago 
 14 │ target             │ Dir  │   4.1 KB │ 2 hours ago  
 15 │ tests              │ Dir  │   4.1 KB │ 18 hours ago 
 16 │ wix                │ Dir  │   4.1 KB │ 18 hours ago 
────┴────────────────────┴──────┴──────────┴──────────────

Let’s open the file ‘Cargo.toml’

> open Cargo.toml
───┬─────────────────┬────────────────────┬──────────────────┬─────────────────────────────┬──────────────────┬──────────────────┬───────────────┬───────────────
 # │       bin       │ build-dependencies │   dependencies   │      dev-dependencies       │     features     │     package      │    profile    │   workspace   
───┼─────────────────┼────────────────────┼──────────────────┼─────────────────────────────┼──────────────────┼──────────────────┼───────────────┼───────────────
 0 │ [table 20 rows] │ [row ]             │ [row 32 columns] │ [row dunce nu-test-support] │ [row 33 columns] │ [row 12 columns] │ [row release] │ [row members] 
───┴─────────────────┴────────────────────┴──────────────────┴─────────────────────────────┴──────────────────┴──────────────────┴───────────────┴───────────────

Sort processes where cpu is more than 10

 ps | where cpu > 10
───┬────────┬──────────────┬─────────┬──────────┬────────┬──────────
 # │  pid   │     name     │ status  │   cpu    │  mem   │ virtual  
───┼────────┼──────────────┼─────────┼──────────┼────────┼──────────
 0 │ 120507 │ nu_plugin_ps │ Running │ 101.9613 │ 3.0 MB │ 836.5 MB 
───┴────────┴──────────────┴─────────┴──────────┴────────┴──────────

Get information about the current date by running the command date now

> date now
2020-12-16 12:48:41.147885106 +03:00

To get information about your system, run the below command:

> sys | get host
───┬───────┬──────────────────┬─────────────────────────────────────────────┬──────────┬────────┬────────────────────────┬────────────────
 # │ name  │     release      │                   version                   │ hostname │  arch  │         uptime         │    sessions    
───┼───────┼──────────────────┼─────────────────────────────────────────────┼──────────┼────────┼────────────────────────┼────────────────
 0 │ Linux │ 5.4.0-29-generic │ #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020 │ App2     │ x86_64 │ 18hr 28min 20sec 150ms │ [table 1 rows] 
───┴───────┴──────────────────┴─────────────────────────────────────────────┴──────────┴────────┴────────────────────────┴────────────────

You have successfully installed and use Nu Shell on Linux. As explained earlier, Nu is a new shell that aims to to help user manipulate inputs and outputs the best way possible. With focus on pipelining, it becomes easy to search through files and directories. I hope the guide has been of help to you.

Check other interesting guides here:

LEAVE A REPLY

Please enter your comment!
Please enter your name here