Basic Shell Commands

Similar documents
UNIX Quick Reference

AN INTRODUCTION TO UNIX

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

Useful Unix Topics. Jeremy Sanders. October 2011

Computer Systems and Architecture

Introduction to Linux Organizing Files

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.

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.

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.

Chapter-3. Introduction to Unix: Fundamental Commands

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Introduction to Unix: Fundamental Commands

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

Lab Working with Linux Command Line

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 UNIX command-line

Computer Systems and Architecture

Files

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

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

An Introduction to Unix

Using Linux as a Virtual Machine

Introduction to Linux

Unix Workshop Aug 2014

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

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

Introduction to Linux. Fundamentals of Computer Science

Introduction: What is Unix?

Linux Reference Card - Command Summary

Lec 1 add-on: Linux Intro

EKT332 COMPUTER NETWORK

IMPORTANT: Logging Off LOGGING IN

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

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

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

Recitation #1 Boot Camp. August 30th, 2016

Linux and Git Boot Camp

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

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

CS197U: A Hands on Introduction to Unix

Unix Tools / Command Line

CS Fundamentals of Programming II Fall Very Basic UNIX

1 Very Short Linux Manual

Lecture # 2 Introduction to UNIX (Part 2)

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

Linux at the Command Line Don Johnson of BU IS&T

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

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

Getting Started with UNIX

CS 261 Recitation 1 Compiling C on UNIX

Practical Session 0 Introduction to Linux

Command-line interpreters

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

The Unix Shell & Shell Scripts

Linux Nuts and Bolts

BE CAREFUL! The Summer Research Student s Guide to UNIX

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Introduction to UNIX command-line II

COMS 6100 Class Notes 3

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

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

H C I - D C o m p u t e r A d m i n i s t r a t i o n

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Lab #1 Installing a System Due Friday, September 6, 2002

SIEMENS UserAdmin Workshop TELEPERM XP Version 4 Chapter 1

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

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

Introduction to UNIX/Linux

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

Recitation #1 Unix Boot Camp. August 29th, 2017

Parallel Programming Pre-Assignment. Setting up the Software Environment

Using the Zoo Workstations

Exercise 1: Basic Tools

Using the Unix system. UNIX Introduction

Introduction to Linux

CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

System Administration

Essential Linux Shell Commands

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

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Introduction to Linux

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

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Linux Interview Questions and Answers

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

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.

Introduction to the shell Part II

Unix Tutorial Haverford Astronomy 2014/2015

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Linux Essentials Objectives Topics:

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CS 460 Linux Tutorial

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Introduction to UNIX I: Command Line 1 / 21

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

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

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

CS370 Operating Systems

Transcription:

Basic Shell Commands Jeremy Sanders October 2011 1. acroread - Read or print a PDF file. 2. cat - Send a file to the screen in one go. Useful for piping to other programs cat file1 # list file1 to screen cat file1 file2 file3 > outfile # add files together into outfile cat *.txt > outfile # add all.txt files together cat file1 file2 grep fred # pipe files 3. cc - Compile a C program cc test1.c cc -O2 -o test2.prog test2.c # compile test1.c to a.out # compile test2.c to test2.prog 4. cd - Change current directory cd cd /papers cd fred cd dir cd /dir1/dir2/dir3... cd - # go to home directory # go to /home/user/papers # go to /home/fred # go to directory (relative) # go to directory (absolute) # go to last directory you were in 5. cp - Copy file(s) cp file1 file2 # copy file1 to file2 cp file1 directory # copy file1 into directory cp file1 file2 file3... directory # copy files into directory cp -R dir1 dir2/ # copy dir1 into dir2 including subdirectries cp -pr dir1 dir2/ # copy directory, preserving permissions 6. date - Shows current date > date Sat Aug 31 17:18:53 BST 2002 7. dvips - Convert a dvi file to PostScript dvips document.dvi dvips -Ppdf document.dvi # convert document.dvi to document.ps # convert to ps, for conversion to pdf 8. emacs - The ubiquitous text editor 1

emacs foo.txt emacsclient foo.txt # open file in emacs # open file in existing emacs (need to use # M-x start server first) 9. file - Tells you what sort of file it is > file temp_70.jpg temp_70.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), 72 x 72 10. firefox - Start Mozilla Firefox 11. f77/f90 - Compile a Fortran 77/99 program f77 -O2 -o testprog testprog.f 12. gedit - Gnome text editor 13. gnuplot - A plotting package. 14. grep - Look for text in files. List out lines containing text (with filename if more than one file examined). grep "hi there" file1 file2... # look for hi there in files grep -i "hi there" filename # ignore capitals in search cat filename grep "hi there" # use pipe grep -v "foo" filename # list lines that do not include foo 15. gtar - GNU version of the tar utility (also called tar on Linux). Store directories and files together into a single archive file. Use the normal tar program to backup files to a tape. See info tar for documentation. gtar cf out.tar dir1 # put contents of directory into out.tar gtar czf out.tar.gz dir1 # write compressed tar, out.tar.gz gtar tf in.tar # list contents of in.tar gtar tzf in.tar.gz # list contents of compressed in.tar.gz gtar xf in.tar # extract contents of in.tar here gtar xzf in.tar.gz # extract compressed in.tar.gz gtar xf in.tar file.txt... # extract file.txt from in.tar 16. gv - View a Postscript document with Ghostscript. 17. gzip / gunzip - GNU Compress files into a smaller space, or decompress.z or.gz files. gzip file.fits # compresses file.fits into file.fits.gz gunzip file.fits.gz # recovers original file.fits gzip *.dat # compresses all.dat files into.dat.gz gunzip *.dat.gz # decompresses all.dat.gz files into.dat program gzip > out.gz # compresses program output into out.gz program gunzip > out # decompresses compressed program output 18. info - A documentation system designed to replace man for GNU programs (e.g. gtar, gcc). Use cursor keys and return to go to sections. Press b to go back to previous section. A little hard to use. info gtar # documentation for gtar 2

