Solaris

Uso del comando FGREP
domenica 31 gennaio 2010
La sintassi del comando fgrep é:

fgrep options string filenames

Esempi:

1) Per trovare tutte le righe del file che contengono '*':

$ fgrep '*' /etc/system
*ident "@(#)system 1.18 97/06/27 SMI" /* SVR4 1.5 */
*
* SYSTEM SPECIFICATION FILE
*
* moddir:
*
* Set the search path for modules. This has a format similar to the
* csh path variable. If the module isn't found in the first directory
* it tries the second and so on. The default is /kernel /usr/kernel
*
* Example:
* moddir: /kernel /usr/kernel /other/modules
* root device and root filesystem configuration:
*
* The following may be used to override the defaults provided by
* the boot program:
*
* rootfs: Set the filesystem type of the root.
*
* rootdev: Set the root device. This should be a fully
* expanded physical pathname. The default is the
* physical pathname of the device where the boot
* program resides. The physical pathname is
* highly platform and configuration dependent.
*
* Example:
* rootfs:ufs
* rootdev:/sbus@1,f8000000/esp@0,800000/sd@3,0:a
*
* (Swap device configuration should be specified in /etc/vfstab.)
* exclude:
*
* Modules appearing in the moddir path which are NOT to be loaded,
* even if referenced. Note that `exclude' accepts either a module name,
* or a filename which includes the directory.
*
* Examples:
* exclude: win
* exclude: sys/shmsys
* forceload:
*
* Cause these modules to be loaded at boot time, (just before mounting
* the root filesystem) rather than at first reference. Note that
* forceload expects a filename which includes the directory. Also
* note that loading a module does not necessarily imply that it will
* be installed.
*
* Example:
* forceload: drv/foo
* set:
*
* Set an integer variable in the kernel or a module to a new value.
* This facility should be used with caution. See system(4).
*
* Examples:
*
* To set variables in 'unix':
*
* set nautopush=32
* set maxusers=40
*
* To set a variable named 'debug' in the module named 'test_module'
*
* set test_module:debug = 0x13


2) Per trovare la stringa adm nei file il cui nome finisce con .sh

$ fgrep adm *.sh
adm.sh:adm

















postato da Eduardo Kislanski @ 12:11   | 0 Commenti
Uso del comando EGREP
La sintassi del comando EGREP è:

egrep options pattern filenames.


Esempi:

1) Cerca tutte le stringhe che contengono la parola body all'interno del file /etc/passwd

$ egrep '[a-z]+body' /etc/passwd
nobody:x:60001:60001:NFS Anonymous Access User:/:
nobody4:x:65534:65534:SunOS 4.x NFS Anonymous Access User:/:

2) Cerca la stringa Network Admin e la stringa uucp Admin nel file /etc/passwd

$ egrep '(Network|uucp) Admin' /etc/passwd
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
listen:x:37:4:Network Admin:/usr/net/nls:
















postato da Eduardo Kislanski @ 12:04   | 0 Commenti
Uso del comando GREP

Option



Definition



-i



Searches for both uppercase ande lowercase characters



-l



lists the names of files with marching lines



-n



Precedes each line with the relative line number in the file



-v



Inverts the search to display lines that do not match th
pattern



-c



Counts the lines that contain the pattern



-w



Searches for tehe expression as a complete word,ignoring
those matches that are substrings of larger




Esempi:

1) cerca la stringa root nel file /etc/group e mi restituisce il numero della linea

$ grep -n root /etc/group

1:root::0:

2:other::1:root

3:bin::2:root,daemon

4:sys::3:root,bin,adm

5:adm::4:root,daemon

6:uucp::5:root

7:mail::6:root

8:tty::7:root,adm

9:lp::8:root,adm

10:nuucp::9:root

12:daemon::12:root

$cd /etc

$ grep -l root group passwd hosts

group

passwd

$ grep -c root group

11

Examples of using regular expression metacharacters


$ grep '^no' /etc/passwd
nobody:x:60001:60001:NFS Anonymous Access User:/:
noaccess:x:60002:60002:No Access User:/:
nobody4:x:65534:65534:SunOS 4.x NFS Anonymous Access User:/:


$ grep 'A...n' /etc/passwd
adm:x:4:4:Admin:/var/adm:
lp:x:71:8:Line Printer Admin:/usr/spool/lp:
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
listen:x:37:4:Network Admin:/usr/net/nls:


$ grep 'adm$' /etc/group
sys::3:root,bin,adm
tty::7:root,adm
lp::8:root,adm




postato da Eduardo Kislanski @ 09:17   | 0 Commenti
Commands (CHMOD)
sabato 30 gennaio 2010
Can change the permission set for files or directories using the chmod command. Either the owner of the file or directory, or the root user can use the chmod command to change permissions. The chmod command can change permissions specified in either symbolic mode or octal mode. The symbolic mode uses combinations of letters and symbols to add or remove permissions for each type of user. The octal mode uses octal numbers to represent each permission.

chmod symbolic_mode filename
The syntax for the chmod command in the symbolic mode is: chmod symbolic_mode filename The symbolic_mode option consists of three parts: the user category (owner, group, or other) affected, the function performed, and the permissions affected. For example, if the option is g+x, the executable permission is added for the group.


ex:
$ ls -l test
-rw-r--r-- 1 m171c0 other 0 Jan 30 09:56 test
$ chmod o-r test
$ ls -l test
-rw-r----- 1 m171c0 other 0 Jan 30 09:56 test


To remove the read permission for the group:

$ chmod g-r test
$ ls -l test
-rw------- 1 m171c0 other 0 Jan 30 09:56 test


Exampels Using the symbolic mode.

To adde an execute permissio for the owner ande permission for teh group and other:

$ ls -l test
-rwx------ 1 m171c0 other 0 Jan 30 09:56 test

to assing read adn write permissions for owner,group,and other:

$ chmod a=rw test
$ ls -l test
-rw-rw-rw- 1 m171c0 other 0 Jan 30 09:56 test


The chmod command syntax in octal_mode filename
The chmod command syntax in octal mode is: chmod octal_mode filename The octal_mode option consists of three octal numbers, from 0–7, which represent a combination of permissions for the file or directory. The table on the screen shows the octal values for each individual permission.

Octal Value

Permission

Sets binary

7

rwx

111 (4+2+1)

6

rw-

110 (4+2+0)

5

r-x

101 (4+0+1)

4

r--

100 (4+0+0)

3

-wx

011 (0+2+1)

2

-w-

010 (0+2+0)

1

--x

001 (0+0+1)

0

---

000 (0+0+0)


Octal Value

Permission

644

rw-r--r--

755

rwxr-xr-x

775

rwxrwxr-x

777

rwxrwxrwx





Examples using octal mode
To set perimssions so that owner grupo ande other haver read and exectue acess only:

$ chmod 555 test
$ ls -l test
-r-xr-xr-x 1 m171c0 other 0 Jan 30 09:56 test


to change owner and group permissions to include wirte access
$ chmod 775 test
$ ls -l test
-rwxrwxr-x 1 m171c0 other 0 Jan 30 09:56 test



to change the group permission read an execute only:

$ ls -l test
-rwxr-xr-x 1 m171c0 other 0 Jan 30 09:56 test

With 't' set, only the owner of a file can delete it.

chmod +t directorySet the sticky bit on a directory
chmod -t directory Remove the sticky bit from a directory


$ chmod +t somedir/


$ ls -l

drwxr-xr-t 2 root root 2 Feb 1 01:30 somedir




postato da Eduardo Kislanski @ 00:51   | 0 Commenti
Commands (RSH)
venerdì 29 gennaio 2010
Remote Shell (RSH)
rsh server df -k > server.df.txt


postato da Eduardo Kislanski @ 23:54   | 0 Commenti
Commands
AVAILABILITY
SUNWcsu


DESCRIPTION
The find command recursively descends the directory hierar-
chy for each path seeking files that match a Boolean expres-
sion written in the primaries given below.

find will be able to descend to arbitrary depths in a file
hierarchy and will not fail due to path length limitations
(unless a path operand specified by the application exceeds
PATH_MAX requirements).


OPERANDS
The following operands are supported:

path a path name of a starting point in the direc-
tory hierarchy.

The first argument that starts with a -, or is a ! or a (,
and all subsequent arguments will be interpreted as an
expression made up of the following primaries and operators.
In the descriptions, wherever n is used as a primary argu-
ment, it will be interpreted as a decimal integer optionally
preceded by a plus (+) or minus (-) sign, as follows:

+n more than n
n exactly n
-n less than n.

Expressions
Valid expressions are:

-atime n True if the file was accessed n days ago.
The access time of directories in path is
changed by find itself.

-cpio device Always true; write the current file on dev-
ice in cpio format (5120-byte records).

-ctime n True if the file's status was changed n days
ago.

-depth Always true; causes descent of the directory
hierarchy to be done so that all entries in a
directory are acted on before the directory
itself. This can be useful when find is used
with cpio(1) to transfer files that are con-
tained in directories without write permis-
sion.

-exec command True if the executed command returns a zero
value as exit status. The end of command
must be punctuated by an escaped semicolon.
A command argument {} is replaced by the
current path name.

-follow Always true; causes symbolic links to be
followed. When following symbolic links,
find keeps track of the directories visited
so that it can detect infinite loops; for
example, such a loop would occur if a sym-
bolic link pointed to an ancestor. This
expression should not be used with the - type
l expression.

-fstype type True if the filesystem to which the file
belongs is of type type.

-group gname True if the file belongs to the group gname.
If gname is numeric and does not appear in
the /etc/group file, it is taken as a group
ID.

-inum n True if the file has inode number n.

-links n True if the file has n links.

-local True if the file system type is not a remote
file system type as defined in the
/etc/dfs/fstypes file. nfs is used as the
default remote filesystem type if the
/etc/dfs/fstypes file is not present.

-ls Always true; prints current path name
together with its associated statistics.
These include (respectively):

o inode number
o size in kilobytes (1024 bytes)
o protection mode
o number of hard links
o user
o group
o size in bytes
o modification time.

If the file is a special file the size field
will instead contain the major and minor dev-
ice numbers.

If the file is a symbolic link the pathname
of the linked-to file is printed preceded by
`->'. The format is identical to that of ls
-gilds (see ls(1)).

