SlideShare a Scribd company logo
What is Unix? A multi-user networked operating system “Operating System” Handles files, running other programs, input/output Just like DOS or Windows “Networked” Designed for server use Networking is an intrinsic part of the system “Multi-user” Every user has different settings and permissions Multiple users can be logged in simultaneously Tons of fun!!!   This tutorial provided by UW ACM http://www.cs.washington.edu/orgs/acm/ Questions to ethel@cs, awong@cs
IWS (Instructional Work Servers) There are 4 instructional Unix servers: attu1, attu2, attu3 and attu4.  They can be accessed through attu.cs Accessing the servers: Terminal Programs: telnet (insecure; cannot be used) ssh (via the TeraTerm, Putty, or official SSH programs) Start  ->  Program Files  ->  Unix Connectivity  ->  Ssh -> SSH-x attu File Transfer Programs ftp (insercure; cannot be used at UW) O:\unix\iws\<username> Secure file transfer (from C&C)  http://www.washington.edu/computing/ software/uwick/contents.html
Logging In Which server you use  (almost)  doesn’t matter – all four allows access to your files Although your Windows and Unix usernames (and passwords) are the same,  they are two separate accounts Your z: drive is not your Unix account Connecting: We’ll connect to the Unix machines via ssh After connection, you are presented with a login prompt After logging in, you’re placed in your home directory (where your personal files are located)
The Command Prompt Commands are the way to “do things” in Unix A command consists of a command name and options called “flags” Commands are typed at the  command prompt In Unix,  everything  (including commands) is case-sensitive [prompt]$  <command> <flags> <args> attu1:/u15/awong$  ls –l -a unix-tutorial Command Prompt Command (Optional) flags (Optional) arguments Note : In Unix, you’re expected to know what you’re doing.  Many commands will print a message only if something went wrong.
Two Basic Commands The most useful commands you’ll ever learn: man   (short for “ man ual”) info They help you find information about other commands man <cmd>  or  info <cmd>  retrieves detailed information about  <cmd> man –k <keyword>  searches the man page summaries (faster, and will probably give better results) man –K <keyword>  searches the full text of the man pages fiji:/u15/awong$  man –k password passwd (5)  - password file xlock (1)  - Locks the local X display  until a password is entered fiji:/u15/awong$  passwd
Two Basic Commands (info) Info, as opposed to man, is category based Documents are hyperlinked info   <cmd>   retrieves detailed information about   <cmd> info   by itself will give instructions on its usage Type  q  to quit . Type  h  for help .
Directories In Unix, files are grouped together in other files called  directories , which are analogous to  folders  in Windows Directory paths are separated by a forward slash: / Example:  /u10/hctang/classes/cse326 The hierarchical structure of directories (the directory tree) begins at a special directory called the  root , or / Absolute paths  start at / Example:  /u10/hctang/classes/cse326 Relative paths  start in the current directory Example:  classes/cse326  (if you’re currently in  /u10/hctang ) Your home directory is where your personal files are located, and where you start when you log in. Example:  /u10/hctang
Directories (cont’d) Handy directories to know ~  Your home directory ..  The parent directory .  The current directory ls L i S ts the contents of the specified directories (or the current directory if no files are specified) Syntax:  ls [<file> … ] Example:  ls backups pwd P rint  W orking  D irectory
Directories (cont’d further) cd C hange  D irectory (or your home directory if unspecified) Syntax:  cd <directory> Examples:  cd backups/unix-tutorial cd ../class-notes mkdir M a K e  DIR ectory  Syntax:  mkdir <directories> Example:  mkdir backups class-notes rmdir R e M ove  DIR ectory, which  must be empty Syntax:  rmdir <directories> Example:  rmdir backups class-notes
Files Unlike Windows, in Unix file types (e.g. “executable files, ” “data files,” “text files”) are  not  determined by file extension (e.g. “foo.exe”, “foo.dat”, “foo.txt”) Thus, the file-manipulation commands are few and simple … Many commands only use 2 letters rm R e M oves a file,  without a possibility of “undelete!” Syntax:  rm [options] <file(s)> Example:  rm tutorial.txt backups/old.txt -r option:  recursive (delete directories) -f option:  force. Do no matter what
Files (cont’d) cp C o P ies a file, preserving the original Syntax:  cp [options] <sources> <destination> Example:  cp tutorial.txt tutorial.txt.bak -r option:  recursive (copies directories) mv M o V es (renames) a file or directory, destroying the original Syntax:  mv [options] <sources> <destination> Examples:  mv tutorial.txt tutorial.txt.bak mv tutorial.txt tutorial-slides.ppt backups/ Note : Both of these commands will over-write existing files   without warning you!
Permissions for files Files are owned by both a user and a group You will either belong to ugrad_cs or ugrad_ce Each file has 3 sets of permissions Permissions for the user who owns it  (user permissions) Permissions for the group that owns it (group permissions) Permissions for everyone else (‘other’ or ‘world’ permissions) There are 3 types of permissions Read  -- controls ability to read a file Write -- controls ability to write or change a file Executable -- controls whether or not a file can be executed as a program
Permissions for files (example) To see the permissions on a file, do a ‘ ls –l ’ attu4:/u15/awong$ ls –l -r--r--r--  1 awong  ugrad_ce  17375 Apr 26 2000  rgb.txt -rw-r--r--  1 awong  ugrad_ce  17375 Apr  5 02:57 set10.csv drwxr-xr--  1 awong  ugrad_ce  1024 Jan 19 19:39 tests Changing Permissions chmod [ugo]+[rxw] <filename> e.g.  chmod u+w rgb.txt     gives me permission to change rgb.txt Changing Ownership chown <user>.<group> <filename> e.g.  chmod awong.iuns rgb.txt     iuns group now owns rgb.txt Note: You cannot change which user owns file, unless you are an administrator, for security reasons.
Permissions on directories Directories can also be thought of as a file that lists all the files it contains. They also belong to a user and a group They have the same 3 sets of permissions For directories, this is what the permissions mean Read  -- You can read the list of files (eg. You can use “ls” and get the directory contents) Write -- You can change the list of files (eg. You can add or remove files from the directory) Executable -- You can use the directory list to let the operating system “find” the file. This means, you have access to the file.  All directories generally have execute permission.
Permissions Quiz Given the following output for ‘ ls –la ~ ’ for user awong.ugrad_ce attu4:/u15/awong$ ls –la ~ drwxr----x  1 awong  ugrad_ce  1024 Jan 19 19:39 . drwxr-xr-x  1 root  root   17375 Apr 26 2000 .. -rw-r--r--  1 awong  ugrad_ce  17375 Apr  5 02:57 readme.txt -rw-rwxr-x  1 awong  ugrad_ce  17375 Apr  5 02:57 myprog For users  ethel.ugrad_ce, jjlin@ugrad_cs,  and  awong.ugrad_ce: Who can create files in this directory? Who can get the list of files in this directory? Who can read the contents of the files readme.txt?  How about myprog?  Who can run the program “myprog”? What is dangerous about the permissions on myprog?  Especially the ‘.’ directory had g+w access? Can you think of a reason why you would give someone execute, but not read permissions on a directory?  How read but not execute?
Shell Shortcuts Tab completion Type part of a file/directory name, hit  <tab> , and the shell will finish as much of the name as it can Works if you’re running  tcsh  or  bash Command history Don’t re-type previous commands – use the up-arrow to access them Wildcards  Special character(s) which can be expanded to match other file/directory names *   Zero or more characters ?  Zero or one character Examples: ls *.txt rm may-?-notes.txt
Editing Text Which text editor is “the best” is a holy war.  Pick one and get comfortable with it. Three text editors you should be aware of: pico  – Comes with  pine  ( Dante ’s email program) To quit:  Ctrl-q emacs/xemacs  – A heavily-featured editor commonly used in programming To quit: Ctrl-x Ctrl-c vim/vi  – Another editor, also used in programming To quit: <Esc> : q <Enter>  (or QQ -- capitals matter) Knowing the basics of emacs and vim will help with the rest of Unix; many programs have similar key sequences.
Printing READ THE MORE UPDATED PRINTING TUTORIAL: http://www.cs.washington.edu/orgs/acm/tutorials/printing Printing: lpr :   print Use   –h   (no header) and   –Zduplex   (double-sided) to save paper lpq :  check the print queue (including Windows print jobs!) lprm :  remove print jobs (including Windows print jobs) For the above commands, you will need to specify the printer with the option:   –P<printer name> Check out   enscript   (quizlet: how do you find information about commands?) to print text files nicely!   WARNING:   Do  NOT  use   enscript   with postscript files!
Programs and Compilation (C++) To compile a program: g++ <options> <source files> Recommended:   g++ -Wall –ansi –o <executable_name> *.cpp -Wall  –  W arnings:  ALL -ansi  – Strict ANSI compliance Quizlet: what does  *.cpp  mean? What’s an “executable”? In Windows, double-clicking on an icon runs a program E.g. double-click on  C:\Windows\notepad.exe In Unix, you can run your executable from the command line! Type the executable name at the prompt, just like a command In fact, commands are actually executables However, you may need to specify the path to your executables ./<program>  runs  <program>  in the current directory Example: attu4:ehsu%  g++ -Wall –ansi –o hello hello.cpp attu4:ehsu% ./ hello
Programs and Compilation (Java) To compile a program: javac fileName1.java filename2.java . . . Errors will be printed to the screen with their line numbers Remember that the class name must have the same capitalization as the file name To compile all the .java files in the current folder: javac *.java To run : java classname (remember, no .java or .class) This will run the  main  method for that class.
X-Windows X-Windows is the most common graphical interface for Unix It allows graphics to be sent over the network (Windows Remote Desktop is similar to this) If you login via the ssh-x shortcuts, you will start and “X-server” on your machine and you will be able to get graphics from your unix commands If you log into a linux box, you will automatically have X-windows setup in that login.
Linux Machines, iuns Linux Machines: There are 6 linux machines in each lab The graphics work smoother on those machines Be sure to get a good “Window Manager” setup Ask one of the other people using the linux boxes for help setting up your window manager. Iuns: Iuns is the “instruction unsupported” software group Student volunteers maintain cutting edge software for unix and windows E-mail  [email_address]  for more info

