Introduction to Linux

Similar documents
Introduction to Linux. May 9, 2010 Isaac Ye SHARCNET York University

An Introduction to Linux

Perl and R Scripting for Biologists

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

Chapter-3. Introduction to Unix: Fundamental Commands

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Computer Systems and Architecture

INTRODUCTION TO LINUX

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

Computer Systems and Architecture

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Chap2: Operating-System Structures

Introduction to Linux

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

Working with Basic Linux. Daniel Balagué

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

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

The Unix Shell & Shell Scripts

Course 144 Supplementary Materials. UNIX Fundamentals

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

CISC 220 fall 2011, set 1: Linux basics

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

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

CS246 Spring14 Programming Paradigm Notes on Linux

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

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Files and Directories

System Administration

CSCI 2132 Software Development. Lecture 5: File Permissions

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Command-line interpreters

Unix Introduction to UNIX

CS Fundamentals of Programming II Fall Very Basic UNIX

Unix Basics. Systems Programming Concepts

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Getting started with Hugs on Linux

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

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

Introduction to Unix: Fundamental Commands

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Introduction to Linux

LAB #7 Linux Tutorial

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

Introduction to the Linux Command Line

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Linux & Shell Programming 2014

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CS370 Operating Systems

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

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

Linux Essentials. Smith, Roderick W. Table of Contents ISBN-13: Introduction xvii. Chapter 1 Selecting an Operating System 1

UNIX Quick Reference

CS/CIS 249 SP18 - Intro to Information Security

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

Welcome to Linux. Lecture 1.1

UNIX. Basic UNIX Command

INSE Lab 1 Introduction to UNIX Fall 2017

Introduction to Linux

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

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

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

Introduction to Linux

Linux Command Line Primer. By: Scott Marshall

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CS4350 Unix Programming. Outline

Introduction to the UNIX command line

Linux System Administration

Unix Basics. Benjamin S. Skrainka University College London. July 17, 2010

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

CSC UNIX System, Spring 2015

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

Linux Essentials Objectives Topics:

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

A Brief Introduction to Unix

Outline. Structure of a UNIX command

Lab Working with Linux Command Line

Commands are in black

Introduction to Linux

Practical Session 0 Introduction to Linux

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

Files

Introduction to Linux

Introduction: What is Unix?

Linux Bootcamp Fall 2015

Introduction to the Linux Command Line January Presentation Topics

EECS2301. Lab 1 Winter 2016

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

System Programming. Introduction to Unix

Scripting Languages Course 1. Diana Trandabăț

Linux Shell Script. J. K. Mandal

Linux at the Command Line Don Johnson of BU IS&T

Session 1: Accessing MUGrid and Command Line Basics

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Transcription:

Introduction to Linux Mukesh Pund Principal Scientist, NISCAIR, New Delhi, India

History In 1969, a team of developers developed a new operating system called Unix which was written using C Linus Torvalds, a young man studying computer science at the university of Helsinki developed academic version of Unix which is named as Linux. Linux is a full UNIX clone. 2

Linux a powerful OS! Today Linux has joined the desktop market. On the server side, Linux is well-known as a stable and reliable platform. Linux provides many applications like: Databases (MySQL,Postgresql), Network services(web Servers,DNS, Proxy, firewall etc) Software development tools(c, Java, Python,Perl etc.) Office automation tools And many more 3

Is Linux difficult? There is excellent and free Internet support and documentation available. The graphical user interface (GUI) is similar in design to that on any other system A very powerful command line alternative is also available. Linux is user friendly. 4

Properties of Linux It is Open Source Today, Linux is ready to accept the challenge of a fast-changing world. Linux is free: If you want to spend absolutely nothing, you don't even have to pay the price of a CD. Linux can be downloaded in its entirety from the Internet completely for free. 5

Properties of Linux Linux is portable to any hardware platform. Linux was made to keep on running. As with UNIX, a Linux system expects to run without rebooting all the time. Tasks can be scheduled to run at suitable times. 6

Properties of Linux Linux is secure and versatile. The security model used in Linux is based on the UNIX idea of security which is robust. It is less prone to virus attacks. Linux is scalable 7

Commands.. Let s have an overview of frequently used commands in Linux. Note: Some commands can only be executed by super user (example adduser, shutdown etc). 8

Creating a new user Use the useradd command Use the passwd command to set password Try it logon as root [root@mukesh]# useradd sdc1 [root@mukesh]# passwd sdc1 Changing password for user sdc1 New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully [root@mukesh]# 9

What is a Shell? Is a program that takes your commands from the keyboard and gives them to the operating system to perform An interface between the Linux system and the user Used to call commands and programs Many available (bsh; csh; bash; etc.) 10

You need help? Add more In Linux help can be accessed by command man (manual) Use man <command> to display help for that command 11

Linux File System Basics Linux files are stored in a single rooted, hierarchical file system Data files are stored in directories (folders) Directories may be nested as deep as needed User home directories Directories root Data files 12

Some Special File Names Some file names are special: /. The root directory (not to be confused with the root user) The current directory.. The parent (previous) directory ~ My home directory 13

Special Files /: The root directory where the file system begins. /boot: This is where the Linux kernel is kept. /etc: The /etc directory contains the configuration files for the system. /bin, /usr/bin: These two directories contain most of the programs for the system. The /bin directory has the essential programs that the system requires to operate, while /usr/bin contains applications for the system's users. 14

Special Files /sbin, /usr/sbin: The sbin directories contain programs for system administration, mostly for use by the superuser. /usr: The /usr directory contains a variety of things that support user applications /lib: The shared libraries (similar to DLLs in that other operating system) are kept here. /home: /home is where users keep their personal work. /root: This is the superuser's home directory. 15

Linux Command Basics To execute a command, type its name and arguments at the command line ls -l /etc Command name Options (flags) Arguments 16

Command Options Command options allow you to control a command to a certain degree Conventions: Usually being with a single dash and are a single letter ( -l ) Sometimes have double dashes followed by a keyword ( --help ) 17

Navigation and Looking Around pwd - print (display) the working directory cd <dir> - change the current working directory to dir cd.. ls - list the files in the current working directory ls -l - list the files in the current working directory in long format 18

File and Directory Manipulation cp <fromfile> <tofile> Copy from the <fromfile> to the <tofile> mv <fromfile> <tofile> Move/rename the <fromfile> to the <tofile> rm <file> Remove the file named <file> mkdir <newdir> Make a new directory called <newdir> rmdir <dir> Remove an (empty) directory cat > <file> Create file <file> 19

Data display from files cat <file> Displays contents of the <file> head -n <fromfile> Displays n lines from top of the <fromfile> tail n <fromfile> Displays n lines from bottom of <fromfile> 20

Standard Files UNIX concept of standard files standard input (where a command gets its input) - default is the terminal standard output (where a command writes it output) - default is the terminal standard error (where a command writes error messages) - default is the terminal 21

Redirecting Output The output of a command may be sent (piped) to a file: ls -l >output ls >>output > is used to specify the output file >> is used to append to output 22

Redirecting Input The input of a command may come (be piped) from a file: wc <input < is used to specify the input file 23

Connecting commands with Pipes The output of one command can become the input of another: ps -aef grep postgres wc -l is used to separate stages The output of the ps command is sent to grep wc takes this input and counts the lines its output going to the console grep takes input and searches for postgres passing these lines to wc 24

More Commands who List who is currently logged on to the system who am i ps Report what user you are logged on as List your processes on the system ps -aef List all the processes on the system echo A string to be echoed Echo a string (or list of arguments) to the terminal 25

More Commands grep - Searches files for one or more pattern arguments. It does plain string, basic regular expression, and extended regular expression searching Example: ls l grep mukesh ls command display the listing of files in current directory. And grep command searches for mukesh file in that listing. 26

More Commands kill - sends a signal to a process or process group You can only kill your own processes unless you Example: are root [root@mukesh log]# ps aef Above command will display result like: [root@mukesh log]# UID PID PPID C STIME TTY TIME CMD root 6715 6692 2 14:34 ttyp0 00:00:00 sleep 10h root 6716 6692 0 14:34 ttyp0 00:00:00 ps -ef And one can kill the process by following command: [root@mukesh log]# kill 6715 [1]+ Terminated sleep 10h 27

More Commands tar - manipulates archives An archive is a single file that contains the complete contents of a set of other files; an archive preserves the directory hierarchy that contained the original files. tar -zxvf imap-4.7.tar.gz imap-4.7/ imap-4.7/src/ imap-4.7/src/c-client/ imap-4.7/src/c-client/env.h imap-4.7/src/c-client/fs.h 28

Switching Users su <accountname> switch user accounts. You will be prompted for a password. When this command completes, you will be logged into the new account. Type exit to return to the previous account su Switch to the root user account. Do not do this lightly Note: The root user does not need to enter a password when switching users. It may become any user desired. This is part of the power of the root account. 29

PATH Environment Variable Controls where commands are found PATH is a list of directory pathnames separated by colons. For example: PATH=/bin:/usr/bin:/usr/X11R6/bin:/u sr/local/bin:/home/scully/bin If a command does not contain a slash, the shell tries finding the command in each directory in PATH. The first match is the command that will run 30

File and Directory Permissions Every file or directory Is owned by someone Belongs to a group Has certain access permissions for owner, group, and others Default permissions determined by umask 31

File and Directory Permissions The long version of a listing (ls -l) will display the file permissions: -rwxrwxr-x 1 rvdheij rvdheij 5224 Dec 30 03:22 hello -rw-rw-r-- 1 rvdheij rvdheij 221 Dec 30 03:59 hello.c -rw-rw-r-- 1 rvdheij rvdheij 1514 Dec 30 03:59 hello.s drwxrwxr-x 7 rvdheij rvdheij 1024 Dec 31 14:52 posixuft Permissions Group Owner 32

Interpreting Permissions -rwxrwxrwx Other permissions Group permissions Owner permissions Directory flag (d=directory; l=link) 33

Changing Permissions Use the chmod command to change file or directory permissions rwx rwx rwx = 111 111 111 = 777 rw- rw- rw- = 110 110 110 = 666 rwx --- --- = 111 000 000 = 700 chmod 755 file # Owner=rwx Group=r-x Other=r-x chmod 500 file2 # Owner=r-x Group=--- Other=--- chmod 644 file3 # Owner=rw- Group=r-- Other=r-- chmod +x file # Add execute permission to file for all chmod o-r file # Remove read permission for others chmod a+w file # Add write permission for everyone 34

Changing ownership chown - change file ownership chown name some_file chgrp - change a file's group ownership chgrp new_group some_file 35

Processes As with any multitasking operating system, Linux executes multiple, simultaneous processes. Processes are created in a hierarchical structure whose depth is limited only by the virtual memory available to the virtual machine A process may control the execution of any of its descendants by suspending or resuming it, altering its relative priority, or even terminating it Termination of a process by default causes termination of all its descendants; termination of the root process causes termination of the session Linux assigns a process ID (PID) to the process 36

Processes Foreground When a command is executed from the prompt and runs to completion at which time the prompt returns is said to run in the foreground Background When a command is executed from the prompt with the token & at the end of the command line, the prompt immediately returns while the command continues is said to run in the background 37

Process Control Commands ps - list the processes running on the system kill - send a signal to one or more processes (usually to "kill" a process) 38

Process Control Commands $ ps PID TTY TIME CMD 1280 pts/5 00:00:00 bash 1293 pts/5 00:00:00 xload 1294 pts/5 00:00:00 ps $ kill -9 1293 [2]+ Terminated xload 39

Processes & causes process to be run in background [root@mukesh log]# sleep 10h & [1] 6718 [root@mukesh log]# ps UID PID PPID C STIME TTY TIME CMD root 6718 6692 0 14:49 ttyp0 00:00:00 sleep 10h Job Number Process ID (ID) Parent Process ID 40

Editors Several choices available: vi xedit emacs pico Standard UNIX editor X windows text editor Extensible, Customizable Self- Documenting Display Editor Simple display-oriented text editor 41

42