Note: Formatting is done internally, without
executing the ls program.

-mount Always true; restricts the search to the
file system containing the directory speci-
fied. Does not list mount points to other
file systems.

-mtime n True if the file's data was modified n days
ago.

-name pattern True if pattern matches the current file
name. Normal shell file name generation
characters (see sh(1)) may be used. A
backslash (\) is used as an escape character
within the pattern. The pattern should be
escaped or quoted when find is invoked from
the shell.

-ncpio device Always true; write the current file on dev-
ice in cpio -c format (5120 byte records).

-newer file True if the current file has been modified
more recently than the argument file.

-nogroup True if the file belongs to a group not in
the /etc/group file.

-nouser True if the file belongs to a user not in
the /etc/passwd file.

-ok command Like -exec except that the generated command
line is printed with a question mark first,
and is executed only if the user responds by
typing y.

-perm [-]mode The mode argument is used to represent file
mode bits. It will be identical in format to
the operand described in
chmod(1), and will be interpreted as follows.
To start, a template will be assumed with all
file mode bits cleared. An op symbol of:

+ will set the appropriate mode bits in
the template;

- will clear the appropriate bits;

= will set the appropriate mode bits,
without regard to the contents of pro-
cess' file mode creation mask.

The op symbol of - cannot be the first char-
acter of mode; this avoids ambiguity with the
optional leading hyphen. Since the initial
mode is all bits off, there are not any sym-
bolic modes that need to use - as the first
character.

