INTRODUCTION TO LINUX

Similar documents
Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Perl and R Scripting for Biologists

Introduction to Linux

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Linux Systems Administration Getting Started with Linux

Chapter-3. Introduction to Unix: Fundamental Commands

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

1 Installation (briefly)

Introduction to Unix: Fundamental Commands

Linux for Beginners. Windows users should download putty or bitvise:

Unix System Architecture, File System, and Shell Commands

Getting Started with Linux

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to Linux

Linux Kung-Fu. James Droste UBNetDef Fall 2016

Introduction to Linux

Commands are in black

Exercise Sheet 2. (Classifications of Operating Systems)

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

UNIX Concepts COMPSCI 386

INF322 Operating Systems

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

CS/CIS 249 SP18 - Intro to Information Security

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CS197U: A Hands on Introduction to Unix

GNU/Linux: An Essential Guide for Students Undertaking BLOSSOM

Working with Basic Linux. Daniel Balagué

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Introduction to Linux Part I: The Filesystem Luca Heltai

The kernel is the low-level software that manages hardware, multitasks programs, etc.

Introduction to the UNIX command line

Introduction. What is Linux? What is the difference between a client and a server?

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

CS Fundamentals of Programming II Fall Very Basic UNIX

System Administration

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Linux Essentials Objectives Topics:

Computer Systems and Architecture

CISC 220 fall 2011, set 1: Linux basics

Filesystem Hierarchy and Permissions

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Course Wiki. Today s Topics. Web Resources. Amazon EC2. Linux. Apache PHP. Workflow and Tools. Extensible Networking Platform 1

Unix Introduction to UNIX

Introduction to Linux

UNIT 9 Introduction to Linux and Ubuntu

Overview of Unix / Linux operating systems

Chap2: Operating-System Structures

Linux Command Line Primer. By: Scott Marshall

A Brief Introduction to Unix

Filesystem Hierarchy and Permissions

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Operating Systems Linux 1-2 Measurements Background material

Computer Systems and Architecture

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

h/w m/c Kernel shell Application s/w user

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

commandname flags arguments

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Outline. Structure of a UNIX command

Introduction to Linux

Introduction to Linux Basics

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

LAB #7 Linux Tutorial

Welcome to Linux. Lecture 1.1

CS197U: A Hands on Introduction to Unix

Overview of the UNIX File System

Filesystem Hierarchy Operating systems I800 Edmund Laugasson

Course 144 Supplementary Materials. UNIX Fundamentals

Lab Authentication, Authorization, and Accounting

The Unix Shell & Shell Scripts

Linux basics U3A in Bath. Linux Principles. by Andy Pepperdine

Introduction to UNIX command-line

Introduction of Linux

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Installation of the DigitalSystemsVM virtual machine

Operating Systems Lab 1 (Users, Groups, and Security)

File System Hierarchy Standard (FHS)

You will automatically be in your user (home) directory when you login.

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Presented by Bill Genske Gary Jackson

UNIX File Hierarchy: Structure and Commands

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Getting started with Hugs on Linux

CS370 Operating Systems

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Transcription:

INTRODUCTION TO LINUX

REALLY SHORT HISTORY Before GNU/Linux there were DOS, MAC and UNIX. All systems were proprietary. The GNU project started in the early 80s by Richard Stallman Goal to make a free version of UNIX Developers make money by modifying and extending existing software depending on companies needs In the early 90s the Linux kernel appears which quickly becomes the defacto kernel for GNU The GNU General Public License ensures that the source codes will be free for all to copy, study and to change

ADVANTAGES OVER WINDOWS It's free to relatively inexpensive Source code is available, due to GPL Bugs are fixed quickly and help is readily available through the Internet (IRC, forums) Linux is more stable than Windows A truly multi-user and multi-tasking multiuser: OS that can simultaneously serve a number of users multitasking: OS that can simultaneously execute a number of programs runs on equipment that other operating systems consider too underpowered, e.g. 386 systems, embedded devices and smartphones. Overall highly reliable as an operating system

