IMPORTANT: Logging Off LOGGING IN

Similar documents
UNIX Quick Reference

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

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

Computer Systems and Architecture

Linux Command Line Primer. By: Scott Marshall

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Computer Systems and Architecture

Fiery EXP6000/EXP5000 Color Server SERVER & CONTROLLER SOLUTIONS. Printing from UNIX

MTU Computer Structure

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Chapter-3. Introduction to Unix: Fundamental Commands

Linux Reference Card - Command Summary

UNIX Quick Reference

SIEMENS UserAdmin Workshop TELEPERM XP Version 4 Chapter 1

Introduction to Linux Organizing Files

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Unix Introduction to UNIX

Unix Tools / Command Line

UNIX Command Cheat Sheets

Oxford University Computing Services. Getting Started with Unix

Introduction: What is Unix?

UNIX Command Cheat Sheets

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

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

Outline. Structure of a UNIX command

Introduction to Linux

Unix Workshop Aug 2014

CS4350 Unix Programming. Outline

Lecture # 2 Introduction to UNIX (Part 2)

Perl and R Scripting for Biologists

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Introduction to Unix: Fundamental Commands

Introduction to UNIX Command Line

Linux crash lecture by Andrey Lukyanenko

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Operating Systems. Copyleft 2005, Binnur Kurt

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

Working with Basic Linux. Daniel Balagué

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

RH033 Red Hat Linux Essentials

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Fall Lecture 5. Operating Systems: Configuration & Use CIS345. The Linux Utilities. Mostafa Z. Ali.

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

Getting your department account

Bharadia Jaydeep OS with Unix MCQ

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

Practical Session 0 Introduction to Linux

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Common UNIX Utilities Alphabetical List

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Operating Systems Lab 1 (Users, Groups, and Security)

Basic Shell Commands

Introduction to Linux Workshop 1

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

Lab Working with Linux Command Line

5/20/2007. Touring Essential Programs

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

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

System Administration

M.C.A. (Sem.-lll) (CBCS) Examination November CCA-3003 Operating System and LinuxlUnix programming

Introduction to Linux

An Introduction to Unix

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

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Research. We make it happen. Unix Basics. User Support Group help-line: personal:

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

A Brief Introduction to the Linux Shell for Data Science

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

bash, part 3 Chris GauthierDickey

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Comparative and Functional Genomics

Command-line interpreters

UNIX. Basic UNIX Command

Basic Linux Command Line Interface Guide

Course 144 Supplementary Materials. UNIX Fundamentals

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Introduction to UNIX command-line

AN INTRODUCTION TO UNIX

Utilities. September 8, 2015

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Provides ability to perform UNIX commands at some time in the future. At time time on day day, the commands in filefile will be executed.

EECS2301. Lab 1 Winter 2016

Users Manual SX2. 2. Register this product host name and IP address to /etc/hosts file.

Getting Started with UNIX

Getting Started With UNIX Lab Exercises

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Introduction to Unix CHAPTER 6. File Systems. Permissions

The Unix Shell & Shell Scripts

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

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

Linux command line basics II: downloading data and controlling files. Yanbin Yin

INSE Lab 1 Introduction to UNIX Fall 2017

Part I. Introduction to Linux

Tutorial-1b: The Linux CLI

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

Transcription:

