[SOLVED] file system Basic Unix Operations on Files and Directories

$25

File Name: file_system_Basic_Unix_Operations_on_Files_and_Directories.zip
File Size: 546.36 KB

5/5 - (1 vote)

Basic Unix Operations on Files and Directories

Basic Unix Operations on Files and Directories

Prof. Susan Older

17 January 2017

(CIS 252) Unix Basics 17 January 2017 1 / 7

Unix Beginnings (1969 at Bell Labs)

Design philosophy:

View everything as a file (but with different types).

Incorporate lots of small commands that can be combined easily to
accomplish more complex tasks.

Employ a hierarchical file system, which forms a tree structure:

/

bin/ usr/ Users/

make bin/ lib/ joule/ sueo/

plans/ toys treats

training.pdf walks.txt

zip zsh/

Note: / is called the root directory.

(CIS 252) Unix Basics 17 January 2017 2 / 7

Current Working Directory and Pathnames

When you log in (or start a Terminal window), your current working
directory is your home directory:

/Users/joule is my dog Joules home directory.

~ is abbreviation for ones home directory.

. is abbreviation for the current working directory.

.. is abbreviation for directory directly above current directory.

Absolute pathnames start from the root directory:
/Users/joule/plans/training.pdf or /bin/make or /usr

Relative pathnames start relative to current working directory.
If current working directory is /Users/joule, then:

plans/walks.txt refers to /Users/joule/plans/walks.txt

../sueo refers to /Users/sueo, ../../bin refers to /bin

(CIS 252) Unix Basics 17 January 2017 3 / 7

Viewing Files and Directories

ls

List the contents of current directory, but dont show hidden files
(i.e., files whose names start with a dot/period (.) )

ls pathname

List the contents of the directory at pathname

Additional options:

ls -a

List all files, including hidden files

ls -l

Generate a long listing, which includes information about permissions,
file size, etc.

Options can be combined, such as:

ls -al ~/class stuff

(CIS 252) Unix Basics 17 January 2017 4 / 7

Moving Around the System

cd

Make your home directory (~) the current working directory

cd pathname

Make pathname the current working directory

pwd

Print the name of the current working directory

To find out more about specific commands:

man command
Get a manual page on command

(CIS 252) Unix Basics 17 January 2017 5 / 7

Working with Files

Basic commands:
cp source target

Make a copy of file source and name the copy target

mv source target

Move (or rename) the file source to target

rm source

Remove the file source

Generalizations:
cp source1 . . . sourcek targetDirectory

Make a copy of each of the files sourcei and place them in the
directory targetDirectory

mv source1 . . . sourcek targetDirectory
Move each of the files sourcei and place them in the directory
targetDirectory

(CIS 252) Unix Basics 17 January 2017 6 / 7

Some More Commands

Working with directories:

mkdir target

Make a new directory called target

rmdir target

Remove the directory target

Working with text:
more name

Page through text file name, one screenful at a time

less name

A more versatile (and more efficient) version of more

file name

Find out what type of file name is

(CIS 252) Unix Basics 17 January 2017 7 / 7

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] file system Basic Unix Operations on Files and Directories
$25