SOME IMPORTANT UNIX COMMANDS

GENERAL COMMANDS
banner
Description : This command prints the argument supplied, in large letters so as to appear like a banner.

Example:
$ banner hello

# # ###### # # ####
# # # # # # #
###### ##### # # # #
# # # # # # #
# # # # # # #
# # ###### ###### ###### ####


cal
Description : The command can print the calendar for any year in the range 1 to 9999. The command, when given no arguments, generally prints the calendar for the previous, current and following months.

Example:
$ cal
July 2003
S M Tu W Th F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

$ cal 8 1947
August 1947
S M Tu W Th F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

 An unusual calendar is printed for September 1752. That is the month 11 days were skipped to make up for lack of leap year adjustments. To see this calendar, type:
$ cal 9 1752
date
Description : This command is used to display the current system date or set the system date.

Example:
$ date
Mon Jul 28 17:08:26 IST 2003

$ date +%a
Mon

$ date +%A
Monday

$ date +%b
Jul

$ date +%B
July

date +%d
28

$ date +%D
07/28/03

Try the output for other formats like x, X, c, C. An interesting option is j
echo
Description : Displays the text supplied as argument or the contents of the variable that is supplied as argument.

Example:
$echo Welcome to world of UNIX
Welcome to world of UNIX

passwd
Description : This command is used to change the user’s password or to create a new password. The argument is used by the super user alone.
pg
Description : This command displays the contents of the files specified, page-wise.

Example:


pipe “|”
Description : Channels the output of command1 as input for command2.

Example:
$ls /etc | pg
acct dmi hosts magic nsswitch.dns
aliases driver_aliases inet mail nsswitch.files
apache driver_classes inetd.conf minor_perm nsswitch.ldap
auto_home dumpadm.conf init mkfs nsswitch.nis
auto_master dumpdates init.d mknod nsswitch.nisplus
autopush ff initpipe mnttab opasswd
b2k fmthard ignitable motd openwin
cfgadm fn install mount opt
chroot format ioctl.syscon mountall ouser_attr
clri format.dat iplanet mvdir pam.conf
coreadm.conf fs iu.ap name_to_major passwd
cron fsck killall name_to_sysnum path_to_inst
cron.d fsdb krb5 nca path_to_inst.old
dacf.conf fstyp labelit ncheck power.conf
datemsk ftpd lib net ppp
dcopy fuser link netconfig printers.conf
default getty llc2 netmasks profile
defaultrouter group log networks project
device.tab grpck logadm.conf nfs protocols
devlink.tab gss logindevperm nfssec.conf prtconf
dfs gtk lp nodename prtvtoc
dgroup.tab halt lu nscd.conf publickey
dhcp hostname.hme0 lvm nsswitch.conf pwck
sleep
Description : This command is used to delay a process for a period of time.

Example:
$sleep 30
wc
Description : This command does a count operation on the file given as argument based on the options given.
Example:
$ wc /etc/passwd

58 70 2275 /etc/passwd

Try the options –l, -w & -c
who
Description : This command lists all the users who are currently logged in, along with the time of login and the terminal details.

Example:
$who
ram2 pts/8 Jul 29 15:59 (blrtwr18282.ad.infosys.com)
rajesh2 pts/9 Jul 29 09:57 (blrkec19005.ad.infosys.com)
balu1 pts/13 Jul 29 08:36 (blrkec18886.ad.infosys.com)
root pts/14 Jul 29 08:37 (blrkec18886.ad.infosys.com)
finadm pts/15 Jul 29 08:40 (blrkec18886.ad.infosys.com)
fabadm pts/16 Jul 29 09:26 (blrtwr15900.ad.infosys.com)
fabadm pts/3 Jul 29 09:33 (blrtwr15900.ad.infosys.com)
anil1 pts/4 Jul 29 09:40 (blrkec06585.ad.infosys.com)
venkat1 pts/5 Jul 29 09:42 (blrkec16592a.ad.infosys.com)
balu2 pts/6 Jul 29 10:11 (blrkec18886.ad.infosys.com)
kvs1 pts/18 Jul 29 11:45 (blrkec18900.ad.infosys.com)
kvs2 pts/19 Jul 29 11:46 (blrkec18900.ad.infosys.com)
prakash1 pts/20 Jul 29 14:39 (blrkec18930.ad.infosys.com)

ls
Description : This command lists the files if the argument is a directory. If the argument is a file, it lists the details about the file.
Example:
$ls /users

The above command does not give much information about the files
$ls –l /users
drwxrwxr-x 3 root bin 512 Dec 1 2000 openwin
drwxrwxr-x 8 root sys 512 Dec 5 2000 opt
-r-------- 1 root sys 2985 Aug 11 10:40 oshadow
-rw-r--r-- 1 root sys 1742 Dec 5 2000 pam.conf
-r--r--r-- 1 root sys 4461 Aug 8 17:46 passwd
-r--r--r-- 1 root sys 3498 Dec 12 2000 path_to_inst
-r--r--r-- 1 root sys 3498 Dec 12 2000 path_to_inst.old
-rw-r--r-- 1 root sys 190 Dec 1 2000 printers.conf
-rw-r--r-- 1 root sys 1501 May 17 11:42 profile
-rw-r--r-- 1 root other 700 Dec 14 2000 profile.preaw
The above command lists the details of the files
-rw-r--r-- Indicates the file permissions
1 Indicates the number of links
root is the user ID of the file's owner
other is the group ID of the group
700 is the size of the file in bytes
Dec 14 2000 is the time stamp—the date and time when the file was last modified
profile.preaw is the name of the file