19. kill - Kill, pause or continue a process. Can also be used for killing daemons. > ps -u jss... 666 pts/1 06:06:06 badprocess > kill 666 # this sends a nice kill to the # process. If that doesn t work do > kill -KILL 666 # (or equivalently) > kill -9 666 # which should really kill it! > kill -STOP 667 # pause (stop) process > kill -CONT 667 # unpause process 20. latex - Convert a tex file to dvi 21. logout - Closes the current shell. Also try exit. 22. lp - Sends files to a printer lp file.ps # sends postscript file to the default printer lp -dlp2 file.ps # sends file to the printer lp2 lp -c file.ps # copies file first, so you can delete it lpstat -p lp2 # get status and list of jobs on lp2 cancel lp2-258 # cancel print job lp2-258 lpr -Plp2 file.ps lpq -Plp2 lprm -Plp2 1234 # send file.ps to lp2 # get list of jobs on lp2 # delete job 1234 on lp2 23. ls - Show lists of files or information on the files ls file ls -l file ls *.txt ls -lt ls -lrt ls -a ls dir ls -d dir ls -p ls -R ls -1 # does the file exist? # show information about the file # show all files ending in.txt # show information about all files in date order # above reversed in order # show all files including hidden files # show contents of directory # does the directory exist? # adds meaning characters to ends of filenames # show files also in subdirectories of directory # show one file per line 24. man - Get instructions for a particular Unix command or a bit of Unix. Use space to get next page and q to exit. man man # get help on man man grep # get help on grep man -s1 sort # show documentation on sort in section 1 25. more - Show a file one screen at a time more file grep frog file more # show file one screen at a time # Do it to output of other command 3

26. mv - Move file(s) or rename a file mv file1 file2 # rename file1 to file2 mv dir1 dir2 # rename directory dir1 to dir2 mv file1 file2 file3... directory # move files into directory 27. nano - very simple text editor. Warning - this program can introduce extra line breaks in your file if the screen is too narrow! 28. nice - Start a process in a nice way. Nice levels run from -19 (high priority) to 19 (low priority). Jobs with a higher priority get more CPU time. See renice for more detail. You should probably be using the grid-engine to run long jobs. nice +19 myjob1 nice +8 myjob2 # run at lowest priority # run at lowish priority 29. openoffice.org - a free office suite available for Linux/Unix, Windows and Mac OS X. 30. passwd - change your password 31. pine - A commonly used text-based mail client. It is now called alpine. Allows you to send and receive emails. Configuration options allow it to become quite powerful. Other alternatives for mail are mozilla mail and mutt, however I suggest you stick to alpine or thunderbird. 32. printenv - Print an environment variable in tcsh setenv MYVARIABLE Fred printenv MYVARIABLE printenv # print all variables 33. ps - List processes on system > ps -u jss # list jss s processes 934 pts/0 00:00:00 bash ˆˆˆˆˆ ˆˆˆˆˆ ˆˆˆˆˆˆˆˆ ˆˆˆˆˆˆˆ PID output CPU time name > ps -f # list processes started here in full format > ps -AF # list all processes in extra full format > ps -A -l # list all processes in long format > ps -A grep tcsh # list all tcsh processes 34. pwd - Show current working directory > pwd /home/jss/writing/lecture 35. quota - Shows you how much disk space you have left > quota -v... 36. renice - Renice a running process. Make a process interact better with other processes on the system (see top to see how it is doing). Nice levels run from -19 (high priority) to 19 (low priority). Only your own processes can be niced and they can only be niced in the positive direction (unless you are root). Normal processes start at nice 0. 4

> ps -u jss grep bigprocess # look for bigprocess 1234 pts/0 99:00:00 bigprocess > renice 19 1234 # renice PID 1234 to 19 37. rm - Delete (remove) files rm file1 rm -r dir1 rm -rf dir1 # delete a file (use -i to ask whether sure) # delete a directory and everything in it (CARE!) # like above, but don t ask if we have a -i alias 38. rmdir - Delete a directory if it is empty (rm -r dirname is useful if it is not empty) rmdir dirname 39. staroffice - An office suite providing word processor, spreadsheet, drawing package. See Users Guide on how to install this. This is a commercial version of the openoffice office package - use openoffice.org on linux. 40. setenv - Set an environment variable in tcsh. setenv MYVARIABLE Fred echo Hi there $MYVARIABLE 41. tar - Combine files into one larger archive file, or extract files from that archive (same as gtar on Linux). tar cvf /dev/rmt/0./ tar tvf /dev/rmt/0 tar xvf /dev/rmt/0 # backup cwd into tape # list contents of tape # extract contents of tape 42. thunderbird - Start mozilla thunderbird. 43. top - Interactively show you the top processes on a system - the ones consuming the most computing (CPU) time. Press the q key in top to exit. Press the k key to kill a particular process. Press r to renice a process. 5