commandname flags arguments

Similar documents
Unix Filesystem. January 26 th, 2004 Class Meeting 2

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

UNIX File Hierarchy: Structure and Commands

A Brief Introduction to Unix

Chapter-3. Introduction to Unix: Fundamental Commands

Mills HPC Tutorial Series. Linux Basics I

Introduction to Unix: Fundamental Commands

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to the Linux Command Line

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

CHAPTER 1 UNIX FOR NONPROGRAMMERS

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Files

Basic Survival UNIX.

SECTION -C. Getting Started with UNIX

Oxford University Computing Services. Getting Started with Unix

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Essential Linux Shell Commands

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

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

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

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

Unix Workshop Aug 2014

Introduction to Linux

CSC209. Software Tools and Systems Programming.

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

Introduction to Linux

Operating Systems, Unix Files and Commands SEEM

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

CS Fundamentals of Programming II Fall Very Basic UNIX

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

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

This section reviews UNIX file, directory, and system commands, and is organized as follows:

CS246 Spring14 Programming Paradigm Notes on Linux

Permission and Ownership

Introduction to Linux

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

CS197U: A Hands on Introduction to Unix

Week 2 Lecture 3. Unix

Introduction: What is Unix?

The Unix Shell & Shell Scripts

Files and Directories

The Linux Command Line & Shell Scripting

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

Lecture 2b. Pathnames, files, special characters in filenames, and file permissions. COP 3353 Introduction to UNIX, FALL 2013

You will automatically be in your user (home) directory when you login.

Exercise Sheet 2. (Classifications of Operating Systems)

Exploring UNIX: Session 3

Outline. Structure of a UNIX command

12/7/10 ATSC 212 UNIX ATSC 212 ATSC 212 UNIX

Introduction to Linux Workshop 1

Getting Started with UNIX

AN INTRODUCTION TO UNIX

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

INTRODUCTION TO BIOINFORMATICS

CSN08101 Digital Forensics. Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

Introduction to Linux

Computer Systems and Architecture

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Course 144 Supplementary Materials. UNIX Fundamentals

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CISC 220 fall 2011, set 1: Linux basics

Practical Session 0 Introduction to Linux

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Std: XI CHAPTER-3 LINUX

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Using the Zoo Workstations

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Introduction to Linux. Fundamentals of Computer Science

CS4350 Unix Programming. Outline

Getting Started With UNIX Lab Exercises

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

CSCI 2132 Software Development. Lecture 5: File Permissions

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Linux Command Line Primer. By: Scott Marshall

Unix Introduction to UNIX

EECS2301. Lab 1 Winter 2016

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Unix basics exercise MBV-INFX410

Unix Basics. Systems Programming Concepts

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

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

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Getting started with Hugs on Linux

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Getting started with Hugs on Linux

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

Treebeard's Unix Cheat Sheet

genome[phd14]:/home/people/phd14/alignment >

Introduction to Linux

Introduction to the UNIX command line

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Introduction to UNIX Command Line

Transcription:

Unix Review, additional Unix commands CS101, Mock Introduction This handout/lecture reviews some basic UNIX commands that you should know how to use. A more detailed description of this and other commands is contained within the Introduction to Unix textbook by David Schwartz. In general, a Unix command has three parts as follows: commandname flags arguments Commandname is the command you wish to run. Examples you are probably already familiar with include ls (list the files in a directory) or cat (show the contents of a file). Flags allow you to specify certain options that are available for the command you have specified. For example, the l flag in addition with the ls command shows additional information about each file listed. Arguments allow you to tell Unix which items the command should operate on. For example, if you want to view the contents of the file somefile.cpp then you could use the cat command with the argument of somefile.cpp for a complete command of cat somefile.cpp Note that Unix is case-sensitive in most contexts, so be careful to use the proper upper or lowercase. File System The Unix file system is a hierarchical tree structure, just like you have probably encountered with Windows or Macintosh based computers. The root of the tree is named by the character /. An example from the directory tree on saturn.math.uaa.alaska.edu is shown below: /--------- usr/ etc/ bin/ dev/ var/ ls cp

