Unix Basics

33 %
67 %
Information about Unix Basics

Published on July 18, 2008

Author: Dr.Ravi

Source: slideshare.net

What is Unix? A multi-user networked operating system “Operating System” Handles files, running other programs, input/output Looks like DOS…but more powerful The internet was designed on it, thus 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!!! w00t! This tutorial provided by UW ACM http://www.cs.washington.edu/orgs/acm/ Questions to clbaker@cs, tanderl@cs, martine@cs, robh@cs, monnahan@cs

A multi-user networked operating system

“Operating System”

Handles files, running other programs, input/output

Looks like DOS…but more powerful

The internet was designed on it, thus 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!!! w00t!

Unix vs. Linux Age Unix: born in 1970 at AT&T/Bell Labs Linux: born in 1992 in Helsinki, Finland Sun, IBM, HP are the 3 largest vendors of Unix These Unix flavors all run on custom hardware Linux is FREE! (Speech vs. Beer) Linux was written for Intel/x86, but runs on many platforms

Age

Unix: born in 1970 at AT&T/Bell Labs

Linux: born in 1992 in Helsinki, Finland

Sun, IBM, HP are the 3 largest vendors of Unix

These Unix flavors all run on custom hardware

Linux is FREE! (Speech vs. Beer)

Linux was written for Intel/x86, but runs on many platforms

IWS (Instructional Work Servers) There are 4 instructional Linux servers: ceylon , fiji , sumatra , and tahiti Accessing the servers: Terminal Programs: ssh (via the TeraTerm or Putty programs) Start -> Program Files -> Desktop Tools -> TeraTerm File Transfer Programs On CSE lab Windows machines Start -> Run lt;server name><username> e.g -- iji obh Secure FTP (from C&C) The X Window System Ask monnahan@cs how to do it

There are 4 instructional Linux servers:

ceylon , fiji , sumatra , and tahiti

Accessing the servers:

Terminal Programs:

ssh (via the TeraTerm or Putty programs)

Start -> Program Files -> Desktop Tools -> TeraTerm

File Transfer Programs

On CSE lab Windows machines

Start -> Run

lt;server name><username>

e.g -- iji obh

Secure FTP (from C&C)

The X Window System

Ask monnahan@cs how to do it

Logging In All four island servers allow you to access to your files Better performance on the right one Although your Windows and Unix usernames are the same, they have separate accounts (different passwords) 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)

All four island servers allow you to access to your files

Better performance on the right one

Although your Windows and Unix usernames are the same, they have separate accounts (different passwords)

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> fiji:~$ ls –l -a unix-tutorial Command Prompt Command (Optional) flags (Optional) arguments Note : Many Unix commands will print a message only if something went wrong. Be careful with rm and mv.

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

Getting help with man man (short for “manual”) documents commands man <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:~$ man –k password passwd (5) - password file xlock (1) - Locks the local X display until a password is entered fiji:~$ passwd

man (short for “manual”) documents commands

man <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

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: /homes/iws/robh/classes/cse326 The hierarchical structure of directories (the directory tree) begins at a special directory called the root , or / Absolute paths start at / Example: /homes/iws/robh/classes/cse326 Relative paths start in the current directory Example: classes/cse326 (if you’re currently in /homes/iws/robh ) Your home directory “~” is where your personal files are located, and where you start when you log in. Example: /homes/iws/robh

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: /homes/iws/robh/classes/cse326

The hierarchical structure of directories (the directory tree) begins at a special directory called the root , or /

Absolute paths start at /

Example: /homes/iws/robh/classes/cse326

Relative paths start in the current directory

Example: classes/cse326 (if you’re currently in /homes/iws/robh )

Your home directory “~” is where your personal files are located, and where you start when you log in.

Example: /homes/iws/robh

Directories (cont’d) Handy directories to know ~ Your home directory .. The parent directory . The current directory ls L i S ts the contents of a specified files or directories (or the current directory if no files are specified) Syntax: ls [<args> … ] Example: ls backups/ pwd P rint W orking D irectory

Handy directories to know

~ Your home directory

.. The parent directory

. The current directory

ls

L i S ts the contents of a specified files or directories (or the current directory if no files are specified)