If the hyphen is omitted, the primary will
evaluate as true when the file permission
bits exactly match the value of the resulting
template.

Otherwise, if mode is prefixed by a hyphen,
the primary will evaluate as true if at least
all the bits in the resulting template are
set in the file permission bits.

-perm [-]onum True if the file permission flags exactly
match the octal number onum (see chmod(1)).
If onum is prefixed by a minus sign (-), only
the bits that are set in onum are compared
with the file permission flags, and the
expression evaluates true if they match.

-print Always true; causes the current path name to
be printed.

-prune Always yields true. Do not examine any
directories or files in the directory struc-
ture below the pattern just matched. See the
examples, below.

-size n[c] True if the file is n blocks long (512 bytes
per block). If n is followed by a c, the
size is in bytes.

-type c True if the type of the file is c, where c
is b, c, d, l, p, or f for block special
file, character special file, directory, sym-
bolic link, fifo (named pipe), or plain file,
respectively.

-user uname True if the file belongs to the user uname.
If uname is numeric and does not appear as a
login name in the /etc/passwd file, it is
taken as a user ID.

-xdev Same as the -mount primary.

Complex Expressions
The primaries may be combined using the following operators
(in order of decreasing precedence):

1) ( expression ) True if the parenthesized
expression is true
(parentheses are special to
the shell and must be
escaped).

2) ! expression The negation of a primary (!
is the unary not operator).

3) expression [-a] expression
Concatenation of primaries
(the and operation is implied
by the juxtaposition of two
primaries).

4) expression -o expression
Alternation of primaries ( - o
is the or operator).

Note: When you use find in conjunction with cpio, if you
use the - L option with cpio then you must use the -follow
expression with find and vice versa. Otherwise there will
be undesirable results.

If no expression is present, -print will be used as the
expression. Otherwise, if the given expression does not
contain any of the primaries -exec, -ok or -print, the given
expression will be effectively replaced by:

( given_expression ) -print

The -user, -group, and -newer primaries each will evaluate
their respective arguments only once.


EXAMPLES
The following commands are equivalent:

example% find .
example% find . -print

They both write out the entire directory hierarchy from the
current directory.

Remove all files in your home directory named a.out or * .o
that have not been accessed for a week:

