Learning Linux

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


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
ssh-keygen
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!


shutdown from the console.

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

--helpq
    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:

    cat /etc/passwd | grep clarice<img class="emoji-icon" alt="emoji-x" data-icon="emoji-x" style="display: inline; margin: 0; margin-top: 1px; position: relative; top: 5px; width: 25px" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4QsFFwET1Q5mzgAABuhJREFUWMPtl11sHFcZht9z5uzOzKb2euNgx05CUqpaxYaImGxFN6kENwWpvUuU9oqLxlZvUNJWtIE6EgJhU6qCgsqVHUopEoKWH6l3FFKpUVOjWKq3Sp2EOg7Z2LHXidez69nd2Z05831ceNdZ/+T3Fo40Wml09jzveb/vvEcD/K8PsdHLC489Bs0sbaUEMYddZ87c1+Kf79sHKYThac1KCPry6Oi6OXLti5neXuRGR8W2ePxQa3Pz4TCbjUwnk/cMn04mEWazkdbm5sPb4vFDudFRMdPbe3sHph99FBNKiaTWB1Wl8isAdmhZP5wlOhkXQu8YG7treIFZdUrZZ1QqPwPgacs6OqbUn3u05h1nz6534FoqhWtbtoi9YXhQlkonivPzHe7cXItw3aEOw+hbYFaZu3Aik0xigVl1GEafcN0hd26upTg/3yFLpRN7w/DgTGuruJZKrXZgPJHAaccRTz300DMt0egvPcfZqoMAEAKGlIi1tjrU1PTKVaKTm4XQD97Cif8kk1hkVl+Usk+67lA5l0uERAAzVCQCO5HIFnz/xdNTU3/sTSR4t+MsO7BIhK9ZlphynKZL8/OWHwRgIcAAAiIUc7mEcN2h7VL2ZZnV5AZOTCaTyDKr7VL2CdcdKuZyiYAIDICFgB8EuHT9unXJcZoeNk2RIwIAGADwdrWKLtPkv3vep62GkTekTG0SwmYADCBkhq5UbFPKfXHTdLLM6WOdnfTG7OwyfO9eOIDaJUSfdN2h4uJiIqgB6mvMMTuXtR54p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iFREd0Wh+ybbTz23ZQr+9fv2mgHdbWpDOZORWosO21q86rrt+58zL8CAY3qaU/nlDyHykNb5jmjSp9bgtRMEQImWt6Ymq79tRYH+5UMh9MjU1/lxLC79TqSwH0ZLW6I3FeNJ1l64L4bVK2WI01DxH5FwjOj4RBMOdhqFf2yDhXvM8vGTb+lwQDBMAkvKnrVIm6oFVIcJMPu+5zIU9sRhf1fqmA+/5PlqkxI89b6JXqYwhxH5biCY0wM/5/nCnUvr128Trx1rjiWiULtXKoWqNWbsjZqfD8MjLpdK7cSn5eG2dlR44G4Z4wbLwludd6FIqI4DHywDNEg1M1OC/uIts/1hrfNs06XIQjFtSFgSw313exNFfl8t/6bcsfqNaXZm/7svoecvCZd8XXzHNp4UQcScM37SlDO4G3jhetG14RJGEYTzLzIWL1eqfdkajfKJSWTVvw0+zA0rBZ5ZxKQUB4R+C4J7g9fFMJAIDMApEHBWC/lqr+/9H4/gvcoQtVIUHRmIAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMTEtMDVUMTg6NDk6NTArMDA6MDAUXGOwAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTExLTA1VDEzOjUzOjQ4KzAwOjAwqyFlXwAAAABJRU5ErkJggg==" title="emoji-x" />1 # admin
    cat /etc/passwd | grep root<img class="emoji-icon" alt="emoji-x" data-icon="emoji-x" style="display: inline; margin: 0; margin-top: 1px; position: relative; top: 5px; width: 25px" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4QsFFwET1Q5mzgAABuhJREFUWMPtl11sHFcZht9z5uzOzKb2euNgx05CUqpaxYaImGxFN6kENwWpvUuU9oqLxlZvUNJWtIE6EgJhU6qCgsqVHUopEoKWH6l3FFKpUVOjWKq3Sp2EOg7Z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eqfdkajfKJSWTVvw0+zA0rBZ5ZxKQUB4R+C4J7g9fFMJAIDMApEHBWC/lqr+/9H4/gvcoQtVIUHRmIAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMTEtMDVUMTg6NDk6NTArMDA6MDAUXGOwAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTExLTA1VDEzOjUzOjQ4KzAwOjAwqyFlXwAAAABJRU5ErkJggg==" title="emoji-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

ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHOW_CHANGESET=true
POWERLEVEL9K_MODE='awesome-fontconfig'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
POWERLEVEL9K_SHORTEN_STRATEGY=truncate_from_right_
POWERLEVEL9K_VCS_HIDE_TAGS=true
POWERLEVEL9K_SHOW_CHANGESET=true
POWERLEVEL9K_VCS_SHORTEN_LENGTH=10
POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11
POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right"
POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".."
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status)

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
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}

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] ( https://help.ubuntu.com/community/SoundTroubleshootingProcedure)

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*;
ubuntu-support-status;
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'

whoami

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