Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.

Slides:



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

Introduction of Unix/Linux Compiled by Anant Vishnoi.
Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
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.
Basic UNIX Commands Commonly used Unix commands. Read a Text File Head Tail More.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Just like DOS or Windows.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Looks like DOS…but more powerful.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
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”
Introducing UNIX EMBnet slide 1 Introducing the UNIX Operating System.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
Unix Basics Chapter 4.
The “File System” Under UNIX, (almost) everything is a “file”: –Normal files –Directories –Hardware –Sockets –Pipes Things that are not files: –Users –Groups.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
CS240 Computer Science II Introduction the Unix File System and File Related Utilities Based on “UNIX for Programmers and Users” by G.Class and K. Ables.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
1 CSE 303 Lecture 3 bash shell continued: processes; multi-user systems; combining commands read Linux Pocket Guide pp , , , 118, 122,
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Λειτουργικά Συστήματα - Lab1 Γιάννης Πετράκης. The Operating System  Unix is a layered operating system  The innermost layer is the hardware that provides.
Introduction to Programming Using C An Introduction to Operating Systems.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
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 CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Just like DOS or Windows.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
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.
1 CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
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.
Introducing the UNIX Operating System.
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.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
CSE 374 Programming Concepts & Tools
Basic UNIX OLC Training.
Introduction to UNIX.
Unix : Introduction and Commands
Web Programming Essentials:
Introduction Paul Flynn
Andy Wang Object Oriented Programming in C++ COP 3330
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
What is Unix? A multi-user networked operating system
LPI Linux Certification
Presentation transcript:

Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet

September 2003Bent Thomsen - FIT 1-22 Unix Philosophy Designed by programmers for programmers Toolbox approach Flexibility and freedom Networked – designed for server use Multi-user / Multitasking Conciseness –Everything is a file or a process File system has places Processes have life

September 2003Bent Thomsen - FIT 1-23 Unix Structure Hardware Kernel System Calls Programs

September 2003Bent Thomsen - FIT 1-24 Interacting with Unix Sometimes through a GUI interface

September 2003Bent Thomsen - FIT 1-25 OpenLook on Sun

September 2003Bent Thomsen - FIT 1-26 Common Desktop Environment

September 2003Bent Thomsen - FIT 1-27 MacOS X

September 2003Bent Thomsen - FIT 1-28 Interacting with Unix But most likely through a shell –Xterm, telnet, Secure Shell –A shell is the command line interpreter (like the DOS or command prompt in Windows) A shell is just another program –There are several shells (sh, csh, tcsh, bash …) A program or command –Interacts with the kernel –May be any of: Built-in shell command Interpreted script Compiled object code file

September 2003Bent Thomsen - FIT 1-29 Telnet

September 2003Bent Thomsen - FIT SSH Secure Shell

September 2003Bent Thomsen - FIT Getting started - login The login is the user’s unique name Password is changeable –Only known to user, not to system staff –Except initial issued password Unix is case sensitive Login and password prompt System messages – you have new mail The command prompt % $ [machine]>

September 2003Bent Thomsen - FIT Example of login

September 2003Bent Thomsen - FIT Password - Do Make sure nobody is looking over your shoulder when you type your password Change your password often Choose a password you can remember Use eight characters or more, some numeric, some not letters, i.e. # ! ( ] …

September 2003Bent Thomsen - FIT Password – Don’t Use a word (or words) in any language Use a proper name Use information in your wallet Use information commonly known about you Use control characters Write your password anywhere EVER give your password to anybody

September 2003Bent Thomsen - FIT Passwords Your password is your account security: Change your initial password immediately Use the passwd command to change your password % passwd -where '%' is the prompt Changing password for bt Old password: -type in your old password New password: -type in your new password Retype new password: -and again, to make sure %

September 2003Bent Thomsen - FIT The command prompt Commands are the way to do things in Unix Commands are typed at the prompt Commands, as everything else, are case sensitive in Unix A command consists of a name, options (or flags) and sometimes arguments [prompt]>

September 2003Bent Thomsen - FIT Two Basic Commands The most useful commands you’ll ever learn: –man (short for “manual”) –help They help you find information about other commands –man retrieves detailed information about –help lists useful commands

September 2003Bent Thomsen - FIT Who am I? Commands that tell you who you are: –whoami displays your username –id displays your username and groups Commands that tell you who others are: –finger [ ] displays info for –id [ ] displays info for Commands that change who you are: –su “switch user” to –login login as a different user

September 2003Bent Thomsen - FIT Files and Directories In Unix, files are grouped together in other files called directories, which are analogous to folders in Windows Directory paths are separated by a forward slash / –Example /home/bt/FIT/docs The hierarchical structure of directories (the directory tree) begins at a special directory called the root, or / –Absolute paths start at / Example /home/bt/FIT/docs –Relative paths start in the current directory Example FIT/docs (if you’re currently in /home/bt ) Your home directory is where your personal files are located, and where you start when you log in. –Example /home/bt

September 2003Bent Thomsen - FIT The File System

September 2003Bent Thomsen - FIT Directories (cont’d) Handy directories to know ~ Your home directory.. The parent directory. The current directory Other important directories /bin /tmp

September 2003Bent Thomsen - FIT Simple commands ls –LiSts the contents of specified files or directories (or the current directory if no files are specified) –Syntax: ls [ … ] –Example: ls backups pwd –Print Working Directory

