Class02 Answer:

How to get started with Linux?

Now that we have Google, Linux is relatively easy to learn.

Usually when I interact with Linux, I type commands at it and then read what it tells me.

Usually this is an exchange of text.

Google is perfectly suited for text search.

If I am confused or need knowledge about Linux related information, I just send detailed English questions to Google.

Millions of others are doing the same.

As each year goes by, Google gets better and better at answering Linux questions.

If Google fails me, I take time to type up a direct, comprehensive question to stackoverflow or

I can offer some perspective on Linux which might speed your learning experience.

The way to start learning the operation of many types of systems is to list nouns and verbs.

I have fewer verbs than nouns so I list the verbs first:

Those are the big 6, but we will encounter others.

To understand my point here I will combine the first verb with a noun in a sentence:

In Linux, I Create (that's the verb) a Folder (that's the noun) like this:

mkdir myfolder

So, to get started with Linux I need to memorize how to operate on about 10 nouns with about 6 verbs which is about 60 commands.

That should be easier to learn than a foreign language which has a huge vocabulary and a complex grammar.

For computers in general I start with these nouns:

For Linux, and the above nouns, I interact with Disk the most often.

I sub-divide the Disk-noun like this:

Folder and File capture 99% more of my attention than Disk, Volume, and File-System.

For Folder, I list Verb-Noun examples below:

Some folders are so important, they have short symbols:

For File, I list Verb-Noun examples below:

For File-System, I list Verb-Noun examples below:

That wraps up the discussion about what I call the Disk-nouns.

I skipped discussing Disks and Volumes; Linux beginners rarely operate on Disks and Volumes.

For Linux, the next set of nouns are what I call the CPU-nouns:

For CPU-info, I list one Verb-Noun combination below:

For process, I list some Verb-Noun combinations below:

On Linux, after Disk-nouns and CPU-nouns, I am interested in RAM.

Usually I want to list RAM usage:

On Linux, after RAM, I am interested in Network-nouns:

For the above Network-nouns, usually the only verb I am interested in is: List.

On Linux, after Network-nouns, I am interested in User-nouns:

For the above User-nouns, I list some Verb-Noun examples below:

On Linux, after User-nouns, I am interested in Software-Package-nouns.

For Software-Package-nouns, I list some Verb-Noun examples below:

Any software which is installed with apt-get (or aptitude) should behave well.

I see that software as permanently attached to my Linux instance.

Also I see that software as owned by root and shared by all users in the instance.

Three types of software which I want constrained to a specific user and not shared are listed below:

Syntax to install bob's copy of Python is listed below:

sudo useradd -m -s /bin/bash bob
sudo passwd bob
ssh -AY bob@localhost
rm -f
mv anaconda3/bin/curl anaconda3/bin/curl_ana
echo 'export PATH=${HOME}/anaconda3/bin:$PATH' >> ~/.bashrc
conda install -c conda-forge tensorflow

Syntax to install bob's copy of Ruby 2.3.1 is listed below:

ssh -AY bob@localhost
cd ~
git clone      .rbenv
git clone .rbenv/plugins/ruby-build
echo 'export PATH="${HOME}/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"'                 >> ~/.bashrc

rbenv install 2.3.1
rbenv global  2.3.1
gem install bundler

To install Java, bob needs to download jdk-8u131-linux-x64.tar.gz from Oracle:

Syntax to install bob's copy of Java is listed below:

ssh -AY bob@localhost
tar zxf ~/Downloads/jdk-8u131-linux-x64.tar.gz
ln -s jdk1.8.0_131 jdk
echo 'export JAVA_HOME=${HOME}/jdk'       >> ~/.bashrc
echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> ~/.bashrc
java -version

Syntax to install bob's copy of Node.js is listed below:

ssh -AY bob@localhost
tar xf node-v8.0.0-linux-x64.tar.xz
ln -s  node-v8.0.0-linux-x64 node
echo 'export PATH=${HOME}/node/bin:$PATH' >> ~/.bashrc
node --help

On Linux, after Software-nouns, I am interested in Security-nouns:

For Security-nouns, I list some Verb-Noun examples below:

Linux always has a user named root who has many privileges.

I can use sudo to ask root to run commands for me.

In that case sudo is a verb.

If root does what I ask then I have sudo privilege and in that case sudo is a noun.

If I want to give sudo privilege to bob I should run a command like this:

sudo usermod -G sudo bob

Another way to give sudo privilege to bob is login as root and run this command:

usermod -G sudo bob

I have three ways to login as root:


This way is more ... complete:

su -

And, this way is more ... complete:

ssh root@localhost

Also I can use su to login as bob:

su - bob

Usually on Linux every user has an ssh-folder:

su - bob
mkdir -p  ~/.ssh
chmod 755 ~/.ssh

Usually on Linux every user has public key and private key.

bob can create public key and private key:

su - bob
ssh-keygen -t rsa
ls -l .ssh/id_rsa
ls -l .ssh/

The file .ssh/id_rsa is like a key I carry in my pocket. It should be private.

The file .ssh/ is like a lock in my car door. It is exposed to the public. The file .ssh/ is called a public key.

bob can give to dan and dan can add to ~dan/.ssh/authorized_keys:

sudo bash
cat ~bob/.ssh/ >> ~dan/.ssh/authorized_keys

Now bob has permission to login as dan:

sudo ssh dan@localhost

A pem key is a private key I get from AWS.

I like to keep my pem keys in ~dan/.ssh/

To use a pem key I create a file called ~dan/.ssh/config

I put syntax like this in the file:

Host ub170
  User ubuntu
  IdentityFile ~/.ssh/ml4uskey.pem

Then I issue a simple shell command to login:

ssh ub170

Sometimes keys will fail due to improper permissions.

If I suspect improper permissions on my keys, I issue commands like this:

cd ~/.ssh/
chmod 700 .
chmod 700 ..
chmod 600 authorized_keys
chmod 600 *.pem
chmod 600 id_rsa
chmod 644

The next noun in Linux security is iptables-firewall.

I use iptables to prevent Linux from listening for certain types of network traffic.

The less traffic I listen for, the more secure I should be.

For iptables I rely on and Google:

The next noun in Linux security is openssh-server.

I use the openssh-server to make my Linux instance listen for ssh login.

It is easy to install:

sudo apt-get install openssh-server

Sometimes I will reboot the instance after I install openssh-server:

sudo shutdown -r now


Class02 About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen