Unix Introduction to UNIX

Similar documents
Introduction to the UNIX command line

The UNIX operating system is a set of programs that act as a link between the computer and the user.

UNIX / LINUX - GETTING STARTED

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

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

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Outline. Structure of a UNIX command

Introduction to Linux Workshop 1

Introduction: What is Unix?

Working with Basic Linux. Daniel Balagué

Linux Shell Script. J. K. Mandal

CS4350 Unix Programming. Outline

Course 144 Supplementary Materials. UNIX Fundamentals

Lab Working with Linux Command Line

2) clear :- It clears the terminal screen. Syntax :- clear

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Basic Linux Command Line Interface Guide

Linux Command Line Primer. By: Scott Marshall

Basic Linux Command Line Interface Guide

Chapter-3. Introduction to Unix: Fundamental Commands

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

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Perl and R Scripting for Biologists

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to Linux

Linux & Shell Programming 2014

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

CISC 220 fall 2011, set 1: Linux basics

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

Mills HPC Tutorial Series. Linux Basics I

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

CSCI 2132 Software Development. Lecture 5: File Permissions

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

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

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

Computer Systems and Architecture

Session 1: Accessing MUGrid and Command Line Basics

UNIX Essentials Featuring Solaris 10 Op System

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

Please choose the best answer. More than one answer might be true, but choose the one that is best.

RH033 Red Hat Linux Essentials

Shell Programming Overview

Files and Directories

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

Week 2 Lecture 3. Unix

Computer Systems and Architecture

Welcome to Linux. Lecture 1.1

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

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

Linux & Shell Programming 2014

EECS2301. Lab 1 Winter 2016

Physics REU Unix Tutorial

Unix Handouts. Shantanu N Kulkarni

Computer Architecture Lab 1 (Starting with Linux)

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

The Unix Shell & Shell Scripts

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

LOG ON TO LINUX AND LOG OFF

UNLV Computer Science Department CS 135 Lab Manual

A Brief Introduction to the Linux Shell for Data Science

CS/CIS 249 SP18 - Intro to Information Security

Introduction to Supercomputing

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

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

CS CS Tutorial 2 2 Winter 2018

INTRODUCTION TO LINUX

100 SHELL PROGRAMS IN UNIX

Lecture # 2 Introduction to UNIX (Part 2)

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.

UNIX Shell Programming

Introduction to Linux. Fundamentals of Computer Science

Operating Systems, Unix Files and Commands SEEM

Name: Tej. D. Shah Subject:CC-304 Linux Uni. Practical programme College :L.J. College Of Computer Application. Questions:

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

commandname flags arguments

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

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

Embedded Systems Ch 3A Linux Development Environment

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Unix System Architecture, File System, and Shell Commands

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

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

Files

Introduction to Linux Environment. Yun-Wen Chen

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

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

5/20/2007. Touring Essential Programs

IMPORTANT: Logging Off LOGGING IN

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

2. UDP Client, UDP Server

(a) About Unix. History

Lab 3a Using the vi editor

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Transcription:

Unix Introduction to UNIX

Get Started Introduction The UNIX operating system Set of programs that act as a link between the computer and the user. Developed in 1969 by a group of AT&T employees Various Unix variants Solaris Unix, AIX, HP Unix and BSD are few examples. Linux is also a flavour of Unix which is freely available. Multiuser system. Multitasking system.

Unix Architecture Introduction Kernel: The heart of the operating system. It interacts with hardware Memory management, task scheduling and file management. Shell: The utility that processes your requests. Type in a command at your terminal, The shell interprets the command Calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell - famous shells Variants.

Contd Introduction Commands and Utilities: Command and utilities are used in your day to day activities. cp, mv, cat and grep etc. Over 250 standard commands Numerous others provided through 3rd party software. All the commands come along with various optional options. Files and Directories: All data in UNIX is organized into files. All files are organized into directories. Tree-like structure called the file system.

System Bootup Introduction Install UNIX operating system. Login Unix Requires User id and password. Command prompt ( sometime called $ prompt )

Commands Introduction External program on disk which could be a binary executable (written in C, C++). a script file (like a shell or perl script). Internal command of the shell like cd, pwd, etc.

Unix in Windows Introduction Download Cygwin Install cygwin Open command prompt Navigate to C:\Cygwin: cd c:/cygwin Run command Cygwin.bat Screen: Unix is ready Try command $ls