DISADVANTAGES COMPARED WITH WINDOWS Not all programs exist for Linux e.g. Office, Photoshop WINE enables you to run the majority of Windows software in Linux Virtual machine with Windows Isn't as popular as Windows Though this is changing as Linux distributions develop more user friendly interfaces No specific commercial company is responsible for Linux Typically companies maintain only their own distribution of Linux

TYPES OF INTERFACES Typically we classify these into GUI Graphical user interface CLI Console line interface

TYPES OF INTERFACES Typically we classify these into GUI Graphical user interface CLI Console line interface

LINUX AND WINDOWS Linux: From the very start it has been CLI oriented. The GUI is just an additional program that passes commands to the CLI Features accessible from the GUI also accessible from the CLI (but not necessarily a simple command) Always possible to switch to CLI if something goes wrong Windows Started out as a GUI focused operating system. DOS console still available, but lacking in expressive power and user friendliness CLI is returning to Windows PowerShell Cygwin or MSYS - a collection of programs enabling a Linux-like CLI in Windows

GRAPHICS USER INTERFACE IN LINUX By adopting the X-Window technology, the graphical user interface is also available for Linux: Uses pointing devices (e.g. mouse) to control the system, similar to Microsoft s Windows Advantages: Tasks selectable from menus or icons. Learning curve is very low, can do certain types of work immediately. Disadvantages: Slow and requires certain resources to run Not an issue on modern PCs Suitable for general users and personal computers Ubunto, Linux Mint and others

COMMAND LINE INTERFACE IN LINUX Traditional Linux (Unix also) uses command line driven interface (or text-based interface) User needs to type command to instruct the computer to do work (as in DOS) Advantage: fast performance. Very few resources are required for its use. More flexible and easier automation of tasks Disadvantages: user needs to type, making it error prone. Learning curve is higher than GUI Suitable for advanced users and for the systems that interaction with user is not frequent, such as servers or embedded systems

LINUX SHELL Shell interprets CLI commands and requests appropriate services from the Linux kernel Similar to DOS but DOS has only one shell, while Linux can select from a variety shells Bourne Again shell (Bash), Debian Almquist (dash), Z shell (Zsh) ls whoami Bash, Tcsh, Zsh Kernel pwd Different shells have similar but different functionality Bash is the default for most The GUI interface is an application started from shell

SOME QUICK HANDS ON TERMINAL While we are in the GUI, to get to the terminal (CLI), we must find and open the program Terminal