More Related Content

What's hot (20)

PDF
Part 6 of "Introduction to linux for bioinformatics": Productivity tips
Joachim Jacob
 
PDF
Linux intro 2 basic terminal
Giovanni Marco Dall'Olio
 
DOCX
Linux final exam
Andrew Ibrahim
 
PDF
Basic linux commands
Shakeel Shafiq
 
PDF
Linux class 8 tar
Khawar Nehal [email protected]
 
PDF
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Joachim Jacob
 
PPTX
Linux Shell Basics
Constantine Nosovsky
 
PDF
Unix Command Line Productivity Tips
Keith Bennett
 
PDF
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Joachim Jacob
 
PDF
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
PDF
Linux intro 1 definitions
Giovanni Marco Dall'Olio
 
PPT
Linux basic commands
MohanKumar Palanichamy
 
ODP
Linux Introduction (Commands)
anandvaidya
 
PPTX
Unix - Filters/Editors
ananthimurugesan
 
PPT
Unix(introduction)
meashi
 
PPTX
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
PDF
50 most frequently used unix linux commands (with examples)
Rodrigo Maia
 
PDF
Lesson 1 Linux System Fundamentals
Sadia Bashir
 
PDF
Command Line Tools
David Harris
 
Part 6 of "Introduction to linux for bioinformatics": Productivity tips
Joachim Jacob
 
