UNIX Essentials Module 4
UNIX Essentials Module 4
UNIX Essentials Module 4
Solaris 10
Module 4
Module 4
Module 4
Example :
To copy the le named file3 to a new le named feathers, within the user1
directory, perform the cp command.
$ cd
$ pwd /export/home/user1
$ ls
dante
file4
dir2
dir5
practice dir1
$ cp file3 feathers
$ ls
dante
dante_1 dir3
dir1
dir2
dir4
dir5
file.3
dir4
file3
fruit2 dante_1 dir3
file.1
file.2 file2 fruit tutor.vi
file.2
file2
feathers file.3
file.1
file1
fruit
file3
file4
file1
tutor.vi
fruit2
practice
Module 4
Module 4
Example
To copy the feathers le and the feathers_6 le from the user1 directory into
the dir1 subdirectory, perform the cp command.
$ pwd
/export/home/user1
$ ls dir1
coffees fruit
$ ls dir1
trees
Module 4
To prevent
Copying Directories
You
Module 4
Module 4
$ pwd
/export/home/user1
$ mv dante dantenew
$ ls
dantenew dir10 dir4 feathers_6 file.3 file.3 fruit dante
dante_1 dir2 dir5 file.1 file1 fruit2 practice
dir1 dir3 feathers file.2 file2 file4 tutor.vi
Module 4
The
Module 4
To move
$ cd ~/dir1/coffees
$ pwd
/export/home/user1/dir1/coffees
$ ls
beans brands nuts $ mv brands ~
$ ls
beans nuts
$ cd
$ pwd
/export/home/user1
$ ls -l brands
-rw-r--r-- 1 user1 staff
Module 4
You can use the mv command to move a directory and its contents to a different
directory.
$ cd
$ pwd
/export/home/user1
$ ls practice
mailbox
project2 projection research results
$ mv practice letters
$ ls letters
mailbox
project2 projection research results
Module 4
Renaming a Directory
You
dir5new
feathers
feathers_6
file.1
file.2
file3
letters
file.3
file4
tutor.vi
file1
fruit
file2
fruit2
$ mv dir5new dir5
$ ls
brands dir2 dir10 file.2 file3 letters
dante dir3 feathers file.3 file4 tutor.vi
dante_1
dir4 feathers_6 file1 fruit
dir1 dir5 file.1 file2 fruit2
Module 4
Module 4
To create an empty le named space in the dir3 directory, perform the touch
command.
$ pwd
/export/home/user1
$ cd dir3
$ ls
planets
$ touch space
$ ls
planets space
Module 4
Creating Directories
You
To create
Module 4
Module 4
Removing Files
You
The
Module 4
To remove the le named projection from the letters directory, perform the
rm command.
$ cd ~/letters
$ ls
mailbox project2 projection research
$ rm projection
$ ls
mailbox project2 research results
results
To remove the research le and the project2 le from the letters directory,
perform the rm command.
$ pwd
/export/home/user1/letters
$ls
mailbox project2 research results
$ rm research project2
$ ls
mailbox results
Module 4
The -i option prompts you for conrmation before removing any le:
$ rm -i *
rm: remove file1:
rm: remove file2:
rm: remove file3:
rm: remove file4:
(yes/no)
(yes/no)
(yes/no)
(yes/no)
?Y
?Y
?Y
?Y
$ ls
Module 4
Removing Directories
There
To remove
Module 4
If a directory is not empty, the rmdir command displays the following error
message:
Module 4
The
rm
- options directories
If
rm:
directoryname : is a directory.
Module 4
Description
-r
-I
There are two main reasons you might choose to use symbolic links:
Module 4
Module 4
ln s source_file target_file
To create a symbolic link le, named dante_link, to thedante le, perform the
ln -s command.
$ cd
$ pwd
/export/home/user1
$mv dante /var/tmp
$ ln -s /var/tmp/dante dante_link
$ ls F
Reports/ dante_link@ dir3/
feathers_6 file1 fruit
brands dir1/
dir4/
file.1
file2 fruit2
dir10/ dir5/
file.2
file3
newdir/
dante_1 dir2/ feathers file.3
file4 tutor.vi
$cat dante_link
The Life and Times of Dante
By Dante Pocai
Mention Alighieri and few may know about whom you are talking. Say
Dante, instead, and the whole world knows whom you mean. For Dante Alighieri,
like Raphael, Michelangelo, Galileo, etc. is usually referred to by his first name. ...
(output truncated)
Module 4
You can use the rm command to remove a symbolic link le in the same
manner as you would remove a standard le.
$ cd
$ pwd
/export/home/user1
$ ls -l dante_link
lrwxrwxrwx 1 user1 staff
5 Nov 19 14:45 dante_link -> dante
$ rm dante_link
$cat dante
No such file or directory
$ ls dante dante_link
-rw-r--r-- 1 user1 staff
5 Nov 19 14:45 dante
dante_link: No such file or directory
$ mv /var/tmp/dante ~/dante
Module 4