What is 'inode'?

 

Ans:

 

When a file system is created, data structures that contain

information about files are created. Each file has an inode

and is identified by an inode number (often "i-number" or

even shorter, "ino") in the file system where it resides.

Inodes store information on files such as user and group

ownership, access mode (read, write, execute permissions)

and type of file. There is a fixed number of inodes, which

indicates the maximum number of files each filesystem can hold.

 

A file's inode number can be found using the ls -i command,

while the ls -l command will retrieve inode information.

This is description of inode information  which it contain:

 

* The length of the file in bytes.

* Device ID (this identifies the device containing the

file).

* The User ID of the file's owner.

* The Group ID of the file.

* The file mode, which determines what users can read,

write, and execute the file.

* Timestamps telling when the inode itself was last

modified (ctime, change time), the file content last

modified (mtime, modification time), and last accessed

(atime, access time).

* A reference count telling how many hard links point to

the inode.

* Pointers to the disk blocks that store the file's content

 

 

 

 

 

UNIX File and Directory Management

File naming

File names can be any length

Unix is case sensitive. Upper and lower case letters are different. File "A" is different from "a".

Names may include some punctuation: . (period) -(dash), _(underscore), %(percent) and $(dollar sign)

The extension notion is used to some degree. Some common extensions are

A filename prog.1.java is okay although discouraged 

 

Directory Structure

Examples

ls /var/mail

ls /home/rhodes 

cat /etc/hosts 

ls ~rhodes (~ is a shortcut way to someone's login directory)  

 

Some common file management commands

These commands are very basic in function. Be sure you know them well  

cd 

change directory

 

cd .. 

change to parent directory

 

cd ~user 

change to user's directory

 

ls 

list filenames

 

cat file

catenate the file contents

 

rm filegroup

remove (be careful, Unix doesn't have file versions) 

 

cp file1 file2

copy files

 

mv file1 file2

move files

 

mkdir dir

make a directory

 

rmdir dir

remove an empty directory

 

cd dir

change working directory to this one (relative or absolute)

 

pwd 

print working directory (actually display it, not to the printer)

 

lp file

print to the default line printer (set to C102)

 

lp -dmainlasr file

enscript -2r file

enscript -2r -Pmainlasr file

print file to the A214 laser printer  (-ddestination)

print file in enscripted format

mainlasr

mainlasrb

c102 c217

 

p107 cyber

p223

 

cancel

remove job from line printer

 

lpstat 

check the line printer queue (-t gives a full listing of all queues)

 

vi filename

start the visual editor on the file designated

 

g++ filename.cpp 

compile using the gnu c++ compiler (a.out is the default executable)

 

g77 filename.for

compile using the gnu g77 FORTRAN compiler (a.out is the default exe)

 

javac file.java

compile a java program

 

java classfile

execute a java class file

The Unix server does not know about other printers on the network.  Printers are accessible only if they have their own IP address and can print postscript.  Do not expect to print on your personal printer unless you ftp the file to your machine and print it from notepad or the ftp application directly.

 

UNIX Commands and their descriptions

Basic UNIX commands

Note: not all of these are actually part of UNIX itself, and you may not find them on all UNIX machines. But they can all be used on turing in essentially the same way, by typing the command and hitting return. Note that some of these commands are different on non-Solaris machines - see SunOS differences.  

If you've made a typo, the easiest thing to do is hit CTRL-u to cancel the whole line. But you can also edit the command line (see the guide to More UNIX).  

UNIX is case-sensitive.

Files

Directories

Directories, like folders on a Macintosh, are used to group files together in a hierarchical structure.

Finding things

About other people

About your (electronic) self

Connecting to the outside world

Miscellaneous tools

 

CAT : command

The cat command reads one or more files and prints them to standard output. The operator can be used to combine multiple files into one. The operator >> can be used to append to an existing file.

The syntax for the cat command is:

cat [options] [files]

options:

-e

$ is printed at the end of each line. This option must be used with -v.

 

-s

Suppress messages pertaining to files that do not exist.

 

-t

Each tab will display as ^I and each form feed will display as ^L. This option must be used with -v.

 

-u

Output is printed as unbuffered.

 

-v

Display control characters and nonprinting characters

 

Examples:

cat file1 

cat file1 file2 > all 

cat file1 >> file2

 

You can find out more about these commands by looking up their manpages:  

man commandname --- shows you the manual page for the command

 

 

 

 

 

Sort command in unix

 

About sort

Sorts the lines in a text file.

Syntax

sort [-b] [-d] [-f] [-i] [-m] [-M] [-n] [-r] [-u] [+fields] filename [-o outputfile]

-b

Ignores spaces at beginning of the line.

 

-d

Uses dictionary sort order and ignores the punctuation.

 

-f

Ignores caps

 

-i

Ignores nonprinting control characters.

 

-m

Merges two or more input files into one sorted output.

 

-M

Treats the first three letters in the line as a month (such as may.)

 

-n

Sorts by the beginning of the number at the beginning of the line.

 

-r

Sorts in reverse order

 

-u

If line is duplicated only display once

 

+fields

Sorts by fields , usually by tabs

 

filename

The name of the file that needs to be sorted.

 

-o outputfile

Sends the sorted output to a file.

Examples

sort -r file.txt - Would sort the file, file.txt in reverse order.