July 10, 2003Serguei A. Mokhov, 1 UNIX Commands COMP 444/5201 Revision 1.4 January 25, 2005.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

1 Introduction to UNIX Ke Liu
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
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.
The Unix Shell. Operating System shell The shell is a command interpreter It forms the interface between a user and the operating system When you log.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
Shell Script Examples.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
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”
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
3 File Processing Mauro Jaskelioff. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
LIN Unix Lecture 3 Hana Filip. LIN UNIX Resources UNIX Tutorials UNIX help for.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
July 17, 2003Serguei A. Mokhov, 1 Shells and Shell Scripts COMP 444/5201 Revision 1.3 January 25, 2005.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
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.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
UNIX Commands COMP 1090 Introduction to Unix Fall
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Introduction to Programming Using C An Introduction to Operating Systems.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
1 CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
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.
Tutorial of Unix Command & shell scriptS 5027
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Lecture 2 Working with Files and Directories
Some Linux Commands.
Shell Environments.
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
LINUX Commands Tuesday, September 18, 2018Tuesday, September 18, 2018
Unix : Introduction and Commands
Tutorial of Unix Command & shell scriptS 5027
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Linux Commands LINUX COMMANDS.
January 26th, 2004 Class Meeting 2
Presentation transcript:

July 10, 2003Serguei A. Mokhov, 1 UNIX Commands COMP 444/5201 Revision 1.4 January 25, 2005

July 10, 2003Serguei A. Mokhov, 2 Contents Shell Intro Command Format Shell I/O Command I/O Command Overview

July 10, 2003Serguei A. Mokhov, 3 Shell Intro A system program that allows a user to execute: –shell functions (internal commands) –other programs (external commands) –shell scripts Linux/UNIX has a bunch of them, the most common are –tcsh, an expanded version of csh (Bill Joy, Berkley, Sun) –bash, one of the most popular and rich in functionality shells, an expansion of sh (AT&T Bell Labs) –ksh, Korn Shell –zhs –...

July 10, 2003Serguei A. Mokhov, 4 Command Format Format: command name and 0 or more arguments: % commandname [arg1]... [argN] By % sign I mean prompt here and hereafter. Arguments can be –options (switches to the command to indicate a mode of operation) ; usually prefixed with a hyphen (-) or two (--) in GNU style –non-options, or operands, basically the data to work with (actual data, or a file name)

July 10, 2003Serguei A. Mokhov, 5 Shell I/O Shell is a “power-user” interface, so the user interacts with the shell by typing in the commands. The shell interprets the commands, that may produce some results, they go back to the user and the control is given back to the user when a command completes (in general). In the case of external commands, shell executes actual programs that may call functions of the OS kernel. These system commands are often wrapped around a so- called system calls, to ask the kernel to perform an operation (usually privileged) on your behalf.

July 10, 2003Serguei A. Mokhov, 6 Command I/O Input to shell: –Command name and arguments typed by the user Input to a command: –Keyboard, file, or other commands Standard input: keyboard. Standard output: screen. These STDIN and STDOUT are often together referred to as a terminal. Both standard input and standard output can be redirected from/to a file or other command. File redirection: –< input –> output –>> output append

July 10, 2003Serguei A. Mokhov, 7 Commands

July 10, 2003Serguei A. Mokhov, 8 man Manual Pages The first command to remember Contains info about almost everything :-) –other commands –system calls –c/library functions –other utils, applications, configuration files To read about man itself type: % man man NOTE: unfortunately there’s no % man woman...

July 10, 2003Serguei A. Mokhov, 9 which Displays a path name of a command. Searches a path environmental variable for the command and displays the absolute path. To find which tcsh and bash are actually in use, type: % which tcsh % which bash % man which for more details

July 10, 2003Serguei A. Mokhov, 10 chsh Change Login Shell Login shell is the shell that interprets commands after you logged in by default. You can change it with chsh (provided that your system admin allowed you to do so). To list all possible shells, depending on implementation: % chsh -l % cat /etc/shells % chsh with no arguments will prompt you for the shell.

July 10, 2003Serguei A. Mokhov, 11 whereis Display all locations of a command (or some other binary, man page, or a source file). Searchers all directories to find commands that match whereis ’ argument % whereis tcsh

July 10, 2003Serguei A. Mokhov, 12 General Commands

July 10, 2003Serguei A. Mokhov, 13 passwd Change your login password. A very good idea after you got a new one. It’s usually a paranoid program asking your password to have at least 6 chars in the password, at least two alphabetical and one numerical characters. Some other restrictions (e.g. dictionary words or previous password similarity) may apply. Depending on a privilege, one can change user’s and group passwords as well as real name, login shell, etc. % man passwd

July 10, 2003Serguei A. Mokhov, 14 date Guess what :-) Displays dates in various formats % date % date -u – in GMT % man date

July 10, 2003Serguei A. Mokhov, 15 cal Calendar –for month –entire year Years range: No year 0 Calendar was corrected in removed 11 days % cal current month % cal Feb 2000, leap year % cal not a leap year % cal leap year % cal days skipped % cal 0 error % cal 2002 whole year

July 10, 2003Serguei A. Mokhov, 16 clear Clears the screen There’s an alias for it: Ctrl+L Example sequence: –% cal –% clear –% cal –Ctrl+L

July 10, 2003Serguei A. Mokhov, 17 sleep “Sleeping” is doing nothing for some time. Usually used for delays in shell scripts. % sleep 2 2 seconds pause

July 10, 2003Serguei A. Mokhov, 18 Command Grouping Semicolon: “;” Often grouping acts as if it were a single command, so an output of different commands can be redirected to a file: % (date; cal; date) > out.txt