THE TERMINAL Typically we are greeted by a window that looks like this andrew@production:~$ Immediately noticable: Our user name (andrew) The computers name (production) Our security status (regular user - $ or super user - #)

THE TERMINAL - TTY As mentined, we can always access the terminal. One mode is to switch to the virtual terminal TeleTYpewriter - TTY Ctrl+Alt+Fn lets us switch between12 TTY terminals Fn being F1,F2,F3 F12 The GUI in Ubuntu runs in terminal 7 TTY7! Same as using the terminal program, only here we are directly in the console. The terminal program in GUI is just a fancy TTY

USER MANAGEMENT As a user you can change your files, user information and run programs Depends on your privileges As a superuser (su) you can do any operation to anything and anyone Dangerous, try to avoid using superuser for everything (typically named root) Anyone ever rooted their phone? Permission denied when executing command as user? May need to execute command as superuser Append sudo to command (sudo superuser do)

ADDING USERS Easy and straightforward Run the following as a superuser (root or via sudo) useradd m USERNAME The m flag will create a home directory passwd USERNAME Set the users password so he can login usermod s /bin/bash USERNAME Modify the users shell (-s) to use bash By default the shell is /bin/sh, a lightweight shell

LINUX FILE ACCESS PRIVILEGES Linux is a multiuser system, the files of all users are stored in a single file structure Mechanism is required to restrict one user to access the files of another user, if he is not supposed to User can impose access permission to each file to restrict its access The term access permission refers to read permission write permission execute permission

LINUX FILE ACCESS PRIVILEGES Access permission can also be assigned to a directory Directory is also a file that contains the attributes of the files inside it If read permission is not given to a directory cannot show the structure of this directory e.g. cannot use ls If write permission is not given to a directory cannot modify anything of the directory structure e.g. cannot copy a file into this directory since it will modify the directory structure by adding one more file If execute permission is not given to a directory nearly nothing can be done with this directory, even cd

LINUX FILE ACCESS PRIVILEGES Use ls l to view current directory files and details

Hard link no Owner Owner s group File last modified date d rwx r-x r-x 2 john users 4096 July 24 2013 Autostart It is a directory file size file name Owner policy The directory can be read, written and executed by the owner Group policy The directory can be read and executed but not written by other users in the same group Everyone else policy The directory can be read and executed but not written by other users in a different group

POLICY PERMISSSIONS Total value Read Value 4 Permissions Write Value 2 Execute Value 1 Listing 0 no read no write no execute --- 1 no read no write execute --x 2 no read write no execute -w- 3 no read write execute -wx 4 read no write no execute r-- 5 read no write execute r-x 6 read write no execute rw- 7 read write execute rwx

LINUX FILE ACCESS PRIVILAGES The access permission of a file or directory can be changed by using the command chmod xyz filename/directory name xyz refers 3 digit in octal form (cant go higher than 7) For example 421 421 421 660 : 110 110 000 rw- rw- --- 545 : 101 100 101 r-x r-- r-x

LINUX FILE ACCESS PRIVILEGES The owner of a file or directory can be changed by using the command chown user:group filename/directory user for which user are user access privileges applied to group for which group are user access privileges applied to

LINUX FILE SYSTEM STRUCTURE According to the File System Standard (FSSTND) proposed in 1994, every LINUX system should contain a set of standard files and directories root / directories bin lib lost+found mnt opt root sbin var boot dev etc proc home tmp usr fd sd sd file group passwd john doe bin lib local 23

LISTING CONTENT OF ROOT /

THE FILESYSTEM In Linux, a file is defined as simply the thing that deals with a sequence of bytes Hence everything are files An ordinary file is a file; a directory is also file; a network card, a hard disk, any device are also files since they deal with a sequence of bytes A few types of files simple/ordinary file (text file, c++ file, etc) directory symbolic (soft) link special file (device) named pipe (FIFO) It is essetial that we know some basics on how to navigate the filesystem

SYMBOLIC LINKS AND DEVICES Symbolic (soft) link Not a real file, just a link to another file Allow giving another name to a file without actually duplicating it save disk space Special file (device) Each hardware device, e.g. keyboard, hard disk, CD-ROM, etc is associated with at least one file Typically located in /dev directory Applications can read and write any devices by reading and writing their associate file hence the access method is known as device independent The drives is responsible for communicating with the actual hardware Divide into two types: character special files, e.g. keyboard, and block special files, e.g. hard drive

LINUX FILE SYSTEM STRUCTURE Root Directory ( / ) Top of the file system. Contains everything. /bin Contain the binaries (executable code) of most essential Linux commands, e.g. bash, cat, cp, ln, ls, etc. /boot Contain all the files needed to boot the Linux system, including the binary of the Linux kernel. /dev Contains the special files for devices, e.g. fd0, sda, etc.

LINUX FILE SYSTEM STRUCTURE /etc Contain host-specific files and directories, e.g. information about system configuration /home Contain the home directories of every user in the system, e.g. dlun, guest, etc /lib Store all essential libraries for different language compilers /lost+found Contain all the files on the system not connected to any directory. System administrator should determine the fate of the files in this directory

LINUX FILE SYSTEM STRUCTURE /mnt Ubunto will typically mount to /media! Used by system administrator to mount file systems temporarily by using the mount command Before using any devices (located in /dev), they have to be mounted to the system for registration For example, after mounting a CD-ROM, the file system in it will be mapped to /mnt/cdrom directory Ubunto maps to /media/cd_name User can then read and write files in the CD-ROM by accessing this directory Similar to mapping a drive letter to a CD-ROM in Windows Different from the special file in /dev. The special file is only a place where data of the CD-ROM is transferred or stored. No file system concept.

LINUX FILE SYSTEM STRUCTURE /opt Use to install optional, add-on software packages, e.g. LibreOffice and such /proc Contains process and system information /root Home directory of the user root, usually the administrator /sbin The directories /sbin, /usr/sbin, and /usr/local/sbin contain system administration tools, utilities and general root only commands, such as halt, reboot and shutdown

LINUX FILE SYSTEM STRUCTURE /tmp Contain temporary files. Usually files in this directory will be deleted from time to time to avoid the system fills with temp files /usr One of the largest sections of the Linux file system Contain read-only data that are shared between various users /var Contain (variable) data that keeps on changing as the system is running.

FREQUENTLY USED COMMANDS TO NAVIGATE AND MANIPULATE THE FILESYSTEM pwd : show the name of the current directory ls : to show the names of the file in the current directory cd : change directory cp : cd / cd.. change to the root directory change to the parent of that directory copy one file to another cp abc.txt xyz.txt copy abc.txt to xyz.txt remove file rm : rmdir : remove (empty) folder man : ask for the manual (or help) of a command man cd ask for the manual of the command cd

FREQUENTLY USED COMMANDS TO NAVIGATE AND MANIPULATE THE FILESYSTEM touch: create an empty file touch abc.txt create empty file with name abc.txt cat : show the content of a text file cat abc.txt show the content of abc.txt nano: simple text editor (one of many) vi : advanced text editor (read manual and tutorials!) man : ask for the manual (or help) of a command man cd ask for the manual of the command cd

PROCESS MANAGEMENT Linux is a multitasking system Multiple programs can be executed at the same time Ultimately, a program needs to be executed by a CPU If there is only one CPU, how are multiple programs executed at the same time? They are not, they share the CPU time CPU sharing happens so fast it feels like all programs are executing in parallel

VIEW PROCESSES One can easily see the system status of executables with command top

VIEW PROCESSES Or using ps -a

KILLING PROCESSES If a process becomes unresponsive, one way to end it is to use signals; the command kill -ID PID ID what kill signal to send PID proces ID, can be found in top command and elsewhere Common kill signal IDs 1 Hang up, safest way to ask a process to stop 2 Kill program, same as pressing Ctrl + C 9 Forces termination, last resort 15 Ask process to end itself

INSTALLING APPLICATIONS Using apt-get Typically recommended to do apt-get update Will fetch an up to date list of applications Install package with apt-get install PACKAGE Search through the list of applications with apt-cache search NAME Update all installed packages with apt-get upgrade

HINTS Always use TAB It will auto-complete what we are typing by looking at available executables and files If more than one option is available, press TAB multiple times to switch between them Available executables are determined by PATH and files are determined by our location in the filesystem

EXERCISE ONE Position yourself to the home directory cd ~ Using the wget command, download these slides from http://gemma.uni-mb.si/ros2014/slides.pdf Syntax is wget URL wget http://gemma.uni-mb.si/ros2014/slides.pdf Open the slides and go to the next page

EXERCISE TWO Again using the wget command, download more exercises from http://gemma.uni-mb.si/ros2014/exercises.txt You can open them with any text editor (gedit)

HELPFUL LINKS Expanded cheat sheet for command line http://www.cheatography.com/davechild/cheatsheets/linux-command-line/ Introduction to Linux command line http://www.phas.ubc.ca/~mbelab/computer/linuxintro/html/ Writing Bash scripts Scripts are typically non compiled programs http://mywiki.wooledge.org/bashguide