Brief introduction
Starting session
(activate putty on your window desktop . Give server address)
login <- enter your login name (case sensitive)
password <- enter password (case sensitive) , nothing will display , if wrong entry press enter till login
prompt appears (back space key may work to delete entered chars.)
Once you log in, the system may displays some information about the system . The command prompt
may appears as a dollar sign ($) . Now you are inyour home directory.
to finish session -type exit or logout at command prompt. (or Ctrl+D)
shell is command interpreter . Commands are gateway to OS. Here only Bash shell is covered .
(other shell are C shell(csh), tc shell(tcsh), Z shell (zsh), k shell etc).
The eight most important shell commands in UNIX are:
ls
lists file names. (can use dir also)
cat
displays the contents of files
cp
copies files
mv
renames and moves files
rm
deletes files
chmod
grants and revokes access to files
mkdir
creates subdirectories
rmdir
removes subdirectories
many commands uses hyphen (-) to indicate options, or switches that say how a command should
operate.
when you type a wrong command name it give message-looked for a program called x and couldn't
find it. Many of the switches can be given with single -. there should be space between command and
hyphen and parameters.
If you do not provide complete (required)/wrong parameter with command the system displays the
Usage of the command or error message.
Online help is available for commands. You can use info and man. format is
man commandname
info commandname
(to come out , back to shell, of man or info back to prompt press q .)
File naming- any combination of alphanumeric except <, >, |, -, ?, [, ], and *. Names are case sensitive.
first character if . means a hidden file (name will be displayed by ls only with specific option).
You can use wild card (* (for many characters and ? For one character) in filename when listing.
ls my* ;
ls *6* ;
ls ??test* ; ls my*6 ; for file name mytestfile68
if file name has a space then it is accessed using for example my file
file organization based on nested directory structure
main directory is called root /
;subdirectories are separated by /
following are subdirectories of root(/) in linux
bin
boot dev etc
home lib
lost+found
media misc mnt net opt
root sbin sys
tmp usr
var
Important directories in file structure
proc
/ - root of filesystem
/bin essential command binaries- files needed to boot and run time (common programme)
/sbin- essential system binaries used in system administration (root)
/boot files related to boot loader (kernel )
/etc system configuration files
/dev files related to peripheral devices
/home- user's home directory is one of the subdirectory of home
/lib shared libraries files
/mnt mount point of temporary partition or removable storage
/opt - Option installed programs
/proc- contains kernel and process information files (processor pseudo files)
/root home directory of root (super user)
/tmp temporary files of programmes
/usr files and programmes used by system and all users
/var- files whose contents varies as the system runs (changing files)
/usr/doc- documents
/usr/bin- more shared programmes
/usr/lib - Specialize libraries
/usr/man online manual
/usr/src- kernel source code
/usr/include- header files of c programmes
/mnt/cdrom - Cd-ROM drive
/mnt/floppy - Floppy drive
/cdrom - Same as mnt/cdrom
/dev/null - Null device
/dev/tty - Current display device
/home/uos10/ - your home directory folder
pathname tells the location of a file or subdirectory starting from / (root)
path name can be absolute or relative. Absolute complete path from root to file/subdirectory is written.
In relative path ../ or subdirectoryname is used to move parent or child subdirectory in command
parameters (relative path never starts with /)
format of command
command [option] [source] [destination]
(source / destination objects can be given with absolute/relative path)
When files of directory is listed it gives information about files
first field is access right
d rwxrwxrwx
or
- rwxrwxrwx
or
l rwxrwxrwx
or
p rwxrwxrwx
the first character tells
whether it a subdirectory or a file or some special file
if first character is - it is a normal file , if d it is subdirectory else other special files
remaining nine characters give the right of the file
r right to read(read or copy);
w right to write(edit);
x right to execute(if programme)
these rights are for owner (creator) , owner's group and others (from left to right order)
if any of these nine field is it means that right is not available to individual (owner, group, other)
directory has different meaning for access rights
r right to read(list the files in);
w right to write(create files in);
x right to execute cd
command to change into that directory
pipe )
g++
g77
to run more than one commands in serial order use semicolon - cmd1 ; cmd2 ;.....cmd n
compress / archieve
tar -tvzf mytarball.tgz : show table of contents(t)of gzipped(z) tarball with filename(f) mytarball.tgz
tar -xzf tarball.tgz :untar (extract x) contents of gzipped(z) tarball tarball.tgz
tar -cz mydir f mytarball.tgz :create(c) a tarball mytarball.tgz from directory mydir
gzip filen : compress the file filen using GNUzip (-v,)
gunzip filen.gz : unzip the file filen.gz(compress with GNUzip)
zcat : displays the compressed file as it were compressed
disk mounting/partition commands
mount to mounte filesystems
mount -t msdos /dev/fd0 /mnt/floppy
mount -t iso9660 /dev/cdrom /mnt/cdrom
mount ro -t vfat /dev/sda1 /mnt/windows ( Windows partition on sda1)
( directory must already exists in /mnt before mounting)
umount
Unmount a file system
fdisk disk partition table (old type , for new type GPT use different command)