Some Fun Commands Introduction Command Example Description who am i whoami Lists who is logged on your machine echo Echo Hello Displays what ever text is typed ahead finger finger Lists who is on computers in the lab history history Lists commands you've done recently date date Print out current date cal <mo> <yr> cal 9 2000 Print calendar for September 2000 xcalc xcalc & Calculator ("background" process)

System Shutdown Commands Introduction Command halt init 0 init 6 poweroff reboot shutdown Description Brings the system down immediately. Powers off the system using predefined scripts to synchronize and clean up the system prior to shutdown Reboots the system by shutting it down completely and then bringing it completely back up Shuts down the system by powering off. Reboots the system. Shuts down the system

File Management

File Management File Management UNIX is organized into files. All files are organized into directories. tree-like structure called the filesystem. Three types of files: Ordinary Files Contains data, text, or program instructions. Here we work with ordinary files. Directories Both special and ordinary files. UNIX directories are equivalent to folders. Special Files Some special files provide access to hardware such as hard drives, CD-ROM drives, modems, and Ethernet adapters. Other special files are similar to aliases or shortcuts and enable you to access a single file using different names.

Listing Files $ls File Management List all files and directories: $ls More information about the listed files $ls -l 1 st colomn: file type and permission given on the file. 2 nd Column: number of memory blocks taken by the file or directory. 3 rd Column: owner of the file. This is the Unix user who created this file. 4 th Column: group of the owner. Every Unix user would have an associated group. 5 th Column: file size in bytes. 6 th Column: Date and time when this file was created or modified last time. 7 th Column: represents file or directory name.

Contd File Management In the ls -l listing example, every file line began with a d, -, or l. These characters indicate the type of file that's listed. Prefix Description - Regular file, such as an ASCII text file, binary executable, or hard link. b c d l p s Block special file. Block input/output device file such as a physical hard drive. Character special file. Raw input/output device file such as a physical hard drive Directory file that contains a listing of other files and directories. Symbolic link file. Links on any regular file. Named pipe. A mechanism for interprocess communications Socket used for interprocess communication.

Creating Files File Management use vi editor to create ordinary files on any Unix system. $ vi filename $ vi myfile To insert in file press i.

Contd File Management Once you are done, do the following steps Press key esc to come out of edit mode. Press two keys Shift + ZZ together to come out of the file completely. $ vi myfile i key to edit the file l key to move to the right side. h key to move to the left side. k key to move up side in the file. j key to move down side in the file. Press two keys Shift + ZZ together to come out of the file completely.

File commands File Management Command Example Description $ cat filemane $ cat myfile Display the contents of the file $ cat b filename $ cat b myfile Displays line numbers along with the content of the file $ wc filename $ wc myfile Counts the number of lines, words and characters in the file $ cp source_file destination_file $ mv old_file new_file $ cp myfile newfile $ mv myfile newfile Copies the file. Now 2 files change the name of a file $ rm filename $ rm newfile Delete the file $ rm filename1 filename2 filename3 $ rm myfile,newfile Delete multiple files together

Directory Management

Directory management Directory Management Navigate to home directory anytime $ cd ~ ~ indicates home directory. Navigate to last directory $ cd - To determine current location in the filesystem hierarchy at any time $ pwd To list the files in a directory $ ls dirname

Contd Directory Management Command Example Description $ mkdir dirname $ mkdir mydir To create a new directoy $rmdir dirname $rmdir mydir To remove a directory $cd dirname $cd /usr/local/bin Changing Directories $mv olddir newdir $mv mydir newdir Renaming Directories

Access Modes

File Permission / Access Modes Access Modes Provides a secure method for storing files. Every file in UNIX has the following attributes Owner permissions actions the owner of the file can perform on the file. Group permissions actions a user, who is a member of the group that a file belongs to, can perform on the file. Other (world) permissions For others indicate what action all other users can perform on the file. This command gives complete details of a file or a directory $ls -l

Contd Access Modes 1 st char D represents a directory - represents a file 2 nd 3 rd 4 th char Permissions for owner 5 th 6 th 7 th char Permissions for group 8 th 9 th 10 th char Permissions for others

Access modes Access Modes File access modes Directory Access Modes Read Grants the capability to read ie. view the contents of the file. Write Grants the capability to modify, or remove the content of the file. Execute User with execute permissions can run a file as a program. Read Access to a directory means that the user can read the contents. The user can look at the filenames inside the directory. Write Access means that the user can add or delete files to the contents of the directory. Execute Executing a directory doesn't really make a lot of sense so think of this as a traverse permission.

