SlideShare a Scribd company logo
Using UNIX This document gives an overview of how to use UNIX. I don’t know who wrote this, but it’s very useful.
Getting More Help You can get more information about any of the topics discussed here by typing “ man <topic name>”,  for instance,     man ls If you don’t quite remember the name of the command, you can say “ apropos <topic name”, for instance     apropos directory There are also many good books in the library that describe all this.
Remember This Picture? There are many standard applications: file system commands interactive shells text editors compilers text processing Applications Libraries \ Kernel (OS) Hardware
Logging In To log in to a Unix machine you can either: sit at the  console  (the computer itself) access via the net (using telnet, rsh, ssh, kermit, or some other remote access client). The system prompts you for your username and password. Usernames and passwords are case sensitive!
Session Startup Once you log in, your shell will be started and it will display a prompt. When the shell is started it looks in your home directory for some customization files. You can change the shell prompt, your PATH, and a bunch of other things by creating customization files.
Your Home Directory Every Unix process* has a notion of the “current working directory”. Your shell (which is a process) starts with the current working directory set to your home directory.
Interacting with the Shell The shell prints a prompt and waits for you to type in a command. The shell can deal with a couple of types of commands: shell internals - commands that the shell handles directly. External programs - the shell runs a program for you.
Some Simple Commands Here are some simple commands to get you started: ls lists file names (like DOS dir command). who lists users currently logged in. date shows the current time and date. pwd print working directory
The  ls  command The ls command displays the names of some files. If you give it the name of a directory as a  command line parameter  it will list all the files in the named directory.
ls  Command Line Options We can modify the output format of the  ls  program with a  command line option . The ls command support a bunch of options: l  long  format (include file times, owner and permissions) a   all  (shows hidden* files as well as regular files) F   include special char to indicate file types. *hidden files have names that start with &quot;.&quot;
Moving Around in the File System There cd command can change the current working directory: cd   c hange  d irectory The general form is: cd [directoryname]
cd With no parameter, the  cd  command changes the current directory to your home directory. You can also give  cd  a relative or absolute pathname: cd /usr cd ..
Some more commands and command line options ls -R   will list everything in a directory and in all the subdirectories recursively (the entire hierarchy). you might want to know that Ctrl-C will cancel a command (stop the command)! pwd : print working directory df : shows what disk holds a directory.
Copying Files The  cp  command copies files: cp [options] source dest The source is the name of the file you want to copy. dest is the name of the new file. source and dest can be relative or absolute.
Another form of  cp If you specify a dest that is a directory, cp will put a copy of the source in the directory. The filename will be the same as the filename of the source file.  cp [options] source destdir
Deleting (removing) Files The  rm  command deletes files: rm [options] names... rm  stands for &quot;remove&quot;. You can remove many files at once: rm foo /tmp/blah /users/clinton/intern
File attributes Every file has some attributes: Access Times:  when the file was created when the file was last changed when the file was last read Size Owners (user and group) Permissions
File Time Attributes Time Attributes: when the file was last changed ls -l when the file was created* ls -lc when the file was last read (accessed) ls -ul * actually it’s the time the file status last changed.
Other filesystem and file commands mkdir make directory rmdir remove directory touch change file timestamp (can also create a blank file) cat concatenate files and print out to terminal.
Shells Also known as: Unix Command Interpreter
Shell as a user interface A shell is a command interpreter that turns text that you type (at the command line) in to actions: runs a program, perhaps the  ls  program. allows you to edit a  command line . can establish alternative sources of input and destinations for output for programs.
Running a Program You type in the name of a program and some command line options: The shell reads this line, finds the program and runs it, feeding it the options you specified. The shell establishes 3 I/O  channels : Standard Input Standard Output Standard Error
Programs and Standard I/O Program Standard Input (STDIN) Standard Output (STDOUT) Standard Error (STDERR)
Unix Commands Most Unix commands (programs): read something from standard input. send something to standard output (typically depends on what the input is!). send error messages to standard error.
Defaults for I/O When a shell runs a program for you: standard input is your keyboard. standard output is your screen/window. standard error is your screen/window.
Terminating Standard Input If standard input is your keyboard, you can type stuff in that goes to a program. To end the input you press Ctrl-D (^D) on a line by itself, this ends the input  stream . The shell is a program that reads from standard input. What happens when you give the shell ^D?
Popular Shells sh Bourne Shell  ksh  Korn Shell  csh  C Shell bash  Bourne-Again Shell
Customization Each shell supports some customization. User prompt Where to find mail Shortcuts The customization takes place in  startup  files – files that are read by the shell when it starts up
Startup files sh,ksh:  /etc/profile (system defaults)    ~/.profile bash: ~/.bash_profile ~/.bashrc ~/.bash_logout csh: ~/.cshrc ~/.login ~/.logout
Wildcards (metacharacters) for filename abbreviation When you type in a command line the shell treats some characters as special. These special characters make it easy to specify filenames. The shell processes what you give it, using the special characters to replace your command line with one that includes a bunch of file names.
The special character * * matches anything. If you give the shell * by itself (as a command line argument) the shell will remove the * and replace it with all the filenames in the current directory. “ a*b ”  matches all files in the current directory that start with  a  and end with  b .
Understanding * The  echo  command prints out whatever you give it: > echo hi hi Try this: > echo *
* and  ls Things to try: ls * ls –al * ls a* ls *b
Input Redirection The shell can attach things other than your keyboard to standard input. A file (the contents of the file are fed to a program as if you typed it). A pipe (the output of another program is fed as input as if you typed it).
Output Redirection The shell can attach things other than your screen to standard output (or stderr). A file (the output of a program is stored in  file). A pipe (the output of a program is fed as input to another program).
How to tell the shell to redirect things To tell the shell to store the output of your program in a file, follow the command line for the program with the “>” character followed by the filename: ls > lsout the command above will create a file named  lsout  and put the output of the  ls  command in the file.
Input redirection To tell the shell to get standard input from a file, use the “<“ character: sort < nums The command above would sort the lines in the file nums and send the result to stdout.
You can do both! sort < nums > sortednums tr a-z A-Z < letter > rudeletter
Pipes A pipe is a holder for a stream of data. A pipe can be used to hold the output of one program and feed it to the input of another. prog1 prog2 STDOUT STDIN
Asking for a pipe Separate 2 commands with the “|” character. The shell does all the work! ls | sort  ls | sort > sortedls
Shell Variables The shell keeps track of a set of parameter names and values. Some of these parameters determine the behavior of the shell. We can access these variables: set new values for some to customize the shell. find out the value of some to help accomplish a task.
Example Shell Variables sh / ksh / bash PWD   current working directory PATH   list of places to look for commands HOME   home directory of user MAIL   where your email is stored TERM   what kind of terminal you have HISTFILE   where your command history  is saved
Displaying Shell Variables Prefix the name of a shell variable with &quot;$&quot;. The  echo  command will do: echo $HOME echo $PATH You can use these variables on any command line: ls -al $HOME
Setting Shell Variables You can change the value of a shell variable with an assignment command (this is a shell  builtin  command): HOME=/etc PATH=/usr/bin:/usr/etc:/sbin NEWVAR=&quot;blah blah blah&quot;
set  command (shell builtin) The  set  command with no parameters will print out a list of all the shell varibles. You'll probably get a pretty long list… Depending on your shell, you might get other stuff as well...
The  PATH Each time you give the shell a command line it does the following: Checks to see if the command is a shell built-in. If not - tries to find a program whose name (the filename) is the same as the command. The  PATH  variable tells the shell where to look for programs (non built-in commands).
echo  $PATH The  PATH  is a list of &quot;:&quot; delimited directories. The  PATH  is a list and a  search order . You can add stuff to your PATH by changing the shell startup file (on RCS change  ~/.bashrc )
Job Control  The shell allows you to manage  jobs place  jobs  in the  background move a job to the foreground suspend a job kill a job
Background jobs If you follow a command line with &quot;&&quot;, the shell will run the  job  in the background. you don't need to wait for the job to complete, you can type in a new command right away. you can have a bunch of jobs running at once. you can do all this with a single terminal (window). ls -lR > saved_ls &
Listing jobs The command  jobs  will list all background jobs: > jobs [1] Running  ls -lR > saved_ls & > The shell assigns a number to each job (this one is job number 1).
Suspending and Killing the Foreground Job You can suspend the foreground job by pressing ^Z (Ctrl-Z).  Suspend means the job is stopped, but not dead. The job will show up in the  jobs  output. You can  kill  the foreground job by pressing ^C (Ctrl-C).  It's gone...
Quoting - the problem We've already seen that some characters mean something special when typed on the command line:  * ? []   What if we don't want the shell to treat these as special - we really mean *, not all the files in the current directory: echo here is a star *
Quoting - the solution To turn off special meaning - surround a string with double quotes: > echo here is a star &quot;*&quot; > here is a star *
Quoting Exceptions Some  special  characters are  not   ignored even if inside double quotes: $ (prefix for variable names) &quot; the quote character itself \  slash is always something special (\n) you can use \$ to mean $ or \&quot; to mean &quot; echo &quot;This is a quote \&quot; &quot;
Single quotes You can use single quotes just like double quotes. Nothing (except  ' ) is treated special. >  echo 'This is a quote \&quot; ' This is a quote \&quot; >
Backquotes are different! If you surround a string with backquotes the string is replaced with the result of running the command in backquotes: > echo `ls` foo fee file? > PS1=`date` Tue Jan 25 00:32:04 EST 2000 new prompt!
Programming Text editors emacs, vi Can also use any PC editor if you can get at the files from your PC. Compilers – gcc. Debuggers: gdb xxgdb
Ad

More Related Content

What's hot (20)

Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Gaurav Shinde
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
Simon Su
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Chap06
Chap06Chap06
Chap06
Dr.Ravi
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
Mohamed Abubakar Sittik A
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
ananthimurugesan
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Ashrith Mekala
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Geeks Anonymes
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
Narendra Sisodiya
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
vceder
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 
Unix shell scripts
Unix shell scriptsUnix shell scripts
Unix shell scripts
Prakash Lambha
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
Chaitanya Kn
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
Simon Su
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
vceder
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
Akshay Siwal
 

Similar to Using Unix (20)

60761 linux
60761 linux60761 linux
60761 linux
Ritika Ahlawat
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
Haitham Raik
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
duquoi
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Linux Basics
Linux BasicsLinux Basics
Linux Basics
Team-VLSI-ITMU
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
harikrishnapolaki
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
LuigysToro
 
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
linux-lecture4.pptuyhbjhbiibihbiuhbbihbilinux-lecture4.pptuyhbjhbiibihbiuhbbihbi
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
anandvaidya
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
BITS
 
Linux com
Linux comLinux com
Linux com
MohanKumar Palanichamy
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Unix
UnixUnix
Unix
Sudharsan S
 
Linux
LinuxLinux
Linux
merlin deepika
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
Haitham Raik
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
duquoi
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
harikrishnapolaki
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
LuigysToro
 
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
linux-lecture4.pptuyhbjhbiibihbiuhbbihbilinux-lecture4.pptuyhbjhbiibihbiuhbbihbi
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
anandvaidya
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
BITS
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Ad

More from Dr.Ravi (19)

Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate Overview
Dr.Ravi
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The Ceo
Dr.Ravi
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs Pf
Dr.Ravi
 
Pf Day5
Pf Day5Pf Day5
Pf Day5
Dr.Ravi
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming Fundamentals
Dr.Ravi
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd Chssc
Dr.Ravi
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3
Dr.Ravi
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1
Dr.Ravi
 
Pf Day3
Pf Day3Pf Day3
Pf Day3
Dr.Ravi
 
Ldd Pf
Ldd PfLdd Pf
Ldd Pf
Dr.Ravi
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc Assignments
Dr.Ravi
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4
Dr.Ravi
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2
Dr.Ravi
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
Dr.Ravi
 
Unix Book
Unix BookUnix Book
Unix Book
Dr.Ravi
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
Dr.Ravi
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell Scripts
Dr.Ravi
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRO
Dr.Ravi
 
Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate Overview
Dr.Ravi
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The Ceo
Dr.Ravi
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs Pf
Dr.Ravi
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming Fundamentals
Dr.Ravi
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd Chssc
Dr.Ravi
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3
Dr.Ravi
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1
Dr.Ravi
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc Assignments
Dr.Ravi
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4
Dr.Ravi
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2
Dr.Ravi
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
Dr.Ravi
 
Unix Book
Unix BookUnix Book
Unix Book
Dr.Ravi
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
Dr.Ravi
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell Scripts
Dr.Ravi
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRO
Dr.Ravi
 
Ad

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 

Using Unix

  • 1. Using UNIX This document gives an overview of how to use UNIX. I don’t know who wrote this, but it’s very useful.
  • 2. Getting More Help You can get more information about any of the topics discussed here by typing “ man <topic name>”, for instance,  man ls If you don’t quite remember the name of the command, you can say “ apropos <topic name”, for instance  apropos directory There are also many good books in the library that describe all this.
  • 3. Remember This Picture? There are many standard applications: file system commands interactive shells text editors compilers text processing Applications Libraries \ Kernel (OS) Hardware
  • 4. Logging In To log in to a Unix machine you can either: sit at the console (the computer itself) access via the net (using telnet, rsh, ssh, kermit, or some other remote access client). The system prompts you for your username and password. Usernames and passwords are case sensitive!
  • 5. Session Startup Once you log in, your shell will be started and it will display a prompt. When the shell is started it looks in your home directory for some customization files. You can change the shell prompt, your PATH, and a bunch of other things by creating customization files.
  • 6. Your Home Directory Every Unix process* has a notion of the “current working directory”. Your shell (which is a process) starts with the current working directory set to your home directory.
  • 7. Interacting with the Shell The shell prints a prompt and waits for you to type in a command. The shell can deal with a couple of types of commands: shell internals - commands that the shell handles directly. External programs - the shell runs a program for you.
  • 8. Some Simple Commands Here are some simple commands to get you started: ls lists file names (like DOS dir command). who lists users currently logged in. date shows the current time and date. pwd print working directory
  • 9. The ls command The ls command displays the names of some files. If you give it the name of a directory as a command line parameter it will list all the files in the named directory.
  • 10. ls Command Line Options We can modify the output format of the ls program with a command line option . The ls command support a bunch of options: l long format (include file times, owner and permissions) a all (shows hidden* files as well as regular files) F include special char to indicate file types. *hidden files have names that start with &quot;.&quot;
  • 11. Moving Around in the File System There cd command can change the current working directory: cd c hange d irectory The general form is: cd [directoryname]
  • 12. cd With no parameter, the cd command changes the current directory to your home directory. You can also give cd a relative or absolute pathname: cd /usr cd ..
  • 13. Some more commands and command line options ls -R will list everything in a directory and in all the subdirectories recursively (the entire hierarchy). you might want to know that Ctrl-C will cancel a command (stop the command)! pwd : print working directory df : shows what disk holds a directory.
  • 14. Copying Files The cp command copies files: cp [options] source dest The source is the name of the file you want to copy. dest is the name of the new file. source and dest can be relative or absolute.
  • 15. Another form of cp If you specify a dest that is a directory, cp will put a copy of the source in the directory. The filename will be the same as the filename of the source file. cp [options] source destdir
  • 16. Deleting (removing) Files The rm command deletes files: rm [options] names... rm stands for &quot;remove&quot;. You can remove many files at once: rm foo /tmp/blah /users/clinton/intern
  • 17. File attributes Every file has some attributes: Access Times: when the file was created when the file was last changed when the file was last read Size Owners (user and group) Permissions
  • 18. File Time Attributes Time Attributes: when the file was last changed ls -l when the file was created* ls -lc when the file was last read (accessed) ls -ul * actually it’s the time the file status last changed.
  • 19. Other filesystem and file commands mkdir make directory rmdir remove directory touch change file timestamp (can also create a blank file) cat concatenate files and print out to terminal.
  • 20. Shells Also known as: Unix Command Interpreter
  • 21. Shell as a user interface A shell is a command interpreter that turns text that you type (at the command line) in to actions: runs a program, perhaps the ls program. allows you to edit a command line . can establish alternative sources of input and destinations for output for programs.
  • 22. Running a Program You type in the name of a program and some command line options: The shell reads this line, finds the program and runs it, feeding it the options you specified. The shell establishes 3 I/O channels : Standard Input Standard Output Standard Error
  • 23. Programs and Standard I/O Program Standard Input (STDIN) Standard Output (STDOUT) Standard Error (STDERR)
  • 24. Unix Commands Most Unix commands (programs): read something from standard input. send something to standard output (typically depends on what the input is!). send error messages to standard error.
  • 25. Defaults for I/O When a shell runs a program for you: standard input is your keyboard. standard output is your screen/window. standard error is your screen/window.
  • 26. Terminating Standard Input If standard input is your keyboard, you can type stuff in that goes to a program. To end the input you press Ctrl-D (^D) on a line by itself, this ends the input stream . The shell is a program that reads from standard input. What happens when you give the shell ^D?
  • 27. Popular Shells sh Bourne Shell ksh Korn Shell csh C Shell bash Bourne-Again Shell
  • 28. Customization Each shell supports some customization. User prompt Where to find mail Shortcuts The customization takes place in startup files – files that are read by the shell when it starts up
  • 29. Startup files sh,ksh: /etc/profile (system defaults) ~/.profile bash: ~/.bash_profile ~/.bashrc ~/.bash_logout csh: ~/.cshrc ~/.login ~/.logout
  • 30. Wildcards (metacharacters) for filename abbreviation When you type in a command line the shell treats some characters as special. These special characters make it easy to specify filenames. The shell processes what you give it, using the special characters to replace your command line with one that includes a bunch of file names.
  • 31. The special character * * matches anything. If you give the shell * by itself (as a command line argument) the shell will remove the * and replace it with all the filenames in the current directory. “ a*b ” matches all files in the current directory that start with a and end with b .
  • 32. Understanding * The echo command prints out whatever you give it: > echo hi hi Try this: > echo *
  • 33. * and ls Things to try: ls * ls –al * ls a* ls *b
  • 34. Input Redirection The shell can attach things other than your keyboard to standard input. A file (the contents of the file are fed to a program as if you typed it). A pipe (the output of another program is fed as input as if you typed it).
  • 35. Output Redirection The shell can attach things other than your screen to standard output (or stderr). A file (the output of a program is stored in file). A pipe (the output of a program is fed as input to another program).
  • 36. How to tell the shell to redirect things To tell the shell to store the output of your program in a file, follow the command line for the program with the “>” character followed by the filename: ls > lsout the command above will create a file named lsout and put the output of the ls command in the file.
  • 37. Input redirection To tell the shell to get standard input from a file, use the “<“ character: sort < nums The command above would sort the lines in the file nums and send the result to stdout.
  • 38. You can do both! sort < nums > sortednums tr a-z A-Z < letter > rudeletter
  • 39. Pipes A pipe is a holder for a stream of data. A pipe can be used to hold the output of one program and feed it to the input of another. prog1 prog2 STDOUT STDIN
  • 40. Asking for a pipe Separate 2 commands with the “|” character. The shell does all the work! ls | sort ls | sort > sortedls
  • 41. Shell Variables The shell keeps track of a set of parameter names and values. Some of these parameters determine the behavior of the shell. We can access these variables: set new values for some to customize the shell. find out the value of some to help accomplish a task.
  • 42. Example Shell Variables sh / ksh / bash PWD current working directory PATH list of places to look for commands HOME home directory of user MAIL where your email is stored TERM what kind of terminal you have HISTFILE where your command history is saved
  • 43. Displaying Shell Variables Prefix the name of a shell variable with &quot;$&quot;. The echo command will do: echo $HOME echo $PATH You can use these variables on any command line: ls -al $HOME
  • 44. Setting Shell Variables You can change the value of a shell variable with an assignment command (this is a shell builtin command): HOME=/etc PATH=/usr/bin:/usr/etc:/sbin NEWVAR=&quot;blah blah blah&quot;
  • 45. set command (shell builtin) The set command with no parameters will print out a list of all the shell varibles. You'll probably get a pretty long list… Depending on your shell, you might get other stuff as well...
  • 46. The PATH Each time you give the shell a command line it does the following: Checks to see if the command is a shell built-in. If not - tries to find a program whose name (the filename) is the same as the command. The PATH variable tells the shell where to look for programs (non built-in commands).
  • 47. echo $PATH The PATH is a list of &quot;:&quot; delimited directories. The PATH is a list and a search order . You can add stuff to your PATH by changing the shell startup file (on RCS change ~/.bashrc )
  • 48. Job Control The shell allows you to manage jobs place jobs in the background move a job to the foreground suspend a job kill a job
  • 49. Background jobs If you follow a command line with &quot;&&quot;, the shell will run the job in the background. you don't need to wait for the job to complete, you can type in a new command right away. you can have a bunch of jobs running at once. you can do all this with a single terminal (window). ls -lR > saved_ls &
  • 50. Listing jobs The command jobs will list all background jobs: > jobs [1] Running ls -lR > saved_ls & > The shell assigns a number to each job (this one is job number 1).
  • 51. Suspending and Killing the Foreground Job You can suspend the foreground job by pressing ^Z (Ctrl-Z). Suspend means the job is stopped, but not dead. The job will show up in the jobs output. You can kill the foreground job by pressing ^C (Ctrl-C). It's gone...
  • 52. Quoting - the problem We've already seen that some characters mean something special when typed on the command line: * ? [] What if we don't want the shell to treat these as special - we really mean *, not all the files in the current directory: echo here is a star *
  • 53. Quoting - the solution To turn off special meaning - surround a string with double quotes: > echo here is a star &quot;*&quot; > here is a star *
  • 54. Quoting Exceptions Some special characters are not ignored even if inside double quotes: $ (prefix for variable names) &quot; the quote character itself \ slash is always something special (\n) you can use \$ to mean $ or \&quot; to mean &quot; echo &quot;This is a quote \&quot; &quot;
  • 55. Single quotes You can use single quotes just like double quotes. Nothing (except ' ) is treated special. > echo 'This is a quote \&quot; ' This is a quote \&quot; >
  • 56. Backquotes are different! If you surround a string with backquotes the string is replaced with the result of running the command in backquotes: > echo `ls` foo fee file? > PS1=`date` Tue Jan 25 00:32:04 EST 2000 new prompt!
  • 57. Programming Text editors emacs, vi Can also use any PC editor if you can get at the files from your PC. Compilers – gcc. Debuggers: gdb xxgdb