Introduction to UNIX.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Linux+ Guide to Linux Certification, Second Edition
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
1 CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
By Jonathan Rinfret UNIX/LINUX By Jonathan Rinfret
Overview of Linux Fall 2016 Dr. Donghyun Kim
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
Chapter 11 Command-Line Master Class
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Prepared by: Eng. Maryam Adel Abdel-Hady
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
System Programming and administration CS 308
Lecture 2 Working with Files and Directories
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
The Linux Operating System
Shell Script Assignment 1.
CSE 374 Programming Concepts & Tools
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Tutorial of Unix Command & shell scriptS 5027
Unix : Introduction and Commands
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
Tutorial Unix Command & Makefile CIS 5027
Linux Shell Script Programming
Module 6 Working with Files and Directories
Linux Commands LINUX COMMANDS.
A shell is a user interface.
LPI Linux Certification
Presentation transcript:

Introduction to UNIX

*nix Linux, Solaris, BSD, macOS… We will be using Ubuntu and centOS primarily

UNIX OS 3 parts: Kernel Shell Programs

Kernel Interacts with hardware directly Manages memory Handles filestore and communications

The Shell Interface between user and kernel Command line interpreter Commands are programs The Shell is also a program

Programs Everything is a process or a file Process – executing program Each process has a unique process identifier (PID) File – collection of data created by users

Filesystem

Basic Commands - Syntax Example: ls -a /home The Shell expects tokens to be separated by spaces Typically first token is your command Subsequent tokens are arguments Arguments that start with - or -- are options Non-option arguments passed to command

Basic Commands ls (list) touch myfile.txt Options: -a, -l, -h… Argument: /home/username/ touch myfile.txt Creates a blank file named myfile.txt

Basic Commands cd (change directory) pwd If no destination is provided it defaults to home directory . is your current directory .. will take you to the parent directory pwd Print working directory (where you are in the filesystem)

Basic Commands mkdir (make directory) rmdir (remove directory) Must provide new directory name rmdir (remove directory) rm (remove) Delete a file Common to see rm –rf /path/to/file Be careful, -r is recursive and -f is force

Basic Commands cp (copy) mv (move) cp source destination ex: cp myFile /home/anotheruser/ mv (move) mv source destination Use this to rename files

Basic Commands cat vim (or emacs) View contents of file Edit file There are built in tutorials for both of these vimtutor Start emacs, type “Ctrl –h” followed by “t”

Basic Commands For more information on any command type “man <command>” Shows command usage Shows all options with explanations

Basic Commands Ctrl C – kill process Ctrl D – end of file Ctrl Z – suspend process Enter “bg” to resume process in background Enter “fg” to bring it to foreground again

Other Useful Commands find /home -name <filename> df -h Find a file in your home directory by name df -h Display how much disk space has been used

Filters head tail grep Show first n lines (10 by default) Show last n lines (10 by default) grep Search for a given pattern

Wildcards * ? [ ] Zero or more characters ls *.png (list all pngs in current directory) ? Single character ls ?a* (list all files whose 2nd letter is “a”) [ ] Range of characters ls [a-dj]*.png (list all pngs that start with a,b,c,d, or j)

Redirecting Output cat list1.txt list2.txt > bothLists.txt redirects output of cat to a text file called bothLists.txt cat list1.txt list2.txt >> bothLists.txt appends output of cat to bothLists.txt command1 | command2 called a pipe redirects output of command1 to input of command2 sort < names.txt redirects input to come from file sorts content of names.txt

Combining Commands cal 2017 ; ls -a runs two commands in sequence sudo apt-get update && sudo apt-get upgrade downloads the list of available updates installs them if the previous command was successful ./myscript || echo “Script Failed!” runs myscript prints “Script Failed!” if script failed Added combination of commands on one line, since it was in Welcome Week exercises. Feel free to skip if nesessary. Max

SSH Secure Socket Shell ssh username@ip Remote access Login to another box on your network

Path Path – location of file/directory Absolute path – location of file/directory from root directory /usr/local/bin ~/Desktop (~ will refer to your home directory) Relative path – location of file/directory relative to another directory ../home/anotheruser

Path cont. $PATH /usr/bin/python (invoke python interpreter) Shell will search for a disk utility, if command is not built-in /usr/bin/python (invoke python interpreter) ./a.out (run program compiled in current directory)

Access Control Every file is owned by a user and a group Permissions allow users/groups to read/write/execute files Root can read/write/execute anything Other users can get root privileges with “sudo” “su” allows a user to change the login session owner

User Info - /etc/passwd Each line contains login info for a single user Format: Username Password Placeholder User ID Group ID Comment field Home directory User shell

User Info - /etc/shadow Each line contains hashed password for single user Format: Username Salt and hashed password Last password change Days of warning prior to password expiration Last 3 fields denote days before account is made inactive

Permissions File type, mod bits Number of hard links Owner Group Size Modification time filename

Permissions r – read (4) w – write (2) x – execute (1) To change: chmod <modes> <files> chmod 754 myScript.sh 7 – rwx for user (file’s owner) 5 – rx for group (member’s of file’s group) 4 - r for other (everyone else)

Bash Extension of Bourne Shell When the Shell gets a command it There are others, like Korn Shell When the Shell gets a command it Expands aliases Checks if command is a shell built in If not, assumes command is a program

Bash Scripting – Hello World

Bash Scripting #!/bin/bash Need to “chmod 755 hello.sh” Invoke appropriate interpreter Need to “chmod 755 hello.sh” Executable for user, group and other can read/write To run “./hello.sh”

References OneNote https://files.fosswire.com/2007/08/fwunixref.pdf