blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

File System part III

In windows we have a concept of partitions named like C, D, etc. But in linux we have concept of device files (which are special files).
In ubuntu one can use the Disk Utility program to view the devices and their mount point's if it's mounted. A device or drive is mounted on to the existing file system which is mounted at /.
If you are using a terminal type
cat /etc/fstab
to see all the mountable devices, including floppy disks and CD players.
Type
df
to see the devices currently mounted, and their free space.

Notes:
In Unix '.' means the directory and '..' means the parent directory. Actually these are pointers to the same directory and to it's parent directory.
And since these are pointers we could use them along with commands.
Eg:
ls .
cd ..


Current working directory and home directory
Unix associates a current working directory with each process. It identifies the directory currently used by the process as it's current working directory.

Processes uses a pathname to identify a file and the pathname consists of slashes alternating with a sequence of directory names that lead to the file.

If the first item in the pathname is a slash, the pathname is said to be absolute, because its starting point is the root directory. Otherwise, if the first item is a directory name or filename, the pathname is said to be relative, because its starting point is the process's current directory.

When we first log in to our system (or start a terminal emulator session) our current
working directory is set to our home directory. Each user account is given its own home
directory and when operating as a regular user, the home directory is the only place the
user is allowed to write files.

When you are in/under your home directory the unix prompt will start with ~
eipe@eipe-system:~$


after you cd Downloads
eipe@eipe-system:~/Downloads$


When you are in the root directory
eipe@eipe-system:/$


If you are the root user (super user) then $ will be replaced by #
eipe@eipe-system:/#


Common commands for directory navigation:

pwd: will print the current working directory.
eipe@eipe-system:~$ pwd
/home/eipe


ls: to list out the files in the current directory.
Common options used with ls are
ls -a :to display all the hidden files (names begin with . And also the pointers '.' and '..')
eipe@eipe-system:~/Documents$ ls -a
. Argument.docx cpparchive.cpp java Network.png
.. carchive.c Essays.docx linux

ls -l : Results in long format.
eipe@eipe-system:~/Documents$ ls -l
total 2008
-rw------- 1 eipe eipe 10918 2009-01-12 21:13 Argument.docx
-rw------- 1 eipe eipe 37277 2010-02-13 16:05 carchive.c
-rw------- 1 eipe eipe 53817 2010-06-11 01:24 cpparchive.cpp
-rw------- 1 eipe eipe 17540 2008-12-13 11:43 Essays.docx
drwxr-xr-x 5 eipe eipe 4096 2010-11-29 11:08 java
drwxr-xr-x 2 eipe eipe 4096 2010-12-02 22:52 linux
-rw-r--r-- 1 eipe eipe 1821268 2010-10-04 14:14 Network.png
-rw-r--r-- 1 eipe eipe 91615 2010-10-04 14:09 network-protocols-map-poster-1.gif


Description of columns:
First line shows the total size of the directory in this case 2008 bytes.
Col 1 : files access permissions.
Col 2 : depends (see below)
Col 3 : user name of the file's owner.
Col 4 : file's group owner name.
Col 5 : size of the file in bytes.
Col 6 : date and time of files last modification date.
Col 7 : name of file (color coding used to display the file is user dependent also system dependent ie., it changes with respect to any specific user's settings or for different distributions.)

Note:
Col(1) prints the
file type (1 char)
permissions for owner (3 chars)
permissions for group (3 chars)
permissions for world (3 chars)
Col(2) prints the
no: of subdirectories if that item is a directory. If the directory is empty it will print 2 by default.
If it's a normal file it prints 1 by default. If it's a hard link then the number of hard links.

ls -l -h : to print sizes in human-readable format
eipe@eipe-system:~/Documents$ ls -l -h
total 2.0M
-rw------- 1 eipe eipe 11K 2009-01-12 21:13 Argument.docx
-rw------- 1 eipe eipe 37K 2010-02-13 16:05 carchive.c
-rw------- 1 eipe eipe 53K 2010-06-11 01:24 cpparchive.cpp
-rw------- 1 eipe eipe 18K 2008-12-13 11:43 Essays.docx
drwxr-xr-x 5 eipe eipe 4.0K 2010-11-29 11:08 java
drwxr-xr-x 2 eipe eipe 4.0K 2010-12-02 22:52 linux
-rw-r--r-- 1 eipe eipe 1.8M 2010-10-04 14:14 Network.png
-rw-r--r-- 1 eipe eipe 90K 2010-10-04 14:09 network-protocols.gif

No comments:

Post a Comment