/dev/rp00 and /dev/rp01 are named after the DEC RP06 disc drive attached to the system. We cannot make a link to a file in another subsystem. One reason is that the inode numbers are not unique in different file systems.
$ df
$ tty
$ mesg n
$ mesg y
The 'df' command tells the available space in the mounted file subsystem. The 'tty' command tells which terminal we are using. So we can send files and informations to that terminal and it appears in the corresponding terminal. 'mesg n' turn off the messages. /dev/tty is a synonym for our terminal.
If we want to run a program and its output files are not importent we can redirect it to '/dev/null' causes its output to be thrown away.
Thursday, September 2, 2010
Wednesday, September 1, 2010
Unix file system : The directory hierarchy
When the system starts the file /boot is read, it then reads /unix (it is the program for the UNIX kernal itself).
The following shows some directories which reside in root and its contents.
/bin : basic programs like who,ed reside.
/etc/rc : This is a file of shell commands which is executed after the system is bootstrapped.
/etc/group : lists the members of each group.
/lib : Contains the parts of the C compiler.
/tmp : Contains temporary (short-lived) files that are created in the execution of programs.
The following shows some directories which reside in root and its contents.
/bin : basic programs like who,ed reside.
/etc/rc : This is a file of shell commands which is executed after the system is bootstrapped.
/etc/group : lists the members of each group.
/lib : Contains the parts of the C compiler.
/tmp : Contains temporary (short-lived) files that are created in the execution of programs.
Unix file system : Inodes
The administrative infomation is stored in the inode. It contains information such as how long it is, where the contents of the file are stored on disc etc.
System's internal name for a file is its i-number.
$ ls -lut
$ ls -lct
$ ls -i
$ ls -ict
'rm' command is for removing a file. 'mv' command is for moving and renaming the files.
$ rm filename1 filename2
$ mv filename1 filename2
The -ut lists the file in order of usage time. -ct lists the files in the order of inode change time. The '-i' option is for listing the i-numbers of the directories contents. '-ict' lists inode number in order of the modifications in the inode (most recently first).
System's internal name for a file is its i-number.
$ ls -lut
$ ls -lct
$ ls -i
$ ls -ict
'rm' command is for removing a file. 'mv' command is for moving and renaming the files.
$ rm filename1 filename2
$ mv filename1 filename2
The -ut lists the file in order of usage time. -ct lists the files in the order of inode change time. The '-i' option is for listing the i-numbers of the directories contents. '-ict' lists inode number in order of the modifications in the inode (most recently first).
Unix file system : Permissions
The file /etc/passwd is the password file. It contains all the login information about each user. We can discover each users id and group id by looking name in /etc/passwd.
$grep name /etc/passwd
The fields in the password file looks like 'login-id:encrypted password:uid:group-id:miscellany:login-directory:shell'. The -l option of ls command prints the permissions.
$ls -l
We can find a string like '-rw-r--r--' . The first - means that it is an ordinary file. If it is a directory there prints a 'd'. The next three field is the permissions of the owner followed by the next three field is the permissions of the group and the next is the others permissions. We cannot edit the passwd file . But the super user can do it.
The 'chmod' command changes the permissions of a file. 'permissions' may occupy octal numbers. The '+' sign is for 'ON' permission modes and to OFF the '-' sign is using. The '-w' option is for turn off the write permisssion for all incliding the owner. '+x' allows every one to execute the following command.
$ chmod permissions filename
$ chmod -w filename
$ chmod +x command
$ chmod -w .
$ chmod 775 filename //Restores the permission.
The '-w .' means removing the write permission of all files in that directory.
$grep name /etc/passwd
The fields in the password file looks like 'login-id:encrypted password:uid:group-id:miscellany:login-directory:shell'. The -l option of ls command prints the permissions.
$ls -l
We can find a string like '-rw-r--r--' . The first - means that it is an ordinary file. If it is a directory there prints a 'd'. The next three field is the permissions of the owner followed by the next three field is the permissions of the group and the next is the others permissions. We cannot edit the passwd file . But the super user can do it.
The 'chmod' command changes the permissions of a file. 'permissions' may occupy octal numbers. The '+' sign is for 'ON' permission modes and to OFF the '-' sign is using. The '-w' option is for turn off the write permisssion for all incliding the owner. '+x' allows every one to execute the following command.
$ chmod permissions filename
$ chmod -w filename
$ chmod +x command
$ chmod -w .
$ chmod 775 filename //Restores the permission.
The '-w .' means removing the write permission of all files in that directory.
Sunday, August 29, 2010
Programming in Python : Dictionaries
Dictionaries are another data type in python. It can be think as a unordered collection of keys associated with values. The keys can be numbers, strings, or tuples. An empty dictionary is denoted by '{ }'. We can view all keys by simply calling keys(). The dict() constructor is using to build a dictionary.
>>> dic = {'one':1,'two':2,'three':3,'four':4,'five':5}
>>> dic
{'four': 4, 'three': 3, 'five': 5, 'two': 2, 'one': 1}
>>> dic['six'] = 6
>>> dic
{'six': 6, 'three': 3, 'two': 2, 'four': 4, 'five': 5, 'one': 1}
>>> del dic['five']
>>> dic
{'six': 6, 'three': 3, 'two': 2, 'four': 4, 'one': 1}
>>> dic['seven'] = 7
>>> dic
{'seven': 7, 'six': 6, 'three': 3, 'two': 2, 'four': 4, 'one': 1}
>>> dic.key()
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'dict' object has no attribute 'key'
>>> dic.keys()
['seven', 'six', 'three', 'two', 'four', 'one']
>>> dic['seven']
7
>>> dic['one']
1
>>> 'one' in dic
True
>>> 'three' in dic
True
>>> 'kjkk' in dic
False
>>> del dic['one']
>>> dic
{'seven': 7, 'six': 6, 'three': 3, 'two': 2, 'four': 4}
>>> dic.keys()
['seven', 'six', 'three', 'two', 'four']
>>> dic.values()
[7, 6, 3, 2, 4]
>>> a=[('aass',23),('iiii',56),('dftj',38)]
>>> a
[('aass', 23), ('iiii', 56), ('dftj', 38)]
>>> dict(a)
{'aass': 23, 'iiii': 56, 'dftj': 38}
>>> b = dict(a)
>>> b
{'aass': 23, 'iiii': 56, 'dftj': 38}
>>> dict(jhjkhk = 433,jkhjkhk = 3434,iuijmkm = 344343)
{'jkhjkhk': 3434, 'jhjkhk': 433, 'iuijmkm': 344343}
>>> c = dict(jhjkhk = 433,jkhjkhk = 3434,iuijmkm = 344343)
>>> c
{'jkhjkhk': 3434, 'jhjkhk': 433, 'iuijmkm': 344343}
>>> dic = {'one':1,'two':2,'three':3,'four':4,'five':5}
>>> dic
{'four': 4, 'three': 3, 'five': 5, 'two': 2, 'one': 1}
>>> dic['six'] = 6
>>> dic
{'six': 6, 'three': 3, 'two': 2, 'four': 4, 'five': 5, 'one': 1}
>>> del dic['five']
>>> dic
{'six': 6, 'three': 3, 'two': 2, 'four': 4, 'one': 1}
>>> dic['seven'] = 7
>>> dic
{'seven': 7, 'six': 6, 'three': 3, 'two': 2, 'four': 4, 'one': 1}
>>> dic.key()
Traceback (most recent call last):
File "
AttributeError: 'dict' object has no attribute 'key'
>>> dic.keys()
['seven', 'six', 'three', 'two', 'four', 'one']
>>> dic['seven']
7
>>> dic['one']
1
>>> 'one' in dic
True
>>> 'three' in dic
True
>>> 'kjkk' in dic
False
>>> del dic['one']
>>> dic
{'seven': 7, 'six': 6, 'three': 3, 'two': 2, 'four': 4}
>>> dic.keys()
['seven', 'six', 'three', 'two', 'four']
>>> dic.values()
[7, 6, 3, 2, 4]
>>> a=[('aass',23),('iiii',56),('dftj',38)]
>>> a
[('aass', 23), ('iiii', 56), ('dftj', 38)]
>>> dict(a)
{'aass': 23, 'iiii': 56, 'dftj': 38}
>>> b = dict(a)
>>> b
{'aass': 23, 'iiii': 56, 'dftj': 38}
>>> dict(jhjkhk = 433,jkhjkhk = 3434,iuijmkm = 344343)
{'jkhjkhk': 3434, 'jhjkhk': 433, 'iuijmkm': 344343}
>>> c = dict(jhjkhk = 433,jkhjkhk = 3434,iuijmkm = 344343)
>>> c
{'jkhjkhk': 3434, 'jhjkhk': 433, 'iuijmkm': 344343}
Programming in Python : Sets
Set is a data type in python. It is an unordered set of elements without duplicates. We can test an element is a member of the set. Set operations can operate on unique letters as given below.
>>> list1 = ['apple','mango','pineapple','mango','apple','orange']
>>> fruit = set(list1)
>>> fruit
set(['orange','mango','apple','pineapple'])
>>> 'mango' in fruit
True
>>> 'grape' in fruit
False
>>> a = ('abhilash')
>>> a
'abhilash'
>>> b = ('abhijith')
>>> b
'abhijith'
>>> set(a)
set(['a', 'b', 'i', 'h', 'l', 's'])
>>> set(b)
set(['a', 'b', 'i', 'h', 'j', 't'])
>>> c = set(a)
>>> d = set(b)
>>> c
set(['a', 'b', 'i', 'h', 'l', 's'])
>>> d
set(['a', 'b', 'i', 'h', 'j', 't'])
>>> c-d
set(['s', 'l'])
>>> d-c
set(['j', 't'])
>>> c |d
set(['a', 'b', 'i', 'h', 'j', 'l', 's', 't'])
>>> c & d
set(['a', 'i', 'b', 'h'])
>>> c ^ d
set(['s', 't', 'j', 'l'])
>>> list1 = ['apple','mango','pineapple','mango','apple','orange']
>>> fruit = set(list1)
>>> fruit
set(['orange','mango','apple','pineapple'])
>>> 'mango' in fruit
True
>>> 'grape' in fruit
False
>>> a = ('abhilash')
>>> a
'abhilash'
>>> b = ('abhijith')
>>> b
'abhijith'
>>> set(a)
set(['a', 'b', 'i', 'h', 'l', 's'])
>>> set(b)
set(['a', 'b', 'i', 'h', 'j', 't'])
>>> c = set(a)
>>> d = set(b)
>>> c
set(['a', 'b', 'i', 'h', 'l', 's'])
>>> d
set(['a', 'b', 'i', 'h', 'j', 't'])
>>> c-d
set(['s', 'l'])
>>> d-c
set(['j', 't'])
>>> c |d
set(['a', 'b', 'i', 'h', 'j', 'l', 's', 't'])
>>> c & d
set(['a', 'i', 'b', 'h'])
>>> c ^ d
set(['s', 't', 'j', 'l'])
Programming in python: Tuples and sequences
Tuples consists of elements that are enclosed in parenthesis. The empty tuples is represented by '()'. The single element tuple is ending with a comma.
>>> t = ('one','two','three')
>>> t
('one','two','three')
>>> e = ()
>>> e
()
>>> len(e)
0
>>> single = ('one',)
>>> single
('one',)
>>> len(single)
1
The statement t = 1223,5676,'one','two' is an example of tuple packing. The elements are packed together in a tuple. The sequence unpacking is also possible. ex: a,b,c,d = t
>>> t = 1223,5676,'one','two'
>>> t
(1223,5676,'one','two')
>>> a,b,c,d = t
>>> a
1223
>>> d
'two'
>>> t = ('one','two','three')
>>> t
('one','two','three')
>>> e = ()
>>> e
()
>>> len(e)
0
>>> single = ('one',)
>>> single
('one',)
>>> len(single)
1
The statement t = 1223,5676,'one','two' is an example of tuple packing. The elements are packed together in a tuple. The sequence unpacking is also possible. ex: a,b,c,d = t
>>> t = 1223,5676,'one','two'
>>> t
(1223,5676,'one','two')
>>> a,b,c,d = t
>>> a
1223
>>> d
'two'
Subscribe to:
Posts (Atom)