Linux intro 2 basic terminal
Giovanni Marco Dall'Olio
 
Linux final exam
Andrew Ibrahim
 
Basic linux commands
Shakeel Shafiq
 
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Joachim Jacob
 
Linux Shell Basics
Constantine Nosovsky
 
Unix Command Line Productivity Tips
Keith Bennett
 
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Joachim Jacob
 
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
Linux intro 1 definitions
Giovanni Marco Dall'Olio
 
Linux basic commands
MohanKumar Palanichamy
 
Linux Introduction (Commands)
anandvaidya
 
Unix - Filters/Editors
ananthimurugesan
 
Unix(introduction)
meashi
 
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
50 most frequently used unix linux commands (with examples)
Rodrigo Maia
 
Lesson 1 Linux System Fundamentals
Sadia Bashir
 
Command Line Tools
David Harris
 

Similar to Unix Basics 04sp (20)

PPT
Unix Basics
Dr.Ravi
 
PPT
Linux
SINGH PROJECTS
 
PPTX
Unix Linux Commands Presentation 2013
Wave Digitech
 
PPT
Karkha unix shell scritping
chockit88
 
ODP
Nithi
sharmibalu
 
ODP
Linux introduction-commands2338
Cam YP Co., Ltd
 
ODP
Linux introduction-commands2338
Cam YP Co., Ltd
 
