Acerca de Linux, BSD y notas personales

Archives for Nix category

SYMLINKS / HARDLINKS

### SMYLINKS / SOFT ###
Note: Symlinks may traverse file systems & point to directories
Softlinks

ln -s source(file/directory) target (any directory)

Note: use ls -Ll symlink_name to reveal symlink’s TRUE permissions
Note: symlinks are created with 777 permissions

The target exits or you dont have permissions use:
ln -fs /curl* curl

### HARDLINKS ###
ln without s option

ln source target


Note: Source & Target (destination) MUST reside within the same file system

Each file systems allocates a set number of INODES with likely overlap in Inode numbers across file systems

/ - 10 GB - 10,000 Inodes
/var - 20 -GB -

For first 10GB of 20GB - 10,000 Inodes 1 -10,000
For second 10GB of 20GB - 1,000 Inodes 10,001 - 20,000

ls -il - reveals file inodes


ls -i
total 7163
292292 drwxr-xr-x 2 root root 512 Aug 8 09:01 Desktop
292279 drwxr-xr-x 2 root root 512 Aug 8 09:01 Documents
1519 lrwxrwxrwx 1 root root 9 Aug 8 02:09 bin -> ./usr/bin
2803 drwxr-xr-x 6 root sys 512 Aug 8 04:20 boot
44822 -rw——- 1 root root 3331728 Aug 21 15:06 core

Note: Hard Links must reside within the same file system

Next… DEVICES & DRIVERS…

SETUID/GID

chgrp - change file group ownership

# which /usr/bin/chgrp
/usr/bin/chgrp

### SETUID / SETGID ### - Sets the effective user/group ID ###

chmod 644 filename
chmod 0644 filename

SETUID - 4
SETGID - 2

chmod 4660 filename.txt

-rwSrw—- filename.txt ( note the S )

### Security Breach Warning ### SETUID run as the owner of the file

Note: SETGID applied to directories, forces assignment of GID

chmod 4644 filename
chmod 2644 filename

Collaborative

SETUID/SETGID

next symbolic links

File Permissions / Types

Permissions hard_links owner group_owner size Month day MTime name
-r-xr-xr-x 1 root bin 10196 Jan 22 2005 time

Permissions - represented by 10 bits:

0 bit = file type ( - file, d directory, b block, l symbolic link, p named pipe, s socket )

Note: remaining 9 bits are grouped into 3 groups

123 bits = r-x (entry’s owner)

456 bits = r-x ( group owner )

789 bits = r-x ( everyone )

r = read
w = write
x = execute

Unix uses octal value to represent permissions for ( rwx )

r = read = 4
w = write = 2
x = execute = 1
- = no access = 0
Total = 7

Note: 7 is max octal permission assignible to user/group/other

d rwx r-x r-x 24 root sys 1536 Aug 21 15:25 platform

rwx ( owner: root ) = 4+2+1=7
r-x ( group: sys ) = 4+0+1=5
r-x ( other ) = 4+0+1=5

/platform directory = 755 octal permissions or rwx r-x r-x

### UMASK ###

umask - get or set the file mode creation mask

umask Default for root = 0022

0777 - 022 = 644

### chmod ####
Note: chmod permits alteration of permissions on files / directories

chmod octal_value object_name ( file/directory )

u = Owner of file
g = Group
o = other
a = ALL

Add Permisions
chmod a+rw = chmod 666

Substract
chmod a-w = chmod 444 file name

chmod -R perms object_name

chmod -R u=rwx,g=rx,o=rx = chmod -R 755

> Hi,

> How can I monitor a number of file descriptors opened by a particular
> process on Solaris8 ?

> Thanks,
> Alona

download lsof from http://www.sunfreeware.com/, then run “lsof -p
pid”.

Victor

Responder al autor Reenviar

Debes registrarte antes de enviar mensajes.
Para enviar una entrada, antes deberás formar parte del grupo.
Antes de enviar entradas, actualiza tu alias en la configuración de la suscripción.
No dispones del permiso necesario para enviar entradas.

