We have seen the differences between files under DOS and Linux. As for directories, under DOS the root directory is \, under Linux / is. Similarly, nested directories are separated by \ under DOS, by / under Linux. Example of file paths:
DOS: C:\PAPERS\GEOLOGY\MID_EOC.TEX
Linux: /home/guido/papers/geology/mid_eocene.tex
As usual, ..
is the parent directory, .
is the current directory.
Remember that the system won't let you cd
, rd
, or md
everywhere you want. Each user starts from his or her own directory called
'home', given by the system administrator; for instance, on my PC my home
dir is /home/guido
.
Directories, too, have permissions. What we have seen in Section
Permissions
holds for directories as well (user, group, and other). For a directory,
rx
means you can cd
to that directory, and w
means that you
can delete a file in the directory (according to the file's permissions,
of course), or the directory itself.
For example, to prevent other users from snooping in
/home/guido/text
:
$ chmod o-rwx /home/guido/text
DIR: ls, find, du
CD: cd, pwd
MD: mkdir
RD: rmdir
DELTREE: rm -R
MOVE: mv
- EXAMPLES -
DOS Linux
---------------------------------------------------------------------
C:\GUIDO>dir $ ls
C:\GUIDO>dir file.txt $ ls file.txt
C:\GUIDO>dir *.h *.c $ ls *.h *.c
C:\GUIDO>dir/p $ ls | more
C:\GUIDO>dir/a $ ls -l
C:\GUIDO>dir *.tmp /s $ find / -name "*.tmp"
C:\GUIDO>cd $ pwd
n/a - see note $ cd
ditto $ cd ~
ditto $ cd ~/temp
C:\GUIDO>cd \other $ cd /other
C:\GUIDO>cd ..\temp\trash $ cd ../temp/trash
C:\GUIDO>md newprogs $ mkdir newprogs
C:\GUIDO>move prog .. $ mv prog ..
C:\GUIDO>md \progs\turbo $ mkdir /progs/turbo
C:\GUIDO>deltree temp\trash $ rm -R temp/trash
C:\GUIDO>rd newprogs $ rmdir newprogs
C:\GUIDO>rd \progs\turbo $ rmdir /progs/turbo
Notes:
rmdir
, the directory to remove must be empty.
To delete a directory and all of its contents, use rm -R
(at your own
risk).
~
' is a shortcut for the name of your home
directory. The commands cd
or cd ~
will take you to your home
directory from wherever you are; the command cd ~/tmp
will take
you to /home/your_home/tmp
.
cd -
``undoes'' the last cd
.