The Linux Terminal: a Crash Introduction
Total Page:16
File Type:pdf, Size:1020Kb
The Linux Terminal: A Crash Introduction 1 The Linux Terminal: A Crash Introduction Wolf Dynamics makes no warranty, express or implied, about the completeness, accuracy, reliability, suitability, or usefulness of the information disclosed in this training material. This training material is intended to provide general information only. Any reliance the final user place on this training material is therefore strictly at his/her own risk. Under no circumstances and under no legal theory shall Wolf Dynamics be liable for any loss, damage or injury, arising directly or indirectly from the use or misuse of the information contained in this training material. Revision 1-2019 2 The Linux Terminal: A Crash Introduction Typographical conventions • Text in Courier new font indicates Linux commands that should be typed literally by the user in the terminal. • Text in Courier new bold font indicates directories. • Text in Courier new italic font indicates human readable files or ascii files. • Text in Arial bold font indicates program elements such as variables, function names, classes, statements and so on. It also indicate environment variables, and keywords. They also highlight important information. • Text in Arial underline in blue font indicates URLs and email addresses. • This icon indicates a warning or a caution • This icon indicates a tip, suggestion, or a general note • This symbol indicates that a Linux command should be typed literally by the user in the terminal $> • This symbol indicates that you must press the enter key 3 The Linux Terminal: A Crash Introduction Typographical conventions • Large code listing, ascii files listing, and screen outputs can be written in a square box, as follows: 1 #include <iostream> 2 using namespace std; 3 4 // main() is where program execution begins. It is the main function. 5 // Every program in c++ must have this main function declared 6 7 int main () 8 { 9 cout << "Hello world"; //prints Hello world 10 return 0; //returns nothing 11 } • To improve readability, the text might be colored. • The font can be Courier new or Arial bold. • And when required, the line number will be shown. 4 The Linux Terminal: A Crash Introduction On the training material • In the directory 101LINUX of the training material, you will find the files that we will use during this training. • Take your time and try to understand the concepts implemented in these examples. • Also, try to get familiar with the syntax. 5 The Linux Terminal: A Crash Introduction • Before continuing, we want to remind you that this is an introductory Linux terminal (or the command line) course. • Our goal is to help you familiarize with the basic concepts of the Linux operating system and the Linux shell. • So keep calm, try to follow all the examples, and ask questions. 6 The Linux Terminal: A Crash Introduction What is Linux? • It is a UNIX-like operating system (OS). So, now you might be wondering what is UNIX? • UNIX is a family of multitasking, multiuser, stable, and portable computer operating systems that derive from the original AT&T UNIX, developed in the 1970s at the Bell Labs. • You will find UNIX/Linux in laptops, desktop PCs, servers, and super computers. • UNIX/Linux systems are made of three components; the kernel, the shell, and the programs. • The kernel is the hub of the OS. It allocates time and resources to programs and handles scheduling and system management (files, processes, devices, networking, memory and so on). • The shell (or the terminal), acts as an interface between the user and the kernel. • Programs are the different applications that the user uses. Most of the programs in Linux are Open Source and free, but you can also find commercial ones. Some programs may have a GUI interface or they can only be accessed via the terminal. 7 The Linux Terminal: A Crash Introduction Some Linux facts • Originally developed by Linus Torvalds. • The development started in 1991. • Supported by a world wide community (volunteers and commercial entities). • Free and Open Source (the kernel). • A wide range of Linux applications are free and Open Source. • It can be installed in a great variety of hardware (laptops, desktop PCs, servers, super computers, mobile phones, embedded microchips, and so on). • Linux is virus free and extremely secure. • It is stable, fast-performing, and highly configurable. • It is the ideal OS for developing applications. It comes with many compilers, interpreters, and libraries. • Most modern Linux versions come with a GUI (similar to Windows or MacOSX), which provides an easy way to interact with the OS. • Knowledge of the terminal is required for operations which aren’t covered by a program with a GUI, or for when there is no graphical interface available. 8 The Linux Terminal: A Crash Introduction Linux distributions • There are many Linux distributions available (free and commercial), just to name a few: • Red Hat. • CentOS. • Fedora. • OpenSUSE. • Slackware. • Debian. • Ubuntu. • Mint. • Arch. • Finding the right version that fit your needs requires some experimentation. • During this course we will use OpenSUSE. 9 The Linux Terminal: A Crash Introduction What is Open Source Software? • Open Source refers to something people can modify and share because its design is publicly accessible. • Open Source Software is software with source code that anyone can inspect, modify, and enhance • Open Source Software is usually developed as a public collaboration and made freely available. • There are many Open Source Software licenses, just to name a few: • GNU General Public License (GPL). • Apache License. • BSD License. • Creative Commons. • European Commission License (EUPL). • MIT License. 10 The Linux Terminal: A Crash Introduction GNU General Public License (GPL) • Under the GNU General Public License (GPL), you have legal permission to copy, distribute and/or modify the source code. • Software that includes source code licensed under the GPL inherits the GPL license. • If compiled binaries of GPL software are redistributed (free or for a fee), the source code must be made available by the distributor. • The license is designed to offer freedom, in particular it does not force users of the software to make modifications or developments publicly available. That means that GPL software can be used as the basis of in-house, proprietary software. • When we speak of free software, we are referring to freedom, not price. • The General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 11 The Linux Terminal: A Crash Introduction What is the Linux terminal or shell? • When we talk about the Linux terminal, we talk about a piece of software that emulates a physical terminal VT220 or its predecessor the VT102. DEC VT220 connected to the serial port of a modern computer. https://en.wikipedia.org/wiki/VT220#/media/File:VT220_Irssi.jpg • The terminal emulator or the shell acts as an interface between the user and the OS. • The shell, is a program that reads commands in the terminal (from the keyboard) and send results back to the terminal (to the screen). • It acts as a command line interpreter or CLI. 12 Copyright on the images is held by the contributors. Apart from Fair Use, permission must be sought for any other purpose The Linux Terminal: A Crash Introduction What shell are we going to use? • There are many command shells, just to name a few, • Bourne shell (sh) • Korn shell (ksh) • C shell (csh) • Tee shell (tcsh) • Bourne-again shell (bash) • In this course, we will use the bash shell. • The bash shell is also a programming language, programs written in bash shell are called scripts. • Linux has many scripts, and you can program your own scripts. • Always remember, after inserting a command in the shell you will need to press the enter key 13 The Linux Terminal: A Crash Introduction Where is the terminal in my Linux distribution? • In most Linux distributions, finding the shell is pretty easy. Just look for the terminal or console application in the applications menu or desktop. • If you are using OpenSUSE 42.1, you will find the shell in the system applications menu, as illustrated in the figure below, Quick access to the terminal 3. The shell application Called Konsole in the KDE desktop 2. System menu 1. Applications menu 14 The Linux Terminal: A Crash Introduction You are in Linux, you see this nice window that everybody calls terminal. Now what? 15 The Linux Terminal: A Crash Introduction How do I know what shell am I using? • To know what shell you are using, type in the terminal: • $> echo $SHELL • If the output is /bin/bash, you are using bash shell. • If you are not using bash shell, type in the terminal • $> bash to start using the bash shell. • At this point, we are ready to start exploring the Linux terminal. 16 The Linux Terminal: A Crash Introduction Basic shell interaction • When you open the shell, it is waiting for you to do something. • Let’s use the command date to show how to interact with the shell. This command will display on the screen the system’s date and time. Type in the terminal, • $> date • Commands can take arguments, for example, • $> date +%Y will display the year. • If you need help on how to use a command, you can type command --help or man command. If the help information exist, you will see the information on the terminal. For example, • $> date --help • $> man date • Most of the times the command man gives more information than the argument --help.