File Types There are four types of file in the Unix file system: 1. Ordinary file. An ordinary file may contain text, a program, or other data. It can be either an ASCII file, with each of its bytes being in the numerical range 0-127 or a binary file where bytes may contain all possible values from 0-255. Example: ASCII source file named test.cpp Leftmost char is a - spooey /home/kenrick> ls -l test.cpp -rw-r--r-- 1 kenrick users 2056 Oct 3 03:03 test.cpp 2. Directory file. A directory is a file that consists of directory entries. Each file must have at least one directory entry. Example: Directory for HTML documents. Leftmost char is a d. drwxr-xr-x 12 kenrick users 1024 Jan 27 2000 public_html 3. Device file. A device file is an interface to a physical device such as a printer or disk drive. These devices are represented as files. For example, to read from a scanner you could read from it like it was a file, and to print to a printer you output like you are generating a file. One of the designs of Unix is such that almost everything can be treated like a file. Example: Hard drive 0. Leftmost char is a b (may be others) spooey /home/kenrick> ls -l /dev/fd0 brw-rw-rw- 1 root disk 2, 0 Sep 6 1998 /dev/fd0 4. Link file. Unix allows pointers to other files or directories. These link files are treated like they were the actual directory or file that is being pointed to. Example: zcat remapped to gzip. Leftmost char is a l. spooey /home/kenrick> ls -l /usr/bin/zcat lrwxrwxrwx 1 root root 4 Feb 27 1999 /usr/bin/zcat -> gzip The numbers in the long directory listing from left to right are: access permissions, number of file entries, owner of the file, group ownership, date last modified, and then the name of the file.

File Access Control In unix, all files are protected to some degree under access control mechanisms. This allows the owner of the file to allow or deny access to other users. The first column of the long directory list shows the access permissions: e.g. drwxr-x--x The leftmost character indicates that this is a directory. The remaining characters repeat with the pattern rwx three times. In this example, we have: rwx r-x --x The leftmost group of three are the permissions for the owner of the file. The middle group of three are the permissions for the group owner of the file. Multiple users might belong to the same group that are working on the same project, for example. Or there might be a special group for faculty, and another for students. The last group of three are the permissions for all users, regardless of what group they belong to. The r indicates read permission is granted. The w indicates write permission is granted. The x indicates execute permission is granted. For the example file, this means that the owner can read, write, or execute the file. Users in the same group can read and execute, but cannot write to the file. All other users can execute the file, but cannot read it and cannot write to it. Changing file permissions To change the permissions on the file, use the chmod command. We can actually exercise what we learned with number representation, and use octal to change file permissions! The r,w, and x flags are represented by three bits. They correspond to the following pattern:

Binary Octal 000 r=0, w=0, x=0 = 0 001 r=0, w=0, x=1 = 1 010 r=0, w=1, x=0 = 2 011 r=0, w=1, x=1 = 3 100 r=1, w=0, x=0 = 4 101 r=1, w=0, x=1 = 5 110 r=1, w=1, x=0 = 6 111 r=1, w=1, x=1 = 7 The octal numbers are used to represent the r, w, and x permissions for either the owner, group, or everyone. For example, to set the permissions so that the owner has full access (r,w,x) and the group/everyone can only read the file (r only), use the chmod command with the following parameters: chmod 744 filename If we want the owner to have full access (r,w,x) and the group to have (r,x) and everyone else to have no access to the file: chmod 750 filename There is another way to change the permissions of a filename using flags, but it doesn t exercise your knowledge of binary to octal, so we ll skip it for now Some Basic Commands We have already described the ls function. Let s just give a recap and list of other commands you will likely use: Listing directories ls ls l ls al ls public_html ls /bin - List the contents of the current directory - List the current directory in long format - List long, all files (normally files starting with. are hidden) - List contents of the public_html directory - List contents of the /bin directory Changing directories cd cd public_html cd.. cd ~ cd. - Change back to your home directory - Change into your public html directory - Change back one directory - Change to your home directory (~ = home directory) - Change to the same directory (. = current directory)

Misc directory commands pwd mkdir foo rmdir foo - Print current working directory - Create a new directory called foo - Remove the directory called foo File manipulation commands cp prog1 prog2 - Copy the file named prog1 to one named prog2 cp prog1 ~/temp/prog2 - Copy prog1 to your home directory / temp / prog2 mv prog1 prog2 - Move the file named prog1 to prog2, delete prog1 rm file1 - Removes the file named file1. There is no undelete! cat prog1.java - View the contents of prog1.java as an ASCII file more prog1.java - View the contents of prog1.java as ASCII, one screen at a time For all file manipulation commands, you can use wildcard characters. * matches an arbitrary number of characters, while? matches a single character. For example: mv *.html public_html Would move all files ending in.html into the public_html directory. Other commands man <command>!<pattern> script - Shows the manual pages on <command>, e.g. try man ls - Searches back and executes the last command you typed that started with the pattern. For example,!g would execute the last command you typed that started with the letter g. - Saves or records the results of all the commands you run into a file named typescript. Type exit to stop recording the script. Redirection, Pipe command > output - Redirects the results of command to the file named output e.g. ls > directorylist makes a file named directorylist with the contents of the directory. command1 command2 - Redirects the output of command1 into command2. Commonly used with more to pause: e.g. ls l more

Application Programs pine vi joe pico emacs ftp ssh scp - email reader, menu driven - Visual editor - Another text editor - Easy-to-use menu-driven editor - Text editor, supports mouse - File transfer protocol, transfer files between systems - Secure shell, login to a remote system securely - Secure copy, copy file to remote system securely