PDF
MCLS 45 Lab Manual
Lokesh Singrol
 
PDF
Linux Basics
Team-VLSI-ITMU
 
PDF
Linux Cheat Sheet.pdf
roschahacker
 
PPTX
Linux administration training
iman darabi
 
ODP
Nguyễn Vũ Hưng: Basic Linux Power Tools
Vu Hung Nguyen
 
PPT
LINUX
ARJUN
 
PPT
Tutorial 2
tech2click
 
PPT
linux-lecture4.ppt
LuigysToro
 
PPTX
Red hat linux essentials
Haitham Raik
 
PPT
Shell_Scripting.ppt
KiranMantri
 
PPT
Linux commands and file structure
Sreenatha Reddy K R
 
PPT
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
PPT
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
Unix Basics
Dr.Ravi
 
Unix Linux Commands Presentation 2013
Wave Digitech
 
Karkha unix shell scritping
chockit88
 
Nithi
sharmibalu
 
Linux introduction-commands2338
Cam YP Co., Ltd
 
Linux introduction-commands2338
Cam YP Co., Ltd
 
MCLS 45 Lab Manual
Lokesh Singrol
 
Linux Basics
Team-VLSI-ITMU
 
Linux Cheat Sheet.pdf
roschahacker
 
Linux administration training
iman darabi
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Vu Hung Nguyen
 
LINUX
ARJUN
 
Tutorial 2
tech2click
 
linux-lecture4.ppt
LuigysToro
 
Red hat linux essentials
Haitham Raik
 
Shell_Scripting.ppt
KiranMantri
 
Linux commands and file structure
Sreenatha Reddy K R
 
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
Ad

More from Dr.Ravi (20)

PDF
Corporate Overview
Dr.Ravi
 
PDF
Excel For The Ceo
Dr.Ravi
 
PDF
Project Specs Pf
Dr.Ravi
 
PDF
Pf Day5
Dr.Ravi
 
PDF
Assignments Programming Fundamentals
Dr.Ravi
 
PDF
Hdd Chssc
Dr.Ravi
 
PDF
Chssc Day3
Dr.Ravi
 
PDF
Chssc Day1
Dr.Ravi
 
PDF
Pf Day3
Dr.Ravi
 
PDF
Ldd Pf
Dr.Ravi
 
PDF
Chssc Assignments
Dr.Ravi
 
PDF
Chssc Day4
Dr.Ravi
 
PDF
Chssc Day2
Dr.Ravi
 
PPT
Talk Unix Shell Script
Dr.Ravi
 