roger.faulk…@sun.com
Ver perfil
Más opciones 1 mayo 2007, 00:00
Grupos de noticias: comp.unix.solaris
De: roger.faulk…@sun.com
Fecha: 30 Apr 2007 22:00:50 -0700
Local: Mart 1 mayo 2007 00:00
Asunto: Re: how to monitor open file descriptors on Solaris8
Responder al autor | Reenviar | Imprimir | Mensaje individual | Mostrar mensaje original | Informar de este mensaje | Buscar mensajes de este autor
On Apr 30, 3:45 pm, Alona wrote:

> Hi,

> How can I monitor a number of file descriptors opened by a particular
> process on Solaris8 ?

> Thanks,
> Alona

Use the pfiles command.
Check the pfiles(1) man page.

Roger Faulkner

Sun Patch Framework

Sun Update Manager . updatemanager GUI version of smpatch
smpatch - CLI of updatemanager - analizyse / download /add

The following components requiere service plan:

Sun Update Web Application - Web Portal hosted by sun.com
faciliates the management of patches for 1 or more systems

Sun Update Connection Proxy - Creates a local patch server

patchadd/patchrm - CLI based tools - non Sun Update Connection tools

download patch manually from sunsolve.sun.com and apply

3. Solaris Management Console SMC

##### SOLARIS PATCH MANAGEMENT VIA CLI — using smpatch ####

1. smpatch analyse - determines required patches
2. smpatch update - apply ALL updates based on analysis
3. smpatch analyse -x idlist=patch_list.txt
4. smpatch analyse -i patch_id -i patch_id2
5. smpatch download -i 121309-03
6. smpatch download -x idlist=patch_list.txt
7. smpatch add -i 121309-03

POOL PATCHES
/var/sadm/spool

#### Patchadd ###
Permits adding/removing/listing signed/unsigned patches

Note: in order to apply signed patches, use keytool to export and the import into patchadd

Syntax: patchadd directory_to_patch

X forwarding with ssh -X and XMing

Redirecting X over tcp / udp and using something like “XWin -query machine” is insecure. So are most VNC solutions. You can use X forwarding over ssh:


% ssh -X -C -c blowfish MachineHostname xterm

(Blowfish encryption tends to be a bit faster, and -C enforces compression, though it should be enabled by default. If you have issues with X forwarding, check your /etc/ssh/sshd_config for “X11Forwarding yes” and “ForwardX11 yes“).

Sometimes you _have_ to run a graphical interface on a UNIX machine, and do so from your Windows box. Examples include the Oracle Installer and some other Java applications.

While you could install Cygwin to provide you with an XOrg server implementation, Cygwin tends to be quite big. A lighter and faster option would be to use XMing. It’s small, fast and just works. Just fire up XWin, and it will listen on 0:0 by default.

Now you can use “ssh -X machineIP xterm” and it will start a remote XTerm right on your machine. Or if you use putty, make sure you redirect X:

Now run your favorite GUI application.

Patching the Solaris / BOX / Patch Management

Steps:

1. Register the system with Sun in order to use Update Manager and other tools. i.e. Sun Update Connection

Applications -> Utilities -> UpdateManager

# which updatemanager
/usr/bin/updatemanager

Registration without subscription key limits updates to the following:

a. Security updates for sotware
b. applicable hardware updates ( firmware )

Note: Sun Update Connection features are unavailable without a service plan ( provides subscription key )

Note> Update Manager defaults to downloading signed patches

… Next Patch MGMT 2 …

Solaris DVD Installer PKG MGMT.

Setup NFS on installation server to share DVD contents:

share -F nfs -o ro,anon=0 /export/home/Solaris10

[ssybl2:~]# cat /etc/dfs/dfstab

# Place share(1M) commands here for automatic execution
# on entering init state 3.
#
# Issue the command ’svcadm enable network/nfs/server’ to
# run the NFS daemon processes and the share commands, after adding
# the very first entry to this file.
#
# share [-F fstype] [ -o options] [-d ""] [resource]
# .e.g,
# share -F nfs -o rw=engineering -d “home dirs” /export/home2
share -F nfs -o ro,anon=0 /export/home/install/Solaris_10/Tools/Boot


