Introduction to Linux
by Matt Thomas @matsinet
A Linux distribution (often abbreviated as distro) is an operating system made from a software collection, which is based upon the Linux kernel and, often, a package management system.
Per lwn.net... "Almost six hundred Linux distributions exist, with close to five hundred out of those in active development."
The Debian Project is an association of individuals who have made common cause to create a free operating system. This operating system that we have created is called Debian.
Debian systems currently use the Linux kernel or the FreeBSD kernel. Linux is a piece of software started by Linus Torvalds and supported by thousands of programmers worldwide. FreeBSD is an operating system including a kernel and other software.
Base of numerous distributions.
Ubuntu is an open source software platform that runs from the cloud, to the smartphone, to all your things
Target platforms
Based on Debian
My personal favorite at the moment.
A lightweight and flexible Linux® distribution that tries to Keep It Simple.
Red Hat® Enterprise Linux® delivers military-grade security, 99.999% uptime, support for business-critical workloads, and so much more. Ultimately, the platform helps you reallocate resources from maintaining the status quo to tackling new challenges. It's just 1 reason why more than 90% of Fortune Global 500 companies use Red Hat products and solutions.
Variations: Enterprise, CentOS & Fedora Linux
The purpose of Linux Mint is to produce a modern, elegant and comfortable operating system which is both powerful and easy to use.
Based on Ubuntu and thus Debian
Debian variant designed for Raspberry Pi
Small in size (8Gb), runs off Micro SD card.
Not Linux by definition, but is a Unix variant
By default, the terminal in OS X is Bash so commands work just like Linux
or as you probably know it better as...
This is the oldest shell and as such is not as feature rich as many of the other shells.
The c shell syntax is taken from the C programming language. As such it is a useful tool for anyone familiar with programming C.
The Bash shell is a combination of features from the Bourne Shell and the C Shell. It's name comes from the Bourne Again SHell. It has a command-line editor that allows the use of the cursor keys in a more "user friendly" manner than the Korn shell. It also has a useful help facility allowing you to get a list of commands by typing the first few letters followed by the "TAB" key. It is the default shell on most Linux distributions.
List file & directories (DOS equivalent is dir)
* is the wildcard
ls -l
List files and directory long format and show permissions
ls -a
List files and directory including hidden files
ls -h
List files and directory using human readable file size
ls -lah
Combining them all together
Change directory
cd ~
(tilde) Change to your home directory
cd -
(dash) Change to previous directory
Copy
cp -R
Copy recursively including directories
Remove
rm -R
Remove recursively
rm -f
Remove forcefully i.e.: don't ask if this is what I really mean!
Linux Shell does NOT have a recycle bin! ... Be warned, there is no turning back.
rm -Rf
Remove recursively and forcefully.... Again be warned!
Command History, lists commands executed recently
Use the !## (Bang aka Exclamation Point) to execute a previous command
Up and down arrow keys can be used to navigate previous commands as well
Outputs the contents of a file to the terminal
cat <file(s)>
Search a file for a given pattern or regex
grep <patttern/regex> <file(s)>
Taak Manager
Human readable task manager
Shuts down or restartt the computer gracefully after a given time period.
shutdown -h now
Shuts down (halts) the computer now
shutdown -r now
Restarts the computer now
shutdown -r 01:00 "The system will reboot at 1 AM"
Restarts the computer at 1:00 AM sending the message to all logged in users via terminal.
At 12:55 AM all new log in attempts will be blocked until after the reboot.
shutdown -c
Cancels a pending shutdown
Nano
Vim (VI)
GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality.
There is only 1 mode in Nano, Edit.
Commands are executed using Ctrl (^) + Letter combinations i.e.: ^x to exit.
Linux: http://www.vim.org/
Mac: http://macvim-dev.github.io/macvim/
Vim includes most all basic features from VI. For this Intro they can be interchanged.
Vim also has numerous additional features inlcuding:
Command (esc)
Enter commands such as goto line, search, find and replace
Insert (i,I,a,A,o,O)
Insert new characters, Append new characters, Open a new line and then insert characters
Replace (R)
Enter insert mode while replacing characters instead of "pushing them"
<quantity>command<movement>
All commands are cASe SeNsiTive
Command | Description |
---|---|
2dw | Delete the next 2 words |
2cw | Delete the next 2 words and drop into insert mode |
Command | Description |
---|---|
c | Change |
y | Yank Character (Copy) |
yy | Yank Line (Copy) |
x | Delete Charactor (Cut) |
d | Delete, requires movement, quantity optional |
dd | Delete Line (Cut) |
p | Put (Paste) |
. | Repeat Last Command (Period) |
u | Undo |
Ctrl-R | Redo |
By default Vim uses only the basic keyboard so moving the cursor is down with...
h j k l
Arrow Keys also work most of the time, which I prefer.
Movement | Description |
---|---|
b | Beginning of word |
w | End of word |
0 | Beginning of line |
$ | End of line |
gg | First line of the file |
G | Last line of the file |
There are 3 types of visual mode, character, line & block
Mode | Description |
---|---|
v | Characters - Select consecutive characters |
V | Line - Select consecutive lines |
Ctrl-V | Block - Select continue block in either horizontal and/or vertical directions |
We are just scratching the surface of visual mode, more details here: http://vimdoc.sourceforge.net/htmldoc/visual.html
When you want to force an action regardless of the consequences use an exclamation point after the command.
A mentor told me to think of the exclaimation point as
Thanks Gregg
Example: To overwrite a file when it should throw a read-only error
use :w!
(write damb it!)
:q!
Be careful as explained in the previous slide the ! has consequences, in this case all modifications to the file will be lost.
Slides: https://where.matsinet.codes/presentations/intro-to-linux
Slides: https://where.matsinet.codes/presentations/intro-to-linux