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”

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.
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.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
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
Linux Files. Files and directories As in Windows directories are structures which contain –Other directories –Files.
Guide To UNIX Using Linux Third Edition
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
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.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
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.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
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.
Unix Basics Chapter 4.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Linux+ Guide to Linux Certification, Second Edition
1 N305 C Programming. 2 Objectives for the Lab ä Learn problem solving strategies ä Achieve intermediate knowledge of C Programming Language ä Gain experience.
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.
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.
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.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Introduction to Programming Using C An Introduction to Operating Systems.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Linux Commands C151 Multi-User Operating Systems.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
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.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
Learning basic Unix command It 325 operating system.
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.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
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.
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.
Andy Wang Object Oriented Programming in C++ COP 3330
Lecture 2 Working with Files and Directories
Some Linux Commands.
The Command Prompt Commands are the way to “do things” in Unix
Introduction to UNIX.
Introduction Paul Flynn
Andy Wang Object Oriented Programming in C++ COP 3330
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
January 26th, 2004 Class Meeting 2
Presentation transcript:

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” program. It displays a prompt, waits for user input, and interprets the command line entered by the user. It goes back to the prompt again after interpreting a command line There are several different shells available, such as bsh, csh, tcsh, etc. We will be using the shell on UCFileSpace (Bourne- again shell or Bash)

Accessing Unix shell in this course Go to Search for Unix A description of accessing the Unix shell is given on Ucfilespace: –On Windows, PuTTY: –On Mac, using ssh command:

Editors Vim For Vim tutorial type on command line vimtutor Emacs For Emacs tutorial, while in Emacs type t for reference cards on Emacs and Vim See Supporting Material on CascadeLMS

Directories The shell should start you in your home directory. This is your individual space on the UNIX system for your files. You can find out the name of your current working directory by typing: pwd The system normally will display : /Users/username Change to a sub-directory “sub” by typing: cd sub No matter where in the directory structure you are, you can always get back to your home directory by typing: cd (without specifying a directory name). From your home directory, create a new subdirectory named "primer" for working through this tutorial: mkdir primer You can remove an empty subdirectory with the following command (but don't do this right now): rmdir primer Now change to the "primer" subdirectory, making it your current working directory: cd primer

Files (1) Since you just created the directory “primer”, nothing will be listed because the directory is empty. Create your first file called first using the Emacs or Vim text editor to type in text: My name is Joe Doe. This is my first file. Now when you list your files, you will see file "first" listed: ls first You can view a text file with the following command: cat first My name is Joe Doe. This is my first file. ("cat" is short for concatenate - you can use this to display multiple files together on the screen.) If you have a file that is longer than your 24-line console window, use instead "more" to list one page at a time or "less" to scroll the file down and up with the arrow keys. Don't use these programs to try to display binary (non-text) files on your console - the attempt to print the non-printable control characters might alter your console settings and render the console unusable.

Files (2) Copy file "first" using the following command: cp first 2nd By doing this you have created a new file named "2nd" which is a duplicate of file "first". The file listing reveals: ls 2nd first Now rename the file "2nd" to "second": mv 2nd second Listing the files still shows two files because you haven't created a new file, just changed an existing file's name: ls first second If you "cat" the second file, you'll see the same sentence as in your first file: cat second My first file. "mv" will allow you to move files, not just rename them. Perform the following commands: mkdir sub mv second sub ls sub second ls first sub

Files (3) You can list even more information about files by using the "-l" option with "ls": ls -l -rw-r--r-- 1 username group 15 Jan 4 16:26 first drwxr-xr-x 2 username group 512 Jan 4 17:11 sub (where "username" will be your username and "group" will be your group name). Among other things, this lists the creation date and time, file access permissions, and file size in bytes. The letter 'd' (the first character on the line) indicates the directory names. Next perform the following commands: cd sub pwd /Users/username/primer/sub ls -l -rw-r--r-- 1 username group 4 Jan 4 16:55 second cd.. pwd /Users/username/primer Finally, clean up the duplicate files by removing the "second" file and the "sub" subdirectory: rm sub/second rmdir sub ls -l -rw-r--r-- 1 username group 15 Jan 4 16:26 first

Online manual man - command for online manual

Path Names dir name + file name –Absolute pathname: starting from root –E.g. /user/doej/bin/myProg.cpp –Relative pathname myProg.cpp (a file under current dir) bin/myProg.cpp (a file under subdir “bin” of current dir –The system maintains a “current working directory”, and will prefix it to a relative pathname

Special Directories The first two members of any subdirectories are two special directories “.” and “..” “.” : self –Will show how to use it “..”: parent dir E.g.: cd.. –Go to the parent directory pwd sub1 cd../sub2

Source Code Naming Convention.cpp : C++ source code file

How to use GNU C++ compiler/linker g++ g++ myProg.cpp Compiles myProg.cpp, generates an object file, link the object file (with libraries), and generates an executable file called “a.out”. g++ myProg.cpp –o myProg Same as above, however the executable has a name “myProg”

How to execute your program Find the executable from the current directory, and run it Unix can take any file extension as executable –Does not have to use a “.exe” extension name –As long as the file is marked as executable For example, using default name a.out for executable, enter on command line: uc./a.out DON’T forget./ to indicate current directory

Redirection of Input and Output < filename take standard input from that filename > filename send standard output to filename Examples: ls > myfiles more < myfiles cat myfilesoutput

The UNIX pipe ls | more Same as ls > temp more < temp rm temp