To re-read dfstab :
exportfs -a

Mount remote server’s installation NFS share point

mount -F nfs servidor:/mnt /export/home/solaris10ISO

#### installer ####

prodreg - application to manage add/remove programs on Solaris BOX

### Shell - Based package management tools ###

pkginfo - display software package information
pkgadd - transfer software packages to the system
pkgrm - remove a package from the system
pkgchk - check package installation accuracy

1. pkginfo - dumps to STDOUT (screen/terminal) all installed pakacges
pkginfo returns - category, package name, description

2. pkginfo -l [package_name] - detailed package listing

3. pkginfo -x returns and extracted list of packages. abbreviation, name, arch.

4. pkginfo -q queries for a package and returns exit status ( 0 / 1 )

5. pkginfo -i - fully installed packages
pkginfo -p partially installed

### pkgchk ### integrity

1. pkgchk -v SUNWevolution - checks/lists files included with SUNWevolution

2. pkgchk -lp - determines which package vim belongs to

# pkgchk -lp /opt/csw/bin/vim
Pathname: /opt/csw/bin/vim
Type: regular file
Expected mode: 0755
Expected owner: root
Expected group: bin
Expected file size (bytes): 1791664
Expected sum(1) of contents: 53780
Expected last modification: Nov 12 23:25:27 2007
Referenced by the following packages:
CSWvim
Current status: installed

3. pkgchk -ap /opt/csw/bin/vim - audits the permissions on the file ‘vim’ ( exit status 0/1 )

4. pkgchk -fp - fix permissions on the file

5. pkgchk -cp /opt/csw/bim/vim sum check ( integrity of the file )

6. pkgchk -q - returns useable exit status

### pkgadd ### install programs

1. pkgadd -d package_name - install from current directory or spool directory /var/spool/pkg

2. pkgadd - this will install programs in the spool directory

Common Solaris Package Online Repositories:

1. www.sunfreeware.com
2. www.blastwave.org - blastwave.org/mirrors.php
3. www.sun.com

pkgadd -d nano
pkgadd -v nano
pkgadd -d URL

Note: when installing via HTTP, packaged MUST be in package stream form.

Use ‘pkgtrans’ to transform packaged to packaged stream format.

### pkgrm ### Package Remove

1. pkgrm package_name

www.sunfreeware.com

http://www.sunfreeware.com/indexsparc10.html

chkrootkit solaris

### ps ###


1. ps, ps -ef (includes all processes)
2. pgrep - searches process list for matching programms
3. pkill - searches process list for matching programs and kills them

4. pwdx 1064 what directory is running a process
5. prstat ( like top in linux )
6. prtdiag - display system diagnostic information

Currently running:

1. ps


[ssybl0:~]$ ps
PID TTY TIME CMD
1030 pts/2 0:00 bash
1034 pts/2 0:00 ps

All the programs
2. ps -ef