Changing Permissions chmod Access Modes Number Octal Permission Representation Ref 0 No permission --- 1 Execute permission --x 2 Write permission -w- 3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx 4 Read permission r-- 5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x 6 Read and write permission: 4 (read) + 2 (write) = 6 rw- 7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx $ chmod 777 myfile

Changing Owners and Groups Access Modes Two commands are available to change the owner and the group of files chown "change owner" To change the owner of a file. Syntax: $ chown user filelist chgrp "change group" To change the group of a file. Syntax: $ chgrp group filelist $ chown Rana myfile $ chgrp special myfile

Variables: PS1, PS2

PS1 and PS2 Variables Variables There are two variables PS1 and PS2 $ PS1= => => => => To set the value of PS1 so that it shows the working directory, issue the command

Escape Sequences with PS1 Variables Escape Sequence Description \t Current time, expressed as HH:MM:SS. \d Current date, expressed as Weekday Month Date \n Newline. \s Current shell environment. \W Working directory. \w Full path of the working directory. \u Current user.s username. \h Hostname of the current machine. \# Command number of the current command. Increases with each new command entered. \$ If the effective UID is 0 (that is, if you are logged in as root), end the prompt with the # character; otherwise, use the $.

PS2 variable Variables The default secondary prompt is > (the greater than sign), but can be changed by re-defining theps2 shell variable

Environment Variables Variables Variable DISPLAY HOME IFS LANG LD_LIBRARY_PATH PATH PWD RANDOM SHLVL TERM TZ UID Description Contains the identifier for the display that X11 programs should use by default. home directory of the current user: the default argument for the cd built-in command. Indicates the Internal Field Separator that is used by the parser for word splitting after expansion. LANG expands to the default system locale; LC_ALL can be used to override this. For example, if its value is pt_br, then the language is set to (Brazilian) Portuguese and the locale to Brazil. On many Unix systems with a dynamic linker, contains a colon-separated list of directories that the dynamic linker should search for shared objects when building a process image after exec, before searching in any other directories. Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for commands. Indicates the current working directory as set by the cd command. Generates a random integer between 0 and 32,767 each time it is referenced. Increments by one each time an instance of bash is started. This variable is useful for determining whether the built-in exit command ends the current session. Refers to the display type Refers to Time zone. It can take values like GMT, AST, etc. Expands to the numeric user ID of the current user, initialized at shell startup.

Examples Variables

Pipes and Filters

Pipes and filters Pipes and Filters Pipes: Connect two commands together Output for 1 st becomes input for 2 nd command. To make a pipe, put a vertical bar ( ) on the command line between two commands. Filters: Program takes its input from another program, performs some operation on that input, writes the result to the standard output.

Grep Command Pipes and Filters Searches a file or files for lines that have a certain pattern. $ grep pattern file(s) $ ls l grep 6

The sort Command Pipes and Filters Arranges lines of text alphabetically or numerically. Options with Sort command. Option Description -n Sort numerically (example: 10 will sort after 2), ignore blanks and tabs. -r Reverse the order of sort. -f Sort upper- and lowercase together. +x Ignore first x fields when sorting.

Network Utilities

Network Communication Utilities Network Utilities The ping Utility Sends an echo request to a host available on the network. check if your remote host is responding well or not. The ping command is useful for the following Tracking and isolating hardware and software problems. Determining the status of the network and various foreign hosts. Testing, measuring, and managing networks. Syntax: $ ping hostname or ip-address $ ping google.com

Vi Editor

Vi Editor Vi Editor Many ways to edit files in Unix One of the best ways is using screen-oriented text editor vi. This editor enables editing lines in context with other lines in the file. Starting the vi Editor Command vi filename vi -R filename view filename Description Creates a new file if it already does not exist, otherwise opens existing file. Opens an existing file in read only mode. Opens an existing file in read only mode. Operation Modes Insert Mode: To add contents to file Press i Command Mode Pess esc to exit insert mode

Exit Vi Vi Editor Command :q! :w :wq zz Description Exit without saving Save contents Save and exit Save and exit Moving inside a file Command Description k j h l Moves the cursor up one line. Moves the cursor down one line. Moves the cursor to the left one character position. Moves the cursor to the right one character position. vi is case-sensitive

Vi Editor Reference Guide: Vi Editor Download from: https://www.hadoopexpress.com/download/hadoop/supplementaryguides/vieditor.pdf