Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Similar documents
CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Lab 1 Introduction to UNIX and C

Computer Systems and Architecture

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Practical Session 0 Introduction to Linux

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

CS CS Tutorial 2 2 Winter 2018

Computer Systems and Architecture

CS Fundamentals of Programming II Fall Very Basic UNIX

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

UNIX. Basic UNIX Command

Week 2 Lecture 3. Unix

Introduction to the Linux Command Line

Lecture # 2 Introduction to UNIX (Part 2)

Using the Unix system. UNIX Introduction

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

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

Introduction to the UNIX command line

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Introduction to UNIX command-line

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

CHAPTER 1 UNIX FOR NONPROGRAMMERS

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

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to Supercomputing

Lab 1 Introduction to UNIX and C

UNIX Quick Reference

Linux Nuts and Bolts

Chapter-3. Introduction to Unix: Fundamental Commands

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Physics REU Unix Tutorial

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

MTU Computer Structure

Introduction to 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.

Unix. 1 tblgrant projects 0 Jun 17 15:40 doc1.txt. documents]$ touch doc2.txt documents]$ ls -l total 0

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

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.

Introduction to UNIX command-line II

SIEMENS UserAdmin Workshop TELEPERM XP Version 4 Chapter 1

Embedded Systems Ch 3A Linux Development Environment

Introduction to UNIX Command Line

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Linux Exercise. pwd answer: We call this directory (into which you get when you log in) your home directory.

Introduction to Linux

User Guide Version 2.0

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.

Exercise 1: Basic Tools

Basic Linux Commands. Srihari Kalgi M.Tech, CSE (KReSIT), IIT Bombay. May 5, 2009

EKT332 COMPUTER NETWORK

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

Getting Started With UNIX Lab Exercises

CENG393 Computer Networks Labwork 1

Introduction of Linux

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

FREEENGINEER.ORG. 1 of 6 11/5/15 8:31 PM. Learn UNIX in 10 minutes. Version 1.3. Preface

Introduction to Linux (Part II) BUPT/QMUL 2018/03/21

Introduction to Linux Basics

Development Environment & Linux Guide

CHEM5302 Fall 2015: Introduction to Maestro and the command line

Laboratory 1 Semester 1 11/12

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

Files and Directories

Files

Introduction to Unix. University of Massachusetts Medical School. October, 2014

Linux/Cygwin Practice Computer Architecture

Introduction to Linux. Fundamentals of Computer Science

Introduction to Linux

Mills HPC Tutorial Series. Linux Basics I

Operating Systems. Copyleft 2005, Binnur Kurt

Unix Basics. Systems Programming Concepts

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

5/8/2012. Creating and Changing Directories Chapter 7

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

Introduction to Linux

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Tutorial 1: Unix Basics

Unit 10. Linux Operating System

Introduction: The Unix shell and C programming

SECTION -C. Getting Started with UNIX

IMPORTANT: Logging Off LOGGING IN

C++ Programming on Linux

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Getting started with Hugs on Linux

Introduction to Linux

No Food or Drink in this room. Logon to Windows machine

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

Unix Tools / Command Line

Basic Shell Commands

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

Getting Started with UNIX

Parallel Programming Pre-Assignment. Setting up the Software Environment

Lab Working with Linux Command Line

Transcription:

Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

For this class you need to work from your grove account to finish your homework Knowing basic UNIX commands is essential to finish your homework

Overview Files and Directories How to connect to GROVE Basic UNIX commands TAR Permissions UNIX editor pico Compiling C programs

Files and Directories In computers, what is the difference between a file and a directory? A file is a program or a document A directory contains files or other directories

Directory Structure Inside directories, you could find files and other directories Inside those other directories, you might find more files, and more directories

How do I connect to grove? telnet grove.ufl.edu

Telnet Window For login, enter the username on your grove account card For Password, enter the password on the grove account card Grove will ask you to change your password Just follow the on-screen instructions http://grove.ufl.edu/ for more information

UNIX Commands mkdir [directory] create a new directory ls list files or directories in current directory. ls l list in long format (including details like permissions, owner, size, etc.)

More UNIX Commands pwd let you know the absolute pathname of your current working directory (Where your are) cd [dir] change directory cd.. go back to parent directory... is the relative pathname to the parent directory.

More UNIX Commands pico [filename] : create a new file cp Text editor ^X to quit and save the file cp [file1 file2] copy file1 to file2. If there s already a file2, the old one will be overwritten.

More UNIX Commands mv [sourcefile targetfile] basically mv renames sourcefile to targetfile. If there s a file with the same name as targetfile, it will be overwritten. rm file(s) delete file(s). rmdir directories delete one or more empty directories.

TAR Create tape archives and add or extract files. Creating a tar file: tar -cvf file.tar myfile.txt In the above example the system would create a tar named file.tar in the directory you currently are in. tar - cvf file.tar *.txt would compress all txt files in the current directory. tar -cvf home.tar home/ In the above example command the system would create a tar file named home.tar in the directory you currently are in of the home directory.

TAR Extracting the files from a tar file: tar -xvf myfile.tar In the above example command the system would uncompress (untar) the myfile.tar file in the current directory. tar -xvzf myfile.tar.gz In the above example command the system would uncompress (untar) the myfile.tar.gz file in the current directory. Note: There is no "untar" unix command.

Permissions There are three types of file access supported by UNIX. r read, view the contents of a file w write, edit file/directory contents x execute, run executable file

- rwx r-x r-- 1 c3460abc cgs3460 858 Jan 23 8:28 f1 type User permissions links owner group size Modification date/time File name Group permissions Other Permissions

Permissions read=4;write= 2;execute=1 rwx r-x r-- 4 + 2 + 1 4 + 0 + 1 4 + 0 + 0 7 5 4

Permissions chmod mode file(or directory) change the permission of the file or directory. Examples: Change the permission of file2 to: rwx r-x --x chmod 751 file2.

Unix Editor pico Simple and very easy to use text editor on UNIX Open a file using pico pico filename For example: pico hello.c The above example would open the editor with the file hello.c if present. Basic pico command (^ hold ctrl key) ^W where is ^Y previous page ^V next page

Compiling C Programs gcc is the "GNU" C Compiler. It is a free compiler that is available on grove.ufl.edu. Below are several examples that show how to use gcc to compile C programs.

Compiling a simple program Consider the following example: Let "hello.c" be a file that contains the following C code. #include <stdio.h> main() { (void) printf("hello \n"); return (0); } A standard way to compile this program is with the command gcc hello.c -o hello This command compiles hello.c into an executable program named "hello" that you run by typing './hello' (or possibly just 'hello') at the command line. It does nothing more than print "Hello..." on the screen.

Compiling a simple program Alternatively, the above program could be compiled using the following two commands. gcc -c hello.c gcc hello.o -o hello The end result is the same, but this two-step method first compiles hello.c into a machine code file named "hello.o" and then links hello.o with some system libraries to produce the final program "hello". In fact the first method also does this two-stage process of compiling and linking, but the stages are done transparently, and the intermediate file "hello.o" is deleted in the process.

Compiling a program with multiple source files If the source code is in several files, say "file1.c" and "file2.c", then they can be compiled into an executable program named "myprog" using the following command: gcc file1.c file2.c -o myprog The same result can be achieved using the following three commands: gcc -c file1.c gcc -c file2.c gcc file1.o file2.o -o myprog