example% find $HOME \( -name a.out -o -name '*.o' \
-atime +7 \ -exec rm {} \;

Recursively print all file names in the current directory
and below, but skipping SCCS directories:

example% find . -name SCCS -prune -o -print

Recursively print all file names in the current directory
and below, skipping the contents of SCCS directories, but
printing out the SCCS directory name:

example% find . -print -name SCCS -prune

The following command is roughly equivalent to the - nt
extension to test(1):

example$ if [ -n "$(find file1 -prune -newer file2)" ]; then
printf %s\\n "file1 is newer than file2"
fi

The descriptions of -atime, -ctime, and -mtime use the ter-
minology n ``24-hour periods''. For example, a file
accessed at 23:59 will be selected by:

example% find . -atime -1 -print

at 00:01 the next day (less than 24 hours later, not more
than one day ago); the midnight boundary between days has no
effect on the 24-hour calculation.


ENVIRONMENT
See environ(5) for descriptions of the following environment
variables that affect the execution of find: LC_COLLATE,
LC_CTYPE, LC_MESSAGES, and NLSPATH.


EXIT STATUS
The following exit values are returned:
0 All path operands were traversed successfully.
>0 An error occurred.


FILES
/etc/passwd password file
/etc/group group file
/etc/dfs/fstypes file that registers distributed file
system packages


SEE ALSO
chmod(1), ls(1), sh(1), test(1), stat(2), umask(2),
environ(5)


WARNINGS
The following options are obsolete and will not be supported
in future releases:

-cpio device Always true; write the current file on device
in cpio format (5120-byte records).

-ncpio device Always true; write the current file on device
in cpio -c format (5120 byte records).


NOTES
When using find to determine files modified within a range
of time, one must use the ?time argument before the -print
argument otherwise find will give all files.
postato da Eduardo Kislanski @ 10:24   | 0 Commenti
Solaris package info

To check which package a file belongs to:


pkgchk -p -l


grep filename /var/sadm/install/contents

postato da Eduardo Kislanski @ 10:14   | 0 Commenti
SUDO ON SOLARIS
SUDO ON SOLARIS
To get sudo working on Solaris

Need to link the /opt/csw/bin/sudo file to /usr/bin/sudo
Need to link the /opt/csw/etc/sudoers file to /etc/sudoers
Need to link the /opt/csw/sbin/visudo file to /usr/sbin/visudo
ln -s /opt/csw/bin/sudo /usr/bin/sudo
ln -s /opt/csw/etc/sudoers /etc/sudoers
ln -s /opt/csw/sbin/visudo /usr/sbin/visudo

Then, as root, edit the /etc/sudoers file using visudo"
postato da Eduardo Kislanski @ 10:12   | 0 Commenti
Comands Solaris
mercoledì 27 gennaio 2010
ps

The following table summarizes the main options used with ps.
Option Description
–a Lists most frequently requested processes
–A, –e List all processes
–c Lists processes in scheduler format
–d Lists all processes
–f Prints comprehensive process information
–g Prints process information on a group basis for a single group
–G Prints process information on a group basis for a list of groups
–j Includes SID and PGID in printout
–l Prints complete process information
–L Displays LWP details
–p Lists process details for list of specified processes
–P Lists the CPU ID to which a process is bound
–s Lists session leaders
–t Lists all processes associated with a specific terminal
–u Lists all processes for a specific user


kill
The following table summarizes the main signals used to communicate with processes
using kill.
Signal Code Action Description
SIGHUP 1 Exit Hangup
SIGINT 2 Exit Interrupt
SIGQUIT 3 Core Quit
SIGILL 4 Core Illegal instruction
SIGTRAP 5 Core Trace
SIGABRT 6 Core Abort
SIGEMT 7 Core Emulation trap
SIGFPE 8 Core Arithmetic exception
SIGKILL 9 Exit Killed
SIGBUS 10 Core Bus error
SIGSEGV 11 Core Segmentation fault
SIGSYS 12 Core Bad system call
SIGPIPE 13 Exit Broken pipe
SIGALRM 14 Exit Alarm clock
SIGTERM 15 Exit Terminate

pgrep
The pgrep command is used to search for a list of processes whose names match apattern specified on the command line. The command returns a list of corresponding

For example,
$ kill –9 `pgrep apache`

USERADD

for example:
useradd -d /export/home/m171c0 -m -s /bin/bash -c "Domenico" domenico

Plattaform
/usr/platform/`uname -i`/sbin/prtdiag -v

Memory Size
/usr/sbin/prtconf | grep "Memory size"


gzip –9

compress

compress backup.tar
uncompress backup.tar.Z
postato da Eduardo Kislanski @ 19:36   | 0 Commenti
MARVEL and SPIDER-MAN: TM & © 2007 Marvel Characters, Inc. Motion Picture © 2007 Columbia Pictures Industries, Inc. All Rights Reserved. © 2007 Sony Pictures Digital Inc. All rights reserved.