These are a few basic Unix commands compiled from Unix web sites, and printed materials. The main purpose is to help a beginner to go around with fewer difficulties. Therefore, I will be adding to this document base on our users experience, and suggestions. I have tried to adopt these material to our specific environment, however, it does not mean that all the commands and syntax would work on our system. If you encounter any problem, please email me. Afshin. Tel: 978-6618 Email: afshin@power.ele.utoronto.ca IMPORTANT: Do not switch off any of the workstations. Do not reboot / shutdown any of the workstations. Do not modify or rearrange the network cables. Do not send print jobs larger than 2.5 Meg to the printer. Make sure you logout before you leave a workstation. If you do not get your print output, make sure you remove the original print request by using "lprm", before re-sending it. Retrieve your old emails from the server. Pack and compress them in your own home directory. LOGGING IN To use the workstation, you must first login. To do so, you must have (at the minimum) a login name by which the computer and other users will know you as well as a password which you should keep to yourself. In fact, since the password protects your work and the entire system from unauthorized and careless users, and since it is relatively easy for other users (all throughout the networked world no less!) to move through Unix systems, you should carefully guard your password. In addition to your login name, the system will also assign you a user ID number and a group ID number. The user ID is a number which has a unique correspondence to your login name and which the system uses to keep tabs on you. When personal information is printed, such as in response to ls -l or ps commands, the system matches the user ID to the login name and prints out the login name. The group ID is a higher level identification shared among users which automatically permits (or forbids) a number of users permission to read and write the same files. Essentially all Unix commands require you to end or activate them by hitting the key labeled Enter (or Return or Carriage return or [ret]). If you make a mistake keying in your command, you can correct it with the Backspace key if you have not yet entered in [ret]. After you have given the computer your login name and password, there is a short delay while the computer validates your account. It then responds by introducing itself, telling you if you have mail, possibly asking you to identify the type of terminal you are on, and setting off a chain of actions as commanded by a file labeled.login or.profile. Finally, with a typically verbose Unix response, the computer presents you with a prompt. Logging Off Before we continue we should mention how to quit your workstation. The command logout will log you off the system. The command exit also works; it terminates the shell you are using and may be used to close xterm windows and in other situations where logout will not work. You can also use bye to terminate your session. 1

ANATOMY OF A UNIX COMMAND command- name -option( s) filename( s) or arguments Example: wc -l sample The first word of the command line is usually the command name. This is followed by the options, if any, then the filenames, directory name/ names, or other arguments, if any, and then a RETURN. Options are usually preceded by a dash and you may use more than one option per command. The examples on this reference card use bold case for command names and options and italics for arguments and filenames. Important Note about UNIX Commands UNIX commands are case sensitive. Type commands exactly as shown; most UNIX commands are lower case. File and directory names can be lower, upper, or mixed case but must be typed exactly as listed. Naming Files & Directories In general, file and directory names should be composed only of letters of the alphabet, digits, "." s, and "_" s. Be aware that files that begin with a "." do not appear in the directory list unless a special flag has been set when doing the list command. The period is often used to add a suffix on to a base filename. For example, the source code for C programs have a.c suffix added to them, e.g. prog.c. Separating a filename by a "." is particularly useful when using wildcard selections. Printing Files When you give the print command lpr, your print job is placed in the printer queue. If the printer is set and working properly, it will print out your job in turn. To check the status of your print job and to determine its print job number, use the lpq command. To stop a job from printing (say because you submitted the Encyclopedia Britannica by mistake, or because the printer is chewing up your output), try the command lprm or cancel, followed by your job number. Stopping a print job by turning off the power to the printer will certainly stop the printing, but it may disable the printer from further use by the system or confuse a (not so) smart printer or printer spool, or both. The printer can be enabled with the lpc or enable command, but it may take some system work to get the print spooler program working again. BSD PRINT (All But ultra) # lpr -Pprinter file(s) (Use lj for printer or type in " lpr file) Place file(s) in line printer queue. # lpq -Pprinter List files in line printer queue. # lprm -Pprinter job # CANCEL a printing job (get # from lpq). # lpc Line printer control to enable printer. 2

SYSTEM V PRINT (ultra) # lpstat List printers, devices, files in queues. # lp -dprinter filename(s) Place file(s) in line printer queue. # cancel job # CANCEL a printing job (get # from lpstat). # enable ENABLE a printer (may have to be superuser). example, % lpr prog.f (no -P, using default printer) Print prog.f on line printer. % lpq Tell me files being printed. % lprm 94 Stop printing prog.f. The printer is busy so try elsewhere. % lpq -Pmath (-P identifies a printer) Check the math dept.'s printer. no entries OK, it's idle. % lpr -Pmath prog.f Send the file to be printed. Search and Compare Commands You can try any of these. If there are filenames or other variables you need to change, they are indicated by italics. # diff file1 file2 List lines in file2 differing from file1. # file fname List fname's type (ASCII, text, directory, object). # grep pat fname Print lines in file fname containing pattern pat. # sort fname 3