Syntax: ls [<args> … ]

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 first Syntax: rmdir <directories> Example: rmdir backups class-notes

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 first

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 use only 2 letters rm R e M oves a file, without a possibility of “undelete!” Syntax: rm <file(s)> Example: rm tutorial.txt backups/old.txt

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 use only 2 letters

rm

R e M oves a file, without a possibility of “undelete!”

Syntax: rm <file(s)>

Example: rm tutorial.txt backups/old.txt

Files (cont’d) cp C o P ies a file, preserving the original Syntax: cp <sources> <destination> Example: cp tutorial.txt tutorial.txt.bak mv M o V es or renames a file, destroying the original Syntax: mv <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!

cp

C o P ies a file, preserving the original

Syntax: cp <sources> <destination>

Example: cp tutorial.txt tutorial.txt.bak

mv

M o V es or renames a file, destroying the original

Syntax: mv <sources> <destination>

Examples:

mv tutorial.txt tutorial.txt.bak

mv tutorial.txt tutorial-slides.ppt backups/

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

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 – Easy! Comes with pine ( Dante ’s email program) emacs/xemacs – A heavily-featured editor commonly used in programming vim/vi – A lighter editor, also used in programming Your opinion is wrong.

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 – Easy! Comes with pine ( Dante ’s email program)

emacs/xemacs – A heavily-featured editor commonly used in programming

vim/vi – A lighter editor, also used in programming

Your opinion is wrong.

Programs and Compilation To compile a program: g++ <options> <source files> Recommended: g++ -Wall –ansi –o <executable_name> *.cpp -Wall – show all warnings -ansi – Strict ANSI compliance What’s an “executable”? In Windows, double-clicking on an icon runs a program E.g. double-click on C:Windows otepad.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: ceylon:ehsu% g++ -Wall –ansi –o hello hello.cpp ceylon:ehsu% ./ hello

To compile a program:

g++ <options> <source files>

Recommended: g++ -Wall –ansi –o <executable_name> *.cpp

-Wall – show all warnings

-ansi – Strict ANSI compliance

What’s an “executable”?

In Windows, double-clicking on an icon runs a program

E.g. double-click on C:Windows otepad.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:

ceylon:ehsu% g++ -Wall –ansi –o hello hello.cpp

ceylon:ehsu% ./ hello

Next time…. Wildcards Environment Variables Process Management I/O redirection Permissions

Wildcards

Environment Variables

Process Management

I/O redirection

Permissions

Add a comment

Related presentations

Related pages

UNIX / Linux Tutorial for Beginners - Electrical and ...

Beginners guide to the UNIX / Linux operating system. Eight simple tutorials which cover the basics of UNIX.
Read more

Unix basics - Indiana University Knowledge Base

System information. In Unix, how can I display information about the operating system? Where can I find information about Unix workstation security?
Read more

Chapter 3. UNIX Basics - The FreeBSD Project

This chapter covers the basic commands and functionality of the FreeBSD operating system. Much of this material is relevant for any UNIX ®-like ...
Read more

Learn UNIX in 10 minutes - FreeEngineer home page

Learn UNIX in 10 minutes. ... in years past. The purpose was to have on one page the basics commands for getting started using the UNIX shell ...
Read more

Basic UNIX commands - Stanford University

Basic UNIX commands Note: not all of these are actually part of UNIX itself, and you may not find them on all UNIX machines. But they can all be used on ...
Read more

UNIX Tutorial - Tutorials for Foundation, Django, Apache ...

Unix Operating System (OS) Tutorial - Learning fundamentals of UNIX in simple and easy steps : A beginner's tutorial containing complete knowledge of Unix ...
Read more

Some Basic UNIX Commands - Thomas Jefferson High School ...

Some Basic UNIX Commands by Donald Hyatt The UNIX operating system has for many years formed the backbone of the Internet, especially for large servers and ...
Read more

UNIX Tutorial - Introduction - Electrical and Electronic ...

UNIX Introduction What is UNIX? UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since.
Read more

Unix Tutorial - Tutorials for Foundation, Django, Apache ...

Unix Tutorial UNIX is a computer Operating System which is capable of handling activities from multiple users at the same time. ... Unix - Basic Operators T
Read more

Unix Basics | LinkedIn

View 653 Unix Basics posts, presentations, experts, and more. Get the professional knowledge you need on LinkedIn.
Read more