Tuesday, December 7, 2010

Learning UNIX - III

File Transfer and Communication Management


xyx:/>cu command, is used for communications over a modem or direct line with another Unix system.

xyx:/>ftp command is used to execute for files transfer over two systems.

-d enable debugging.
-g disable filename globing.
-i turn off interactive prompts.
-v verbose on. Show all responses from remote server.

command invokes a login session to a Unix box, System prompts you to enter userid and password.

xyx:/>rlogin command is used to log on to remote Unix systems, user must have permissions on both systems as well as same user id, or an id defined in .rhosts file.
xyx:/>rlogin host

command used to invoke talk program available on all unix system which lets two users exchange information back and forth in real time.

xyx:/>talk userid@hostname

xyx:/>telnet - command invokes a telnet protocol which lets you log on to different unix, vms or any machine connected over TCP/IP protocol, IPx protocol or otherwise.

xyx:/>telnet host1
xyx:/> telnet

command is used for out of office message to be send. It returns a mail message to sender announcing that you are on vacation.
/export/home/crk> vacation
This program can be used to answer your mail automatically
when you go away on vacation.
You need to create a message file in /export/home/crk/.vacation.msg first.
Please use your editor (vi) to edit this file.
"/export/home/crk/.vacation.msg" 4 lines, 130 characters
Subject: away from my mail
I will not be reading my mail for a while.
Your mail regarding "$SUBJECT" is read when I return.
N.B:- To disable this feature, use mail -F " "
-d will append the date to the log file.
-F user will forward mail to user when unable to send mail to mail file.
-l log file will record in the log file the names of senders who received automatic reply.
-m mail file will save received messages in mail file.

command initiate an interactive conversation with user.

xyx:/>write user1 tty
System reporting and Status Management

xyx:/>at command.
at command is also used like crontab command, to schedule jobs.

-f file execute commands in a file.
-m sends mail to user after job is completed.
-l list all jobs that are scheduled and their jobnumbers.
-r job number will remove specified jobs that were previously scheduled.

xyx:/>chmod Command is used to change permissions on a file.
xyx:/>ls -la test.txt
-rw-rw-rw- 1 qtr pmpcr 135 OCT 20 16:14 test.txt
-rw-rw-rw- meaning that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next qtr is owner of this file pmpcr is the group of this file, there are 135 bytes in this file, this file was created on Oct 20 at time16:14 and at the end there is name of this file.
xyx:/>chmod 600 file1

xyx:/>chgrp command is used to change the group of a file or directory.
xyx:/>chgrp [options] newgroup files
Newgroup is either a group Id or a group name located in /etc/group .
Available Options:
-h will change the group on symbolic links.
-R recursively descend through directory changing group of all files and subdirectories.

xyx:/>chown command.
chown command to change ownership of a file or directory to one or more users.

xyx:/>chown options new owner files
Available important Options
-h will change the owner on symbolic links.
-R will recursively descend through the directory, including subdirectories and symbolic links.

xyx:/>crontab is used to schedule jobs. Permission to run this command should have been granted.
Normally Jobs are scheduled in five numbers, as follows.
Minutes 0-59
Hour 0-23
Day of month 1-31
month 1-12
Day of week 0-6 (0 is sunday)
To schedule a job which runs from script named backup_jobs in /usr/local/bin directory on sunday (day 0) at 11.25 (22:25) on 15th of month.

* represents all values.
25 22 15 * 0 /usr/local/bin/backup_ xyx:/>jobs
The * here tells system to run this each month.
Syntax is
xyx:/>crontab file ## To create a file with the scheduled jobs like above
xyx:/>crontab file1 # to schedule job

xyx:/>date - command displays to days date, to use it type date at command prompt
Fri Oct 20 16:10:58 EDT 2010


df command displays information about mounted filesystems.
/ (/dev/md/dsk/d0 ): 3838540 blocks 431434 files
/proc (/proc ): 0 blocks 29848 files
/etc/mnttab (mnttab ): 0 blocks 0 files
/dev/fd (fd ): 0 blocks 0 files
/var (/dev/md/dsk/d20 ): 2559692 blocks 587286 files
/var/run (swap ):31292080 blocks 789270 files
/dev/vx/dmp (dmpfs ):31292080 blocks 789270 files
/dev/vx/rdmp (dmpfs ):31292080 blocks 789270 files
/tmp (swap ):31292080 blocks 789270 files
/opt (/dev/md/dsk/d30 ): 2509926 blocks 609248 files
/opt/crk (/dev/md/dsk/d40 ):32416940 blocks 2240301 files

Available Options
-b show only the number of free blocks.
-e show only the number of free files.
-k list allocation in kilobytes.
-l show only on local file systems.
-n list only the file system name type

du command displays disk usage.

env command displays all the variables set in your profile

xyx:/>finger - command used to display information about local and remote users.
xyx:/>finger user1@abc

ps command is the most useful command for systems administrators. It reports information on active processes.
Available options.
-a Lists all processes in system except processes not attached to terminals.
-e Lists all processes in system.
-f Lists a full listing.
-j print process group ID and session ID.
xyx:/>ps -eafj |more
root 0 0 0 0 0 Sep 08 ? 0:19 sched
root 1 0 0 0 0 Sep 08 ? 2:51 /etc/init -r
root 2 0 0 0 0 Sep 08 ? 0:00 pageout
root 3 0 0 0 1 Sep 08 ? 634:05 fsflush
root 6817 1 6817 6817 0 Sep 08 ? 0:00 /usr/lib/saf/sac -t 3
root 590 1 590 590 0 Sep 08 ? 0:06 /usr/lib/inet/xntpd
root 689 1 0 0 0 Sep 08 ? 0:00 /sbin/sh - /usr/lib/v
root 20 1 20 20 0 Sep 08 ? 3:48 vxconfigd -x syslog -
m boot

xyx:/>ruptime - command tells the status of local networked machines.

Available options.
-a include user even if they've been idle for more than one hour
-l sort by load average
-r reverse the sort order
-t sort by uptime
-i sort by number of users

xyx:/>shutdown command executed by root. To gracefully bring down a system, shutdown command is used.
-gn use a grace-period of n seconds (default is 60).
-ik tell the init command to place system in a state k.
s single-user state (default)
shutdown for power-off
1 like s, but mount multi-user file systems
5 stop system, go to firmware mode
6 stop system then reboot
-y suppress the default prompt for confirmation.

xyx:/>stty - command sets terminal input output options for the current terminal.
Without options stty reports terminal settings.

-a report all options.
-g report current settings.
Available Modes
0 hang up phone.
n set terminal baud.
erase keyname, will change your keyname to be backspace key.

xyx:/>who - command displays information about the current status of system.
who options file
Who as default prints login names of users currently logged in.
Available Options
-a use all options.
-b Report information about last reboot.
-d report expired processes.
-H print headings.
-p report previously spawned processes.
-u report terminal usage.
File Redirection Management
xyx:/>cal > cal.txt , create a new file called cal.txt that has calendar for current month.
> sign redirects output from stdout (screen) to a file. If file already exists, it will over right the content with latest information being redirected
>> will append the file if it is already existing

No comments:

Post a Comment