PPT
Shell Scripts
Dr.Ravi
 
PPT
Chap06
Dr.Ravi
 
PPT
Airlover 20030324 1
Dr.Ravi
 
PPT
Unix Lec2
Dr.Ravi
 
PDF
Unix Book
Dr.Ravi
 
PPT
Unix And C
Dr.Ravi
 
Corporate Overview
Dr.Ravi
 
Excel For The Ceo
Dr.Ravi
 
Project Specs Pf
Dr.Ravi
 
Pf Day5
Dr.Ravi
 
Assignments Programming Fundamentals
Dr.Ravi
 
Hdd Chssc
Dr.Ravi
 
Chssc Day3
Dr.Ravi
 
Chssc Day1
Dr.Ravi
 
Pf Day3
Dr.Ravi
 
Ldd Pf
Dr.Ravi
 
Chssc Assignments
Dr.Ravi
 
Chssc Day4
Dr.Ravi
 
Chssc Day2
Dr.Ravi
 
Talk Unix Shell Script
Dr.Ravi
 
Shell Scripts
Dr.Ravi
 
Chap06
Dr.Ravi
 
Airlover 20030324 1
Dr.Ravi
 
Unix Lec2
Dr.Ravi
 
Unix Book
Dr.Ravi
 
Unix And C
Dr.Ravi
 
Ad

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
July Patch Tuesday
Ivanti
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
July Patch Tuesday
Ivanti
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 

Unix Basics 04sp

  • 1. What is Unix? A multi-user networked operating system “Operating System” Handles files, running other programs, input/output Just like DOS or Windows “Networked” Designed for server use Networking is an intrinsic part of the system “Multi-user” Every user has different settings and permissions Multiple users can be logged in simultaneously Tons of fun!!!  This tutorial provided by UW ACM http://www.cs.washington.edu/orgs/acm/ Questions to ethel@cs, awong@cs
  • 2. IWS (Instructional Work Servers) There are 4 instructional Unix servers: attu1, attu2, attu3 and attu4. They can be accessed through attu.cs Accessing the servers: Terminal Programs: telnet (insecure; cannot be used) ssh (via the TeraTerm, Putty, or official SSH programs) Start -> Program Files -> Unix Connectivity -> Ssh -> SSH-x attu File Transfer Programs ftp (insercure; cannot be used at UW) O:\unix\iws\<username> Secure file transfer (from C&C) http://www.washington.edu/computing/ software/uwick/contents.html
  • 3. Logging In Which server you use (almost) doesn’t matter – all four allows access to your files Although your Windows and Unix usernames (and passwords) are the same, they are two separate accounts Your z: drive is not your Unix account Connecting: We’ll connect to the Unix machines via ssh After connection, you are presented with a login prompt After logging in, you’re placed in your home directory (where your personal files are located)
  • 4. The Command Prompt Commands are the way to “do things” in Unix A command consists of a command name and options called “flags” Commands are typed at the command prompt In Unix, everything (including commands) is case-sensitive [prompt]$ <command> <flags> <args> attu1:/u15/awong$ ls –l -a unix-tutorial Command Prompt Command (Optional) flags (Optional) arguments Note : In Unix, you’re expected to know what you’re doing. Many commands will print a message only if something went wrong.
  • 5. Two Basic Commands The most useful commands you’ll ever learn: man (short for “ man ual”) info They help you find information about other commands man <cmd> or info <cmd> retrieves detailed information about <cmd> man –k <keyword> searches the man page summaries (faster, and will probably give better results) man –K <keyword> searches the full text of the man pages fiji:/u15/awong$ man –k password passwd (5) - password file xlock (1) - Locks the local X display until a password is entered fiji:/u15/awong$ passwd
  • 6. Two Basic Commands (info) Info, as opposed to man, is category based Documents are hyperlinked info <cmd> retrieves detailed information about <cmd> info by itself will give instructions on its usage Type q to quit . Type h for help .
  • 7. Directories In Unix, files are grouped together in other files called directories , which are analogous to folders in Windows Directory paths are separated by a forward slash: / Example: /u10/hctang/classes/cse326 The hierarchical structure of directories (the directory tree) begins at a special directory called the root , or / Absolute paths start at / Example: /u10/hctang/classes/cse326 Relative paths start in the current directory Example: classes/cse326 (if you’re currently in /u10/hctang ) Your home directory is where your personal files are located, and where you start when you log in. Example: /u10/hctang
  • 8. Directories (cont’d) Handy directories to know ~ Your home directory .. The parent directory . The current directory ls L i S ts the contents of the specified directories (or the current directory if no files are specified) Syntax: ls [<file> … ] Example: ls backups pwd P rint W orking D irectory
  • 9. Directories (cont’d further) cd C hange D irectory (or your home directory if unspecified) Syntax: cd <directory> Examples: cd backups/unix-tutorial cd ../class-notes mkdir M a K e DIR ectory Syntax: mkdir <directories> Example: mkdir backups class-notes rmdir R e M ove DIR ectory, which must be empty Syntax: rmdir <directories> Example: rmdir backups class-notes
  • 10. Files Unlike Windows, in Unix file types (e.g. “executable files, ” “data files,” “text files”) are not determined by file extension (e.g. “foo.exe”, “foo.dat”, “foo.txt”) Thus, the file-manipulation commands are few and simple … Many commands only use 2 letters rm R e M oves a file, without a possibility of “undelete!” Syntax: rm [options] <file(s)> Example: rm tutorial.txt backups/old.txt -r option: recursive (delete directories) -f option: force. Do no matter what
  • 11. Files (cont’d) cp C o P ies a file, preserving the original Syntax: cp [options] <sources> <destination> Example: cp tutorial.txt tutorial.txt.bak -r option: recursive (copies directories) mv M o V es (renames) a file or directory, destroying the original Syntax: mv [options] <sources> <destination> Examples: mv tutorial.txt tutorial.txt.bak mv tutorial.txt tutorial-slides.ppt backups/ Note : Both of these commands will over-write existing files without warning you!
  • 12. Permissions for files Files are owned by both a user and a group You will either belong to ugrad_cs or ugrad_ce Each file has 3 sets of permissions Permissions for the user who owns it (user permissions) Permissions for the group that owns it (group permissions) Permissions for everyone else (‘other’ or ‘world’ permissions) There are 3 types of permissions Read -- controls ability to read a file Write -- controls ability to write or change a file Executable -- controls whether or not a file can be executed as a program
  • 13. Permissions for files (example) To see the permissions on a file, do a ‘ ls –l ’ attu4:/u15/awong$ ls –l -r--r--r-- 1 awong ugrad_ce 17375 Apr 26 2000 rgb.txt -rw-r--r-- 1 awong ugrad_ce 17375 Apr 5 02:57 set10.csv drwxr-xr-- 1 awong ugrad_ce 1024 Jan 19 19:39 tests Changing Permissions chmod [ugo]+[rxw] <filename> e.g. chmod u+w rgb.txt  gives me permission to change rgb.txt Changing Ownership chown <user>.<group> <filename> e.g. chmod awong.iuns rgb.txt  iuns group now owns rgb.txt Note: You cannot change which user owns file, unless you are an administrator, for security reasons.
  • 14. Permissions on directories Directories can also be thought of as a file that lists all the files it contains. They also belong to a user and a group They have the same 3 sets of permissions For directories, this is what the permissions mean Read -- You can read the list of files (eg. You can use “ls” and get the directory contents) Write -- You can change the list of files (eg. You can add or remove files from the directory) Executable -- You can use the directory list to let the operating system “find” the file. This means, you have access to the file. All directories generally have execute permission.
  • 15. Permissions Quiz Given the following output for ‘ ls –la ~ ’ for user awong.ugrad_ce attu4:/u15/awong$ ls –la ~ drwxr----x 1 awong ugrad_ce 1024 Jan 19 19:39 . drwxr-xr-x 1 root root 17375 Apr 26 2000 .. -rw-r--r-- 1 awong ugrad_ce 17375 Apr 5 02:57 readme.txt -rw-rwxr-x 1 awong ugrad_ce 17375 Apr 5 02:57 myprog For users ethel.ugrad_ce, jjlin@ugrad_cs, and awong.ugrad_ce: Who can create files in this directory? Who can get the list of files in this directory? Who can read the contents of the files readme.txt? How about myprog? Who can run the program “myprog”? What is dangerous about the permissions on myprog? Especially the ‘.’ directory had g+w access? Can you think of a reason why you would give someone execute, but not read permissions on a directory? How read but not execute?
  • 16. Shell Shortcuts Tab completion Type part of a file/directory name, hit <tab> , and the shell will finish as much of the name as it can Works if you’re running tcsh or bash Command history Don’t re-type previous commands – use the up-arrow to access them Wildcards Special character(s) which can be expanded to match other file/directory names * Zero or more characters ? Zero or one character Examples: ls *.txt rm may-?-notes.txt
  • 17. Editing Text Which text editor is “the best” is a holy war. Pick one and get comfortable with it. Three text editors you should be aware of: pico – Comes with pine ( Dante ’s email program) To quit: Ctrl-q emacs/xemacs – A heavily-featured editor commonly used in programming To quit: Ctrl-x Ctrl-c vim/vi – Another editor, also used in programming To quit: <Esc> : q <Enter> (or QQ -- capitals matter) Knowing the basics of emacs and vim will help with the rest of Unix; many programs have similar key sequences.
  • 18. Printing READ THE MORE UPDATED PRINTING TUTORIAL: http://www.cs.washington.edu/orgs/acm/tutorials/printing Printing: lpr : print Use –h (no header) and –Zduplex (double-sided) to save paper lpq : check the print queue (including Windows print jobs!) lprm : remove print jobs (including Windows print jobs) For the above commands, you will need to specify the printer with the option: –P<printer name> Check out enscript (quizlet: how do you find information about commands?) to print text files nicely! WARNING: Do NOT use enscript with postscript files!
  • 19. Programs and Compilation (C++) To compile a program: g++ <options> <source files> Recommended: g++ -Wall –ansi –o <executable_name> *.cpp -Wall – W arnings: ALL -ansi – Strict ANSI compliance Quizlet: what does *.cpp mean? What’s an “executable”? In Windows, double-clicking on an icon runs a program E.g. double-click on C:\Windows\notepad.exe In Unix, you can run your executable from the command line! Type the executable name at the prompt, just like a command In fact, commands are actually executables However, you may need to specify the path to your executables ./<program> runs <program> in the current directory Example: attu4:ehsu% g++ -Wall –ansi –o hello hello.cpp attu4:ehsu% ./ hello
  • 20. Programs and Compilation (Java) To compile a program: javac fileName1.java filename2.java . . . Errors will be printed to the screen with their line numbers Remember that the class name must have the same capitalization as the file name To compile all the .java files in the current folder: javac *.java To run : java classname (remember, no .java or .class) This will run the main method for that class.
  • 21. X-Windows X-Windows is the most common graphical interface for Unix It allows graphics to be sent over the network (Windows Remote Desktop is similar to this) If you login via the ssh-x shortcuts, you will start and “X-server” on your machine and you will be able to get graphics from your unix commands If you log into a linux box, you will automatically have X-windows setup in that login.
  • 22. Linux Machines, iuns Linux Machines: There are 6 linux machines in each lab The graphics work smoother on those machines Be sure to get a good “Window Manager” setup Ask one of the other people using the linux boxes for help setting up your window manager. Iuns: Iuns is the “instruction unsupported” software group Student volunteers maintain cutting edge software for unix and windows E-mail [email_address] for more info