[ssybl0:~]$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 19:19:06 ? 0:20 sched
root 1 0 0 19:19:08 ? 0:00 /sbin/init
root 2 0 0 19:19:08 ? 0:00 pageout
root 3 0 0 19:19:08 ? 1:06 fsflush
daemon 310 1 0 19:19:32 ? 0:00 /usr/sbin/rpcbind
root 7 1 0 19:19:09 ? 0:08 /lib/svc/bin/svc.startd
root 9 1 0 19:19:09 ? 0:29 /lib/svc/bin/svc.configd
root 335 1 0 19:19:34 ? 0:02 /usr/lib/inet/inetd start
daemon 315 1 0 19:19:32 ? 0:00 /usr/lib/nfs/statd
carlosap 968 965 0 20:07:00 ? 0:00 /usr/lib/ssh/sshd
root 366 364 0 19:19:34 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
root 118 1 0 19:19:23 ? 0:00 /usr/lib/ldoms/drd
smmsp 542 1 0 19:19:41 ? 0:00 /usr/lib/sendmail -Ac -q15m
root 364 1 0 19:19:34 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
daemon 316 1 0 19:19:32 ? 0:00 /usr/lib/nfs/nfs4cbd
daemon 117 1 0 19:19:23 ? 0:01 /usr/lib/crypto/kcfd
root 356 342 0 19:19:34 ? 0:00 /usr/lib/saf/ttymon
root 370 7 0 19:19:34 console 0:00 /usr/lib/saf/ttymon -g -d /dev/console -l console -m ldterm,ttcompat -h -p ssyb
daemon 321 1 0 19:19:33 ? 0:00 /usr/lib/nfs/lockd
root 159 1 0 19:19:23 ? 0:01 /usr/sbin/nscd
root 228 1 0 19:19:25 ? 0:00 /usr/sbin/cron
root 358 1 0 19:19:34 ? 0:00 /usr/lib/utmpd
root 157 1 0 19:19:23 ? 0:00 /usr/lib/sysevent/syseventd
root 170 1 0 19:19:24 ? 0:01 /usr/lib/picl/picld
daemon 317 1 0 19:19:32 ? 0:00 /usr/lib/nfs/nfsmapid
root 365 364 0 19:19:34 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
root 220 1 0 19:19:25 ? 0:00 /usr/lib/efcode/sparcv9/efdaemon
root 342 7 0 19:19:34 ? 0:00 /usr/lib/saf/sac -t 300
carlosap 1030 1028 0 21:05:53 pts/2 0:00 -bash
root 453 1 0 19:19:40 ? 0:00 /usr/sbin/vold -f /etc/vold.conf
root 482 1 0 19:19:41 ? 0:00 /usr/sbin/syslogd
root 444 1 0 19:19:40 ? 0:00 /usr/lib/autofs/automountd
root 445 444 0 19:19:40 ? 0:00 /usr/lib/autofs/automountd
noaccess 837 1 0 19:19:55 ? 1:38 /opt/se6000/java_1.5.0/usr/java/bin/java -server -Xms64m -Xmx512m -XX:+Backgrou
root 562 1 0 19:19:42 ? 0:00 /usr/lib/snmp/snmpdx -y -c /etc/snmp/conf
root 540 1 0 19:19:41 ? 0:00 /usr/lib/sendmail -bd -q15m
root 559 1 0 19:19:42 ? 0:00 /usr/sfw/sbin/snmpd
root 502 1 0 19:19:41 ? 0:05 /opt/SUNWsefms/sbin/./wrapper-solaris-sparc-32 /opt/SUNWsefms/sbin/../System/wr
root 965 523 0 20:06:57 ? 0:00 /usr/lib/ssh/sshd
root 523 1 0 19:19:41 ? 0:00 /usr/lib/ssh/sshd
carlosap 1042 1030 0 21:31:18 pts/2 0:00 ps -ef
root 532 502 0 19:19:41 ? 1:13 /opt/se6000/java_1.5.0/usr/java//bin/java -DSUNWsefms=../ -Xms8m -Xmx128m -Djav
carlosap 1028 1025 0 21:05:53 ? 0:00 /usr/lib/ssh/sshd
root 548 1 0 19:19:41 ? 0:04 /usr/lib/fm/fmd/fmd
root 580 1 0 19:19:42 ? 0:00 /usr/lib/dmi/dmispd
root 584 1 0 19:19:42 ? 0:00 /usr/lib/dmi/snmpXdmid -s ssybl0.ssy.gob.mx
root 620 1 0 19:19:45 ? 0:06 /opt/SMgr/agent/jre/bin/java -classpath /opt/SMgr/agent/SMagent.jar devmgr.laun
root 1025 523 0 21:05:50 ? 0:00 /usr/lib/ssh/sshd
root 975 970 0 20:09:55 pts/1 0:00 -bash
carlosap 970 968 0 20:07:00 pts/1 0:00 -bash
root 666 1 0 19:19:46 ? 0:00 /usr/dt/bin/dtlogin -daemon

Search all instances of sshd
pgrep sshd the same effect like ps -ef |grep sshd