The first and second columns require a bit more explanation. The first column is a ten-character field that indicates the file's mode—its type and its permissions. In the first line of the list, the file's mode is –rw-r--r—. The first character tells the file type, which is a hyphen (-) for regular files, and d for directories. In this example, the first two items are directories and rest ordinary files.
The next nine characters of the entry are the file's permissions—three sets of three characters that control which users may access a file and what they can do with it. The first set of three characters controls what the file's owner can do; the second set of three characters controls what others in the group can do; and the third set of three characters controls what all other users can do. Each set of three characters show read (r), write (w), and execute (x) permission, in that order. A hyphen (-) means that the permission is denied.
The second column of the long listing is the number of links to this file.

cd
Description : This command enables the user to change his current working directory and puts him in the directory supplied as argument. If no argument is given, it takes him to his home directory.

Example:
$ cd

$ cd /users

$ cd ../prakash1

pwd
Description : This command prints the path name of the current working directory.

Example:
$ pwd
head
Description : This command displays the first n lines of the files specified as arguments

Example:
$ head /etc/services
$ head -20 /etc/services

tail
Description : This command displays a part of the file, generally the last part, beginning at a designated place.

Example:
$ tail /etc/services
$ tail -20 /etc/services

finger
Description : This command lists the users who are logged on and details about their terminal, time of login and so on.

Example:
$ finger prakash1
Login name: prakash1
Directory: /users/prakash1 Shell: /bin/ksh
On since Jul 29 14:39:24 on pts/20 from blrkec18930.ad.infosys.com
No unread mail
No Plan.
man
Description : This command displays the reference manual pages related to the command given as argument.

Example:
$ man vi
Reformatting page. Wait... done

User Commands finger(1)

NAME
finger - display information about local and remote users

SYNOPSIS
finger [ -bfhilmpqsw ] [ username... ]

finger [-l ]
[ username@hostname1[@hostname2...@hostnamen] ... ]

finger [-l ] [ @hostname1[@hostname2...@hostnamen] ... ]

DESCRIPTION
By default, the finger command displays in multi-column for-
mat the following information about each logged-in user:
o user name
o user's full name
o terminal name (prepended with a `*' (asterisk) if
write-permission is denied)

FILE MANAGEMENT
cat
Description : This command can concatenates files or displays their contents.

Example:
$ cat /etc/services

$ cat -n /etc/services

cmp
Description : This command is used to compare the contents of the two file supplied as arguments.

Example:
$ cmp file1 file2
comm
Description : This command is used to select or reject lines common to two sorted files. It produces a three columnar output where the columns contain lines only in file1, lines only in file2 and lines in both files respectively.

Example:
$ comm file1 file2
cp
Description : This command is used to copy files from the given source to the specified destination.

Example:
$ cp file1 file2
mkdir
Description : This command is used to create a directory.

Example:
$ mkdir dir1

mv
Description : This command moves or renames files and directories.

Example:
$ mv file1 file2

rm
Description : This command is used to remove files or directories.

Example:
$ rm file1
rmdir
Description : This command removes the directory specified as argument provided it is empty.

Example:
$ rmdir dir1
cut
Description : This command is used to cut out columns from a table or fields from each line of one or more files. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option), or the length can vary from line to line and be marked with a field delimiter character like Tab (-f option). If no files are specified, cut reads from the standard input.

Example:
$ cut -c 1-10 /etc/services
ln
Description : A link is a directory entry referring to a file; a single file (together with its size, all its protection information, and so on) may have several links to it. There are two kinds of link: hard links and symbolic links. By default ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effective independent of the name used to reference the file. Hard links may not span file systems and may not refer to directories. This command is used to make a link to a file or directory. A symbolic link contains the name of the file to which it is linked; this file does not need to exist prior to the symbolic link.

Example:
$ ln file1 file2

$ ln –s file1 file2

$ ln –n file1 file2


FILE SECURITY
chgrp
Description : This command is used to change the group id of the files specified to the group id specified as argument.

Example:


$chgrp
$ chgrp dba file1
$ chgrp – R dir1 dba
 chgrp can be restricted in Solaris platform based on the parameter set rstchown = 1 in the /etc/system file.
chown
Description : This command is used to change the owner id of the files specified as arguments to the owner id specified.

Example:
$chown
$ chown dba file1
$ chown – R dir1 dba

chmod
Description : This command changes the access permissions of a file or directory.

Example:
$ chmod 755 file1
$ chmod – R 755 dir1
$ chmod u+x file1
$ chmod u+rwx file1
$ chmod o-rwx file1

MAIL RELATED COMMANDS
mail
Description : mail provides a flexible environment for sending and receiving messages electronically. For reading messages, mail provides commands to allow saving, deleting, and responding to messages. For sending messages, mail allows editing, reviewing, and other modification of the message as it is entered.
Example:
$mail recipient
$ mail trg1
mesg
Description : This command is used to permit or deny messages sent to a terminal.

write
Description : This command is to copy lines from your terminal to that of another user. When first called, it sends the message:
Message from your-logname your-tty ...

talk
Description : The talk utility is a two-way, screen-oriented communication program.

When first invoked, talk sends a message similar to:
Message from TalkDaemon@ her_machine at time ...
talk: connection requested by your_address
talk: respond with: talk your_addressto the specified address. At this point, the recipient of the message can reply by typing:

talk your_address

No comments:

Post a Comment