September 2003Bent Thomsen - FIT More commands cd –Change Directory (or your home directory if unspecified) –Syntax: cd –Examples: cd backups/unix-tutorial cd../class-notes mkdir –MaKe DIRectory –Syntax: mkdir –Example: mkdir backups class-notes

September 2003Bent Thomsen - FIT More commands rm –ReMove –Syntax: rm [ ] –Example: rm class-notes.txt –Example: rm –ir backups rmdir –ReMove DIRectory, which must be empty –Syntax: rmdir –Example: rmdir backups class-notes

September 2003Bent Thomsen - FIT Files (cont’d) cp –CoPies a file, preserving the original –Syntax: cp –Example: cp tutorial.txt tutorial.txt.bak mv –MoVes or renames a file, destroying the original –Syntax: mv –Examples: mv tutorial.txt tutorial.txt.bak mv tutorial.txt tutorial-slides.ppt backups/ Note: Both of these commands will over-write existing files without warning you!

September 2003Bent Thomsen - FIT File Permissions Every file has three access levels: –user(the user owner of the file) –group(the group owner of the file) –other(everyone else) At each level, there are three access types: –read(looking at the contents) –write(altering the contents) –execute(executing the contents)

September 2003Bent Thomsen - FIT What You Can Do With Permissions PermissionFileDirectory r (read) Read a fileList files in … w (write) Write a fileCreate a file in … Rename a file in … Delete a file in … x (execute) Execute a file (eg shell script) Read a file in … Write to a file in … Execute a file/shell script in …

September 2003Bent Thomsen - FIT Changing Permissions The “change mode” command: chmod [,…] string of: u, g, o, a (user, group, other, all) one of +, -, = (gets, loses, equals) string of: r, w, x, s, t, u, g, o (read, write, execute, set-id, text, same as user, same as group, same as other), Examples: chmod u+rwx,go-w foobar chmod g=u,+t temp/ chmod u=rwx,g=rwxs,o= shared/

September 2003Bent Thomsen - FIT Process Management What can you do with it? –Start programs in the background –Run more than one program per terminal –Kill bad and/or crashing programs –Suspend programs mid-execution –List all jobs running in a shell –Move foreground jobs to the background –More …

September 2003Bent Thomsen - FIT Three States of a Process Foreground –Attached to keyboard –Outputs to the screen –Shell waits until the process ends Background, running –Not attached to keyboard –Might output to the screen –Shell immediately gives you another prompt Background, suspended –Paused mid-execution –Can be resumed in background or foreground

September 2003Bent Thomsen - FIT Background Processes Listing jobs: –jobs lists background “jobs” and job #’s –ps lists processes and their process id (“pid”) –% expands to the process id of the job Stopping foreground jobs –Press ^Z (Ctrl-Z) in the terminal window Starting a process in the background –Append a & character to the command line –Examples: ls –lR > ls-lR.out & Resuming a stopped job –In the foreground: fg [ ] –In the background: bg [ ]

September 2003Bent Thomsen - FIT Killing Processes The “kill” command: kill [- ] Send to process The “killall” command: killall [- ] Send to all processes that start with Useful signals ( kill –l for the complete list): TERMthe default, “terminate”, kills things nicely KILLwill kill anything, but not nicely HUP“hangup”, used to reload configurations STOPstops (suspends) a running process

September 2003Bent Thomsen - FIT Redirecting input and output Simple! > Example sort dirlist Note a file called dirlist will be created if it doesn’t exist Dirlist will be overwritten. >> appends

September 2003Bent Thomsen - FIT Piping Piping is connecting programs together by using the output of one program as the input to the next. Syntax: | | … | A simple example (view a sorted file-listing a page at a time): ls | sort | less By combining Unix utilities in a pipeline, you can build tools “on-the-fly” as you need them.

September 2003Bent Thomsen - FIT Shell Shortcuts Tab completion –Type part of a file/directory name, hit, and the shell will finish as much of the name as it can –Works if you’re running tcsh or bash Command history –Don’t re-type previous commands – use the up-arrow to access them Wildcards –Special character(s) which can be expanded to match other file/directory names * Zero or more characters ? Zero or one character –Examples: ls *.txt rm may-?-notes.txt

September 2003Bent Thomsen - FIT Editing Text Which text editor is “the best” is a holy war. Pick one and get comfortable with it. Three text editors you should be aware of: –vi – A lighter editor, used in programming –emacs – A heavily-featured editor commonly used in programming –pico – Comes with pine ( Dante ’s program)

September 2003Bent Thomsen - FIT Printing Printing: –Use lpr to print –Check the print queue with lpq –lprm to remove print jobs –For the above commands, you’ll need to specify the printer with –P

September 2003Bent Thomsen - FIT Exiting Logout – leave the system Exit – leave the shell ^C interrupt ^D can log user off – often disabled

September 2003Bent Thomsen - FIT Remember In Unix, you’re expected to know what you’re doing. –Many commands will print a message only if something went wrong. –Most often there is no undo button –Make a backup copy if you are unsure –Some commands have interactive options E.g. rm –i Unix can be hard to learn, but it is loads of fun to use when you know what you are doing!

September 2003Bent Thomsen - FIT Opgaver og kursusmateriale m