Sort lines of fname based on options. Job Control Commands You can try any of these. If there are filenames or other variables you need to change, they are indicated by italics. # ctrl-z Stop active foreground job. NOTE: ctrl-z suspend the foreground job, it is still active. To stop it completely use "ps" to get the process id number, and then "kill" it. # bg Place stopped foreground job into background. # fg job Place background job into foreground. # jobs Return names and job no. of suspended jobs. File Manipulation Commands You can try any of these. If there are filenames or other variables you need to change, they are indicated by italics. # mv fold fnew Copy fold to fnew, remove fold (i.e. rename), files can be in different directories. # rm fold Remove (delete) fold. # rm -rf directory Remove directory and everything in it. # cp fold fnew Copy fold to fnew, destroy previous fnew. # cat filea > fileb Copy filea to fileb. # cat filea >> fileb Append filea to end of fileb (add to end). # ls List files in present directory. 4

# ls -l A long list of files. Displaying files # display file contents cat myfile # determine file type file myfile # display file, a screen at a time (Solaris) pg myfile # display first 100 lines of a file head -100 myfile # display last 50 lines of a file tail -50 myfile # display file that is changing, dynamically tail errlog.out -f System status check Listed here are a few system monitoring commands which should give you a rough idea of how the server is running. # server information uname -a # disk free, listed in KB df -kt # processes currently running ps -elf # user processes w whodo who am i finger ps File permissions Permission flags: r = read, w = write, x = execute Permissions are displayed for owner, group, and others. 5

# display files, with permissions ls -l # make file readable, writeable, and executable for group/others chmod 777 myfile # make file readable and executable for group/others chmod 755 myfile # make file inaccessible for all but the owner chmod 700 myfile # make file readable and executable for group/others, # user assumes owner's group during execution chmod 4755 myfile # change permission flags for directory contents chmod -R mydir # change group to staff for this file chgrp staff myfile # change owner to jsmith for this file chown jsmith myfile Note: You can use the umask command to set the default mode for newly created files. umask specifies the permissions to TAKE AWAY from all new files. For example, to get the permission mode of 751 by default, compute 777-751= 026, this is the value you give to umask: # umask 026 Listing files LIST FILES AND DIRECTORIES ls directory- name - list contents of directory options: -a list all files including invisible files -l long list - shows ownership, permission, and links -t list files chronologically -f append * to executable file name, / to directory name -d list directories -u list files using time of last access instead of time of last modification -F mark directories with forward slash, mark executables with an @- sign. -g lists ownership of each file or directory pwd -display the name of present working directory Examples; # list all files, with directory indicator, long format 6

ls -lpa # list all files, sorted by date, ascending ls -lpatr # list all text files ls *.txt Moving/copying files # rename file to backup copy mv myfile myfile.bak # copy file to backup copy cp myfile myfile.bak # move file to tmp directory mv myfile /tmp # copy file from tmp dir to current directory cp /tmp/myfile. Deleting files See scripting examples for group dissection routines. # delete the file rm myfile # delete directory rd mydir # delete directory, and all files in it rm -r mydir Disk usage # display disk free, in KB df -kt # display disk usage, in KB for directory du -k mydir # display directory disk usage, sort by largest first du -ak / sort -nr pg 7

Using tar # display contents of a file tar tvf myfile.tar # display contents of a diskette (Solaris) volcheck tar tvf /vol/dev/rdiskette0/unnamed_floppy # copy files to a tar file tar cvf myfile.tar *.sql # append files to a tar file tar rvfn myfile.tar *.txt # extract files from a tar filem to current dir tar xvf myfile.tar Redirecting output Output can be directed to another program or to a file. # send output to a file runbackup > /tmp/backup.log # also redirect error output runbackup > /tmp/backup.log 2> /tmp/errors.log # send output to grep program runbackup grep "serious" View Commands # cat file Print file on screen (or as directed by >, >>). # more file Print file, one screenful at a time. # view file Use the vi editor for viewing a file. # head file Print first 10 lines of file. # tail file Print file's last 10 lines on screen. 8