Optimizing your experience
Gradient background

Learning Linux

Clarice Bouwer

Software Engineering Team Lead and Director of Cloudsure

Friday, 27 July 2018 · Estimated 4 minute read

I have used Windows for over twenty years. Oh my goodness that's a long bloody time.

Now I've joined the Linux world. It's thrilling. I'm loving it, learning, sharing (and as always - documenting) what I love and learn.

Ubuntu's APT (Advanced Packaging Tool) gives you access to some cool software that you can install . Run man apt for all available options. Examples are always useful.

Want to know what you can download? apt-cache search java | grep sdk-

That brings me to pipe | Sheesh this thing is cool. It takes the output stream of the first command, sends it to the next command which does something radical with it, or maybe not, it depends on the command I guess and these commands can chain! Here are some examples.

# command_1 | command_2 | command_3 | .... | command_N
ls -a | more
sort awesome.txt | uniq
cat awesome.txt | head -7 | tail -5
cat awesome.txt | grep "value" | tree file2.txt | wc -lm

tree - It displays an indented directory tree. In your console. In color. So cool. I didn't have it installed by default so I installed it from apt.

apt-cache search "tree-"
sudo apt update
sudo apt install tree

"Displays an indented directory tree, in color"

"Displays an indented directory tree, in color"

grep - It stands for Global regular expression print and its an UBER plain-text search utility | grep <something to search for>

apt-cache search java | grep sdk
man apt | grep update
ps -ef | grep zsh
cat /etc/hosts | grep 127

Copy public key after generating one.

  • Add it to the known_hosts on a server so that you can authenticate to it.
  • Add it to your repo for SSH authentication.
sudo apt install clipit # Send data to the clipboard
sudo apt install libcanberra-gtk-module libcanberra-gtk3-module # dependencies
cat ~/.ssh/id_rsa.pub | clipit

Get system and distro information - especially useful for online support.

$ lsb_release -a # (Linux Standard Base) - prints all distribution specific information

Distributor ID:	Ubuntu
Description:	Ubuntu 18.04 LTS
Release:	    18.04
Codename:	    bionic

$ lsb_release -a | grep 18.04

$ uname -a # prints all system information
Linux oxygen 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

htop - its like top but hotter. It shows you processes. Interact with them by scrolling through them or selecting them. You can sort, tag, untag, trace, kill. Options! It comes with options!

"Interactive process viewer"

"Interactive process viewer"

shutdown from the console.

sudo shutdown now # Shutdown now | /sbin/shutdown now
man shutdown
OPTIONS The following options are understood:

    Print a short help text and exit.

-H, --halt
    Halt the machine.

-P, --poweroff
    Power-off the machine (the default).

-r, --reboot
    Reboot the machine.

  • whoami prints the effective user name.

  • Check user roles:

    # remove the spaces between the x and the colons
    cat /etc/passwd | grep clarice: x :1 # admin
    cat /etc/passwd | grep root: x :0 # root

chmod changes the file mode bits so you can set a file to read-only, executable and so forth.

sudo chmod +x awesome.sh # executable
./awesome.sh # open in that directory
/path/to/awesome.sh # open from another directory

sudo nautilus opens the file manager in admin mode giving me uber rights like being able to create folders and other admin stuff I am yet to explore.

This is dangerous territory so tread with caution.

Chromium is on the Ubuntu Software centre, but Chrome is not. Download it from their website. I needed flash and it only worked when I installed Chrome.

I installed oh-my-zsh for a better shell experience. Settings are found in ~/.zshrc

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history)

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default

Freaking sound! If I ever lose my sound card association again - because that happened 😢 - I can test my sound using aplay /usr/share/sounds/alsa/Front_Center.wav then install a bunch of drivers

sudo apt-get update;
sudo apt-get dist-upgrade;
sudo apt-get install pavucontrol linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2;
sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2;
killall pulseaudio;
rm -r ~/.pulse*;
sudo usermod -aG

cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'


I got to play around with Linux on a Rock64. So much fun!