[ssybl0:~]# pgrep sshd
968
965
523
1028
1025


[ssybl0:~/docs]$ prtdiag
System Configuration: Sun Microsystems sun4v Sun Blade T6300 Server Module
Memory size: 3968 Megabytes

================================ Virtual CPUs ================================

CPU ID Frequency Implementation Status
—— ——— ———————- ——-
0 1000 MHz SUNW,UltraSPARC-T1 on-line
1 1000 MHz SUNW,UltraSPARC-T1 on-line
2 1000 MHz SUNW,UltraSPARC-T1 on-line
3 1000 MHz SUNW,UltraSPARC-T1 on-line
4 1000 MHz SUNW,UltraSPARC-T1 on-line
5 1000 MHz SUNW,UltraSPARC-T1 on-line
6 1000 MHz SUNW,UltraSPARC-T1 on-line
7 1000 MHz SUNW,UltraSPARC-T1 on-line
8 1000 MHz SUNW,UltraSPARC-T1 on-line
9 1000 MHz SUNW,UltraSPARC-T1 on-line
10 1000 MHz SUNW,UltraSPARC-T1 on-line
11 1000 MHz SUNW,UltraSPARC-T1 on-line
12 1000 MHz SUNW,UltraSPARC-T1 on-line
13 1000 MHz SUNW,UltraSPARC-T1 on-line
14 1000 MHz SUNW,UltraSPARC-T1 on-line
15 1000 MHz SUNW,UltraSPARC-T1 on-line
16 1000 MHz SUNW,UltraSPARC-T1 on-line
17 1000 MHz SUNW,UltraSPARC-T1 on-line
18 1000 MHz SUNW,UltraSPARC-T1 on-line
19 1000 MHz SUNW,UltraSPARC-T1 on-line
20 1000 MHz SUNW,UltraSPARC-T1 on-line
21 1000 MHz SUNW,UltraSPARC-T1 on-line
22 1000 MHz SUNW,UltraSPARC-T1 on-line
23 1000 MHz SUNW,UltraSPARC-T1 on-line

======================= Physical Memory Configuration ========================
Segment Table:
————————————————————–
Base Segment Interleave Bank Contains
Address Size Factor Size Modules
————————————————————–
0×0 4 GB 4 2 GB MB/CMP0/CH0/R0/D0
MB/CMP0/CH0/R0/D1
2 GB MB/CMP0/CH3/R0/D0
MB/CMP0/CH3/R0/D1

========================= IO Configuration =========================

IO
Location Type Slot Path Name Model
———– —– —- ——————————————— ————————- ———
MB/NET0 PCIE MB /pci@780/pci@0/pci@1/network@0 network-pciex8086,105e
MB/NET1 PCIE MB /pci@780/pci@0/pci@1/network@0,1 network-pciex8086,105e
MB/PCI-EM0 PCIE 0 /pci@780/pci@0/pci@9/SUNW,emlxs@0 SUNW,emlxs-pci10df,fc20 LPem11002+
MB/PCI-EM0 PCIE 0 /pci@780/pci@0/pci@9/SUNW,emlxs@0,1 SUNW,emlxs-pci10df,fc20 LPem11002+
MB/USB0 PCIE MB /pci@7c0/pci@0/pci@1/pci@0/usb@0 usb-pciclass,0c0310
MB/USB1 PCIE MB /pci@7c0/pci@0/pci@1/pci@0/usb@0,1 usb-pciclass,0c0310
MB/USB2 PCIE MB /pci@7c0/pci@0/pci@1/pci@0/usb@0,2 usb-pciclass,0c0320
MB/SAS-SATA PCIE MB /pci@7c0/pci@0/pci@2/scsi@0 scsi-pciex1000,58 LSI,1068E

============================ Environmental Status ============================
Fan sensors:
All fan sensors are OK.

Temperature sensors:
All temperature sensors are OK.

Current sensors:
All current sensors are OK.

Voltage sensors:
All voltage sensors are OK.

============================ FRU Status ============================
All FRUs are enabled.


…. NEXt PACKAGE MGMT ……