July 10, 2003Serguei A. Mokhov, 19 alias Defined a new name for a command % alias –with no arguments lists currently active aliases % alias newcommand oldcommand –defines a newcommand % alias cl cal 2003 % cl

July 10, 2003Serguei A. Mokhov, 20 unalias Removes alias Requires an argument. % unalias cl

July 10, 2003Serguei A. Mokhov, 21 history Display a history of recently used commands % history –all commands in the history % history 10 –last 10 % history -r 10 –reverse order % !! –repeat last command % !n –repeat command n in the history % !-1 –repeat last command = !! % !-2 –repeat second last command % !ca –repeat last command that begins with ‘ca’

July 10, 2003Serguei A. Mokhov, 22 apropos Search man pages for a substring. % apropos word Equivalent: % man -k word % apropos date % man -k date % apropos password

July 10, 2003Serguei A. Mokhov, 23 exit / logout Exit from your login session. % exit % logout

July 10, 2003Serguei A. Mokhov, 24 shutdown Causes system to shutdown or reboot cleanly. May require superuser privileges % shutdown -h now - stop % shutdown -r now - reboot

July 10, 2003Serguei A. Mokhov, 25 Files

July 10, 2003Serguei A. Mokhov, 26 ls List directory contents Has whole bunch of options, see man ls for details. % ls –all files except those starting with a “.” % ls -a –all % ls -A –all without “.” and “..” % ls -F –append “/” to dirs and “*” to executables % ls -l –long format % ls -al % ls -lt –sort by modification time (latest - earliest) % ls -ltr –reverse

July 10, 2003Serguei A. Mokhov, 27 cat Display and concatenate files. % cat –Will read from STDIN and print to STDOT every line you enter. % cat file1 [file2]... –Will concatenate all files in one and print them to STDOUT % cat > filename –Will take whatever you type from STDIN and will put it into the file filename To exit cat or cat > filename type Ctrl+D to indicate EOF (End of File).

July 10, 2003Serguei A. Mokhov, 28 more / less Pagers to display contents of large files page by page or scroll line by line up and down. Have a lot of viewing options and search capability. Interactive. To exit: ‘q’

July 10, 2003Serguei A. Mokhov, 29 less less ("less is more") a bit more smart than the more command to display contents of a file: –% less filename To display line numbers: –% less -N filename To display a prompt: –% less -P"Press 'q' to quit" filename Combine the two: –% less -NP"Blah-blah-blah" filename For more information: –% man less

July 10, 2003Serguei A. Mokhov, 30 touch By touching a file you either create it if it did not exists (with 0 length). Or you update it’s last modification and access times. There are options to override the default behavior. % touch file % man touch

July 10, 2003Serguei A. Mokhov, 31 cp Copies files / directories. % cp [options] % cp file1 file2 % cp file1 [file2] … /directory Useful option: -i to prevent overwriting existing files and prompt the user to confirm.

July 10, 2003Serguei A. Mokhov, 32 mv Moves or renames files/directories. % mv –The gets removed % mv file1 dir/ % mv file1 file2 –rename % mv file1 file2 dir/ % mv dir1 dir2

July 10, 2003Serguei A. Mokhov, 33 rm Removes file(s) and/or directories. % rm file1 [file2]... % rm -r dir1 [dir2]... % rm -r file1 dir1 dir2 file4...

July 10, 2003Serguei A. Mokhov, 34 script Writes a log (a typescript) of whatever happened in the terminal to a file. % script [file] % script –all log is saved into a file named typescript % script file –all log is saved into a file named file To exit logging, type: –% exit

July 10, 2003Serguei A. Mokhov, 35 find Looks up a file in a directory tree. % find. -name name % find. \(-name ‘w*’ -or -name ‘W*’ \)

July 10, 2003Serguei A. Mokhov, 36 mkdir Creates a directory. % mkdir newdir Often people make an alias of md for it.

July 10, 2003Serguei A. Mokhov, 37 cd Changes your current directory to a new one. % cd /some/other/dir –Absolute path % cd subdir –Assuming subdir is in the current directory. % cd –Returns you to your home directory.

July 10, 2003Serguei A. Mokhov, 38 pwd Displays personal working directory, i.e. your current directory. % pwd

July 10, 2003Serguei A. Mokhov, 39 rmdir Removes a directory. % rmdir dirname Equivalent: –% rm -r dirname

July 10, 2003Serguei A. Mokhov, 40 ln Symbolic link or a “shortcut” in M$ terminology. % ln –s

July 10, 2003Serguei A. Mokhov, 41 chmod Changes file permissions Possible invocations –% chmod 600 filename –-rw user group 2785 Feb 8 14:18 filename (a bit not intuitive where 600 comes from) –% chmod u+rw filename (the same thing, more readable) –For the assignment: % chmod u+x myshellscript (mysshellscript is now executable) -rwx user group 2785 Feb 8 14:18 myshellscript

July 10, 2003Serguei A. Mokhov, 42 grep Searches its input for a pattern. The pattern can be a simple substring or a complex regular expression. If a line matches, it’s directed to STDOUT; otherwise, it’s discarded. % echo “blah-foo” | grep blah –Will print the matching line % echo “blah-foo” | grep zee –Will not. See a separate grep tutorial.

July 10, 2003Serguei A. Mokhov, 43 Pipes What's a pipe? –is a method of interprocess communication (IPC) –in shells a '|' symbol used –it means that the output of one program (on one side of a pipe) serves as an input for the program on another end. –a set of "piped" commands is often called a pipeline Why it's useful? –Because by combining simple OS utilities one can easily solve more complex tasks

July 10, 2003Serguei A. Mokhov, 44 More on UNIX Commands and Editors