Shells, Help, and Paths.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

1 Introduction to UNIX Ke Liu
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
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.
UNIX chapter 04 UNIX Shells Mr. Mohammad Smirat. Introduction The shell is the software that listens to commands typed in at the terminal and translates.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
“Linux at the Command Line” Don Johnson of BU IS&T.
Introduction to Linux and Shell Scripting Jacob Chan.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Linux Commands LINUX COMMANDS.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Introduction to Linux Operating System Tutorial 1
EMT 2390L Lecture 2 Dr. Reyes. Outline What is the Shell Basic commands Linux Filesystem System commands.
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”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
Unix Basics Chapter 4.
CENT 305 Information Systems Security Linux Introduction.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
Chapter 2: Getting Started Logon to Logout. In this chapter … Logging on The Shell Superuser Getting Help Logging off.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
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.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
Introduction to Programming Using C An Introduction to Operating Systems.
Advanced Programming in the UNIX Environment Hop Lee.
Linux Commands C151 Multi-User Operating Systems.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
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.
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  There are many different.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Company LOGO Security in Linux PhiHDN - VuongNQ. Contents Introduction 1 Fundamental Concepts 2 Security System Calls in Linux 3 Implementation of Security.
UNIX Filesystem and Hierarchy AfNOG 2008 Workshop May Rabat, Morocco.
Getting Started with Linux
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.
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
Andy Wang Object Oriented Programming in C++ COP 3330
System Programming and administration CS 308
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
The Linux Operating System
UNIX Filesystem and Hierarchy
Basic UNIX OLC Training.
Introduction to UNIX.
Sarah Diesburg Operating Systems CS 3430
Operating Systems and Using Linux
Intro to UNIX System and Homework 1
Exploring the UNIX File System and File Security
CSE 390a Lecture 1 introduction to Linux/Unix environment
Unix : Introduction and Commands
Operating Systems and Using Linux
CSE 390a Lecture 1 introduction to Linux/Unix environment
Andy Wang Object Oriented Programming in C++ COP 3330
CSE 303 Concepts and Tools for Software Development
What is Unix? A multi-user networked operating system
Operating Systems and Using Linux
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
January 26th, 2004 Class Meeting 2
SHELLSHOCK ATTACK.
Presentation transcript:

Shells, Help, and Paths

What is a “Shell” A shell is a program used to parse and execute “commands”. Popular Shells: – bash → /bin/bash – csh / tcsh → /bin/tcsh – zsh → /bin/zsh By “default”, all Linux installs usually come with sh, bash, and tcsh.

Commands A “command” has two main parts, the command and some number of arguments. When running a command, the shell checks if the command exists. If not, it produces an error. If the command is a “built-in”, it is handled by the shell. – Checked for correctness (command and arguments) If the command is not “built-in”, the shell does NOT check arguments. The shell executes the program and passes the arguments to it.

Other shell curiosities Prompts → left and right prompts, user configurable. Show: – time of day – cwd (current working directory) – username – command history – system information Output redirection & Pipes Can have variables (like programs)

More on Shells The shell itself is simply a program. Everyone can run the shell of their preference. This is set in /etc/passwd You will write your own shell in C/C++ (in CS352) Terminal: a window running a shell (xterm, konsole, gnome-terminal) Virtual Console: Text mode from Xwindows. Runs login + shells.

Linux (GNU) Utilities Man Short for manual Gives a “manual page” Information about specific application Information about configuration file Information about system calls (if applicable) General Usage information

Linux (GNU) Utilities Why man? Program semantics: e.g. to copy files, is it: copy <source> <destination> or copy <destination> <source> More likely, you forget the switches.

Linux (GNU) Utilities - switches YES! Commands have switches Usually of the form “-a” or “-B” or sometimes “--long-switch” Usually can appear in any order cmd -a -b == cmd -b -a Can be case sensative cmd -r != cmd -R

Switches Switches can have arguments! Could be: mycmd -b 1024 or mycmd -b=1024 or mycmd --block-size 1024 or mycmd –block-size=1024 Switches can be grouped, (sometimes even drop the “-”) Example: tar -c -z -v -f mydirectory.tgz www/ tar -czvf mydirectory.tgz www/ tar czvf mydriectory.tgz www/

More on system help man switches info -s: specify a list of sections to check -a: print all matching pages, not just first found info Like man, but fancier. Different format than man. More like an electronic book than man page

More on system help apropos man -k == apropos Want to know something about floppy drives? pyrite-n2:~> apropos floppy fd (4) - floppy disk device fdformat (8) - Low-level formats a floppy disk floppy (8) - format floppy disks mbadblocks (1) - tests a floppy disk, and marks the bad blocks in the FAT mformat (1) - add an MSDOS filesystem to a low-level formatted floppy disk mkbootdisk (8) - creates a stand-alone boot floppy for the running system man -k == apropos

Paths Recall that the UNIX file system is a large tree:

Paths, cont. You can ALWAYS reference a file or directory based on the root of the tree. For example, if I want to read the ssh configuration files, I know it is at: /etc/ssh/ssh_config and the server configuration file is at: /etc/ssh/sshd_config A file/directory reference that starts from the root of the filesystem is called an “absolute path”

Paths, cont. So, we can access any file based on its location and path from the root of the filesystem. But... Cumbersome (lots of directories?) Makes for VERY long scripts Difficult to move files/folders to sub- folders example: Move file from /home/user/project/myprog.c to /home/user/myotherproject/src/myprog.c

Paths, cont. Relative Paths! Working Directory: So we don't have to use absolute path for everything. Concept of “Working Directory” Working Directory: The directory associated with a process (a running executable) Remember that the shell is simply an executable file invoked by the kernel.

Paths, cont. pwd “print working directory” Will echo your current working directory to the terminal When we know where we are in the directory structure, we can use relative path names. pyrite-n2:~> pwd /home/ssg/bbritt

Paths, cont. Relative Paths: Do not start with / Assumes that all path names are prefixed by `pwd` for example: (assuming /home/user/cs252 is `pwd`) vim hw3/blah.c is the same as vim /home/user/cs252/hw3/blah.c

Even more Paths cd Change directory Will accept both absolute and relative paths example: cd cs252 cd /home/user/cs252

Special “Directories” . Current directory (almost) the same as `pwd` .. “parent” directory ~ “home” directory

Special “Directories”, cont. Examples: cd . Does absolutely nothing cd .. Make parent directory the working directory cd ~ Make home directory the working directory cd ~/cs252 Change directory to /home/user/cs252