Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
All of the files in the UNIX file system are organized into a multi-
leveled hierarchy called a directory tree.
A family tree is an example of a hierarchical structure that
represents how the UNIX file system is organized. The UNIX file
system might also be envisioned as an inverted tree or the root
system of plant.
At the very top of the file system is single directory called "root"
which is represented by a / (slash). All other files are
"descendants" of root.
The number of levels is largely arbitrary, although most UNIX
systems share some organizational similarities.
UNIX File System : Example
/ (root)
|
---------------------
| | |
/bin /usr /tmp
|
|
------------------------------------------------------------
| | | |
/public /misc /staff /students
| | |
------------ ------------------- ----------------------
| | | | | | | | | |
/software /doc /john /mary /bill /carl /tom /dick /mary /lisa
File
mkdir /u/training/data
mkdir data2
mkdir -m 444 tech (Sets the access mode for the new
directory.)
mkdir -p tech/net/faqs (If the parent directories don't exist,
this command creates them.)
Reasons for faiilure of mkdir command:
Directory already exists
Fiile with same name already exists
Permissions for current directory does not allow creation
of directory.
Ls Commands
$ ls -a
. .bashrc .gconfd .nautilus
List Directories with ‘/’ Character at the end
$ ls -F
Desktop/ Downloads/ Pictures/
Recursively list Sub-Directories
ls -R option will list very long listing directory trees.
Ls Commands
$ls -R
total 1384
-rw-------. 1 root root 33408 Aug 8 17:25 anaconda.log
-rw-------. 1 root root 30508 Aug 8 17:25
anaconda.program.log
./httpd:
total 132
-rw-r--r-- 1 root root 0 Aug 19 03:14 access_log
-rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-
20120812
./lighttpd:
total 68
-rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26 access.log
-rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-
20120819
Ls Commands
mv f1 f3
FileName Inode FileName Inode
Number Number
. 6557 rm f3 . 6557
.. 7755 .. 7755
F2 54578 F3 3536
F2 54578
more
more - browses/displays files one screen at a time.
Use f/spacebar to page
b for back, q to quit
10f to scroll 10 pages.
Dot to repeat the last command
/string to search for string
more sample.f
less is the standard pager of Linux and it behaves same as
more.
lp
The lp command is used to print files on Unix and Linux
systems. The name "lp" stands for "line printer“
# lp -m -n 30 -d lp0:lpd0 /etc/motd : Prints 30 copies
using printer lpd0 and notifies user using mail.
# lp -t “Title" /etc/motd : Pints file with title.
wc
The wc (word count) command is used to find out number
of newline count, word count and characters count in a
files specified by the file arguments.
wc tecmint.txt
12 16 112 tecmint.txt
Here 12 is number of lines, 16 words and 112 characters
Option –l, -w, -c.
diff
diff command to display line-by-line difference between
two files.
diff FILE1 FILE2
Diff command will examine file1 and file2 and tells what
changes need to be made for file1 and file2 to match.
diff command point to which lines need be:
Added (a)
Deleted (d)
Changed (c)
lines in file1 identified with a less than (<) symbol and
lines in file2 with a greater than (>) symbol.
comm
Compare two sorted files line-by-line.
comm produces three-column output. Column one
contains lines unique to FILE1, column two contains lines
unique to FILE2, and column three contains lines
common to both files.
comm File1 File2
cmp
cmp - Compare two files byte by byte