Spreadfirefox Affiliate Button
Custom Search

Thursday, October 23, 2008

Creating, Moving, Renaming and Deleting Files and Directories

1. Creating new directories using “mkdir”
Pronounce the mkdir command as “make dir”

root@hardy:/home/bearisusanto/Documents# mkdir NEWDIR
root@hardy:/home/bearisusanto/Documents# ls
NEWDIR

If you try to create a directory with name has already been used, it will shows
root@hardy:/home/bearisusanto/Documents# mkdir NEWDIR
mkdir: cannot create directory `NEWDIR’: File exists

2. Copying files to new locations using “cp” and “mv”
Pronounce cp as “sea pea”, similarly, pronounce mv as “em vee”, but when you speak of moving a file, say “move”

Copy files “
root@hardy:/home/bearisusanto/Documents/NEWDIR# cp login login.copy
root@hardy:/home/bearisusanto/Documents/NEWDIR# ls -ld login login.copy
-rw-r–r– 1 root root 20 2008-07-29 11:43 login
-rw-r–r– 1 root root 20 2008-07-29 11:43 login.copy

Copy Folder
root@hardy:/home/bearisusanto/Documents# cp NEWDIR NEWDIR01
cp: omitting directory `NEWDIR’

Note : Generally, UNIX won’t permit to use the cp command to copy directories

Not as “cp” where leaves the original file intact, making sort of electronic equivalent of a photocopy of a paper, “mv” physically relocates them from the old directory to the new

root@hardy:/home/bearisusanto/Documents# mv login /home/bearisusanto/Documents/TEST
root@hardy:/home/bearisusanto/Documents# mv TEST01 /home/bearisusanto/Documents/TEST
root@hardy:/home/bearisusanto/Documents# cd TEST/
root@hardy:/home/bearisusanto/Documents/TEST# ls
login TEST01

3. Renaming files with mv
“mv” command, whic, in essence, moves the old name to the new name. It’s a bit confusing, but it works

root@hardy:/home/bearisusanto/Documents/TEST# ls
login TEST01
root@hardy:/home/bearisusanto/Documents/TEST# mv login test
root@hardy:/home/bearisusanto/Documents/TEST# ls
test TEST01
root@hardy:/home/bearisusanto/Documents/TEST#

4. Removing directories with rmdir

root@hardy:/home/bearisusanto/Documents/TEST# rmdir TEST01
root@hardy:/home/bearisusanto/Documents/TEST# ls
test

5. Removing Files Using rm

root@hardy:/home/bearisusanto/Documents/TEST# rm test
root@hardy:/home/bearisusanto/Documents/TEST# ls
root@hardy:/home/bearisusanto/Documents/TEST#

No comments: