0% found this document useful (0 votes)
35 views

Amit Saini Dics Technologies 6-8 P.M. (TTS)

This document provides an introduction to the UNIX operating system. It discusses key UNIX concepts like directories, files, commands for creating, deleting and moving directories and files. It also covers commands for listing, searching, copying, printing and redirecting input/output of files. The document is presented as a tutorial with explanatory text and lists of commands.

Uploaded by

aakash saini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Amit Saini Dics Technologies 6-8 P.M. (TTS)

This document provides an introduction to the UNIX operating system. It discusses key UNIX concepts like directories, files, commands for creating, deleting and moving directories and files. It also covers commands for listing, searching, copying, printing and redirecting input/output of files. The document is presented as a tutorial with explanatory text and lists of commands.

Uploaded by

aakash saini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

UNIX

AMIT SAINI
DICS TECHNOLOGIES
6-8 P.M.(TTS)

UNIX Intro.
CONTENTS

 WHAT IS UNIX?
 Making / Deleting / Renaming Directories
 Working with Files

UNIX Intro.
What Is UNIX?

 A computer operating system. It is designed


to be used by many people at the same time
(multi-user).
 Runs on a variety of processors
 Lends itself well to use in scientific
research

UNIX Intro.
1. Making / Deleting / Renaming
Directories

 Usually, you can only create directories (or


delete or rename them) in your home
directory or directories below it.

mkdir Make a directory


rmdir Delete a directory
mv Rename a directory

UNIX Intro.
 Create a lab directory in your home directory:
cd ~
mkdir lab

 Create two directories inside the lab directory:


cd lab
mkdir week1
mkdir week2

UNIX Intro.
 Delete the week1 directory:
rmdir week1

 Change the name of week2 to all-weeks


mv week2 all-weeks

UNIX Intro.
2. Working with Files

2.1. Creating a Text File


2.2. Listing Files
2.3. Filename Conventions
2.4. Other Basic Commands
2.5. Printing
2.6. I/O Redirection

UNIX Intro.
2.1. Creating a Text File
 A quick way:
cat > file

 This will feed the text you type at the keyboard


into file until you type ^D (CONTROL and a D
together).

 A more powerful way is to use vi, a full screen


editor (see later).

UNIX Intro.
2.2. Listing Files

 cat file List the file


cat hobby.c
cat /etc/passwd
cat /usr/dict/words (^C to stop)

 more file List the file a screen at


a time. Type spacebar
to go on; ^C to stop

UNIX Intro.
 less file Like more but more
powerful

 head file List the first few lines

 tail file List the last few lines

UNIX Intro. 1
2.3. Filename Conventions

 Many files have a name and an extension:


file.c A C program
file.cpp A C++ program
file.txt A text file

 However, you can call a file anything. It


doesn’t have to have an extension.

UNIX Intro. 1
2.4. Other Basic Commands

 cp file1 file2 Copy file1,


making file2

 mv file1 file2 Rename file1 as


file2

 rm file Delete file


rm -i file Double-check first
UNIX Intro. 1
 wc file Counts the lines,
words, characters
in file

 grep string file Search file for


string

UNIX Intro. 1
 List lines containing ‘Andrew’ in /etc/passwd
grep Andrew /etc/passwd

 Lines containing ‘printf(‘ in hobby.c


grep ‘printf(‘ hobby.c

 Lines starting with ‘loca’ in /usr/dict/words


grep ^loca /usr/dict/words

UNIX Intro. 1
2.5. Printing

 lpr file Print file

 lpq List the print queue.


Each print job has a
number.

 lprm job-number Remove that


print job
UNIX Intro. 1
 You may have to name the printer with
the -P option:
lpr -Plj5 hobby.c

 lpq and lprm understand the -P option

UNIX Intro. 1
2.6. I/O Redirection
 Most commands output to the screen
ls
 Output can be redirected to a file with‘>‘:
ls > dir.txt
cal 1997 > year1997

 Output can be appended to a file with ‘>>‘


cal 1997 > years
cal 1998 >> years

UNIX Intro. 1
 Concatenate two files:
cat f1 f2 > fs

 Input redirection (less common) uses ‘<‘


wc < years

 Combine input and output redirection:


wc < years > year-counts

UNIX Intro. 1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy