Prof. Navrati Saxena navrati@ece.skku.ac.kr TA: R. Sachan rochak@skku.edu
What is UNIX Command What is UNIX Shell Linux file structure UNIX/LINUX Commands 2
A command is a program which interacts with the kernel to provide the environment and perform the functions called for by the user. A command can be: a built-in shell command; an executable shell file, known as a shell script; or a source compiled, object code file. The shell is a command line interpreter. The user interacts with the kernel through the shell. You can write ASCII (text) scripts to be acted upon by a shell. 3
The shell sits between you and the operating system, acting as a command interpreter. It reads your terminal input and translates the commands into actions taken by the system. The shell is analogous to command.com in DOS. When you log into the system you are given a default shell. When the shell starts up it reads its startup files and may set environment variables, command search paths, and command aliases, and executes any commands specified in these files. 4
The original shell was the Bourne shell, sh. Every Unix platform will either have the Bourne shell, or a Bourne compatible shell available. The default prompt for the Bourne Again Shell(BASH) is $ (or #, for the root user). Another popular shell is C Shell. The default prompt for the C shell is %. 5
6
File Management and Viewing File system Management Help, Job/Process Management Network Management System Management User Management Printing and Programming Document Preparation Miscellaneous 7
Common Shell Symbols ENTER Execute a command line Execution ; Separate commands on the same command line command Execute a command [ ] Match on a class of possible characters in the file names \ Quote the following character. Used to quote special characters. Pipes the standard output of one command as input for another command & Execute a command in the background! History command 8
Wildcard Symbols Execution * Match on any set of character in files name? Match on any single character in file names 9
Redirection Symbols Execution > Redirect the standard output to a file or device, creating the file if it does not exist and overwriting the file if it does exits >! The exclamation point forces the overwriting of a file if it already exists. This overrides the no clobber option. < Redirect the standard input from a file or device to a program. >> Redirect the standard output to a file or device, appending the output to the end of the file. 10
Standard Error Redirection Symbols Execution 2> Redirect the standard error to a file or divice 2>> Redirect and append the standard error to a file or device 2>&1 >& & Redirect the standard error to the standard output Redirect the standard error to a file or device Pipe the standard error as input to another command 11
This command shows your current logged in terminal user name $ whoami To understand the working of the command and possible options use (man command) $ man <command name> Using the GNU Info System (info, info command) $ <command name> info Listing a Description of a Program (whatis command) $ whatis <command name> 12
Listing/Viewing files: ls -demonstrates the existence of the new file Ls [option] [names] option -a, -all -b, --escape -d, --directory meaning List all files, including the normally hidden files whose na mes begin with a period. Display nonprinting characters in octal and alphabetic for mat. Report only on the directory, not its contents. -f Print directory contents in exactly the order in which they are stored, without attempting to sort them. -g Long listing like -l, but don't show file owners. -h Print sizes in kilobytes and megabytes. 13
Making Directories mkdir - to making a subdirectory Syntax: $ mkdir [Directory name] Change Directories cd- to change the current directory Syntax: $ cd [Directory name] Deleting Directories rm- to delete the directory/file Syntax: $ rm [option] [Directory name] 14
Searching Directories find- Search directories for files based on search Syntax: $ find [Directory List] [option] Ex.: $ find reports name Monday Moving Directories/files mv- to move file from one directory to other directory. Syntax: $ mv [file-name] [directory-name] Ex.: $ mv newprops props/version1 Copying Directories/files cp- to copy file from one direcory to another directory Syntax: $ cp [file-name] [Directory-name] EX.: $ cp preface doc1 props 15
Richard Petersen; "The Complete Reference, Linux, Fourth Edition", Osborne/McGraw-Hi ll, Christopher Negus; "Linux Bible, 2007 Editi on", Wiley Publishing, Inc http://www.freeos.com/guides/lsst/ http://bash.cyberciti.biz/guide/main_page 16