Editing
Solaris 10 System Administration Part I
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Solaris 10 OS Directory Hierarchy == === File systems === Unix File System (UFS) is the default file system Directory starts with root directory (/) Solaris 10 OS includes alternate file system called zettabyte file system (ZFS) Logically all directories fall below root directory (/) Physically directories can be located on one or spread over multiple file systems <insert graphics to show this> Refer to filesystem man page for more information on file system organization. <code>$ man -s 5 filesystem</code> Important directories <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>Directory</td> <td>Notes</td> </tr> <tr> <td>/</td> <td>root of file system</td> </tr> <tr> <td>/bin</td> <td>symbolic link to /usr/bin & location for binary files of standard system commands</td> </tr> <tr> <td>/dev</td> <td>primary directory for logical device names & contents of directory are symbolic links to device files in /devices directory</td> </tr> <tr> <td>/etc</td> <td>directory holds host-specific config files & databases for system administration</td> </tr> <tr> <td>/export</td> <td>default directory for commonly shared file systems (like user home directories)</td> </tr> <tr> <td>/home</td> <td>default directory or mount point for user home directories</td> </tr> <tr> <td>/kernel</td> <td></td> </tr> <tr> <td>/lib</td> <td></td> </tr> <tr> <td>/mnt</td> <td></td> </tr> <tr> <td>/opt</td> <td></td> </tr> <tr> <td>/platform</td> <td></td> </tr> <tr> <td>/sbin</td> <td></td> </tr> <tr> <td>/usr</td> <td></td> </tr> <tr> <td>/var</td> <td></td> </tr> </table> ==== Important in-memory system directories ==== <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>/dev/fd</td> <td></td> </tr> <tr> <td>/devices</td> <td></td> </tr> <tr> <td>/etc/mnttab</td> <td></td> </tr> <tr> <td>/etc/svc/volatile</td> <td></td> </tr> <tr> <td>/proc</td> <td></td> </tr> <tr> <td>/system/contract</td> <td></td> </tr> <tr> <td>/system/object</td> <td></td> </tr> <tr> <td>/tmp</td> <td>directory for temporary files (cleared during boot sequence)</td> </tr> <tr> <td>/var/run</td> <td></td> </tr> </table> ==== Subdirectories of note under /dev ==== <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>/dev/dsk</td> <td>block disk devices</td> </tr> <tr> <td>/dev/fd</td> <td>file descriptors</td> </tr> <tr> <td>/dev/md</td> <td>logical volume management metadisk drives</td> </tr> <tr> <td>/dev/pts</td> <td>pseudo terminal devices</td> </tr> <tr> <td>/dev/rdsk</td> <td>raw disk devices</td> </tr> <tr> <td>/dev/rmt</td> <td>raw magnetic devices</td> </tr> <tr> <td>/dev/term</td> <td>serial devices</td> </tr> </table> ==== Important subdirectories under /etc ==== <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>/etc/acct</td> <td>config info for accounting system</td> </tr> <tr> <td>/etc/cron.d</td> <td>config info for cron utility</td> </tr> <tr> <td>/etc/default</td> <td>default info for various programs</td> </tr> <tr> <td>/etc/inet</td> <td>config files for network services</td> </tr> <tr> <td>/etc/init.d</td> <td>scripts for starting & stopping services</td> </tr> <tr> <td>/etc/lib</td> <td></td> </tr> <tr> <td>/etc/lp</td> <td>config info for printer subsystem</td> </tr> <tr> <td>/etc/mail</td> <td>config info for mail subsystem</td> </tr> <tr> <td>/etc/nfs</td> <td>config file for NFS server logging</td> </tr> <tr> <td>/etc/opt</td> <td>config info for optional packages</td> </tr> <tr> <td>/etc/rc#.d</td> <td>legacy scripts that are executed when entering or leaving a specific run level</td> </tr> <tr> <td>/etc/security</td> <td>controls files for Role Based Access Control & security privileges</td> </tr> <tr> <td>/etc/skel</td> <td>default shell initialization files for new users</td> </tr> <tr> <td>/etc/svc</td> <td>Service Management Facility database & log files</td> </tr> </table> ==== Important subdirectories of /usr ==== <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>/usr/bin</td> <td>standard system commands</td> </tr> <tr> <td>/usr/ccs</td> <td>C-compilation programs & libraries</td> </tr> <tr> <td>/usr/demo</td> <td>demo programs & data</td> </tr> <tr> <td>/usr/dt</td> <td>Java Desktop System (JDS) software directory or mount point</td> </tr> <tr> <td>/usr/include</td> <td>Header files</td> </tr> <tr> <td>/usr/jdk</td> <td>directory contains Java technology programs & libraries</td> </tr> <tr> <td>/usr/kernel</td> <td>loadable kernel modules not generally required during boot process</td> </tr> <tr> <td>/usr/lib</td> <td>architecture-dependent databases, libraries, & binaries that are not invoked directly by user</td> </tr> <tr> <td>/usr/opt</td> <td>config info for optional packages</td> </tr> <tr> <td>/usr/sbin</td> <td>sys admin coomands</td> </tr> <tr> <td>/usr/spool</td> <td>symbolic link to /var/spool directory</td> </tr> </table> ==== Important subdirectories of /var ==== <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>/var/adm</td> <td>log files for syslog, system accounting, etc</td> </tr> <tr> <td>/var/crash</td> <td>crash dump storage</td> </tr> <tr> <td>/var/spool</td> <td>spool files storage</td> </tr> <tr> <td>/var/svc</td> <td>Service Management Facility control files and logs</td> </tr> <tr> <td>/var/tmp</td> <td>long term storage of temp files (survives reboot)</td> </tr> </table> === File components === Generally a file name is associated with an inode & an inode provides access to data blocks. <insert figure of relationship> ==== file names ==== File names are objects frequently used to manage files. A file must have a name that is associated with an inode. ==== inodes ==== Inodes are objects that Solaris OS uses to maintain info about a file. In general an inode contains: # file info = file owner, permissions, & size # pointers to data blocks associated with file content inodes are numbered & each file system contains its own inode list At UFS creation a new inode list is created ==== data blocks ==== data blocks are units of disk space that store data Regular files, directories, & symbolic links make use of data blocks Device files do not hold data therefore do not use data blocks '''ZFS uses the following data structures:''' dnode data structure: the data structure contains pointers to data blocks znode data structure: this data structure contains info about file (owner, permissions, & size) Dnode & znode data structures are called metadata & stored dynamically by ZFS. ZFS implements ZFS POSIX layer (ZPL) which is a primary interface for ZFS. ZPL allows commands you use with UFS to work with ZFS. ZFS emulates UFS inode number mechanism === Identifying file types === Solaris has four main file types: <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>regular or ordinary files</td> <td>store one or more types of data</td> </tr> <tr> <td>directories</td> <td>store one or more types of data</td> </tr> <tr> <td>symbolic links</td> <td>store one or more types of data</td> </tr> <tr> <td>device files</td> <td>does not store data</td> </tr> </table> Use ls command with -l option to distinguish different file types The first character of each line indicates file type <insert image of ls -l output with dictionary> <table style="text-align: left; width: 50%;" border="1" cellpadding="2" cellspacing="0"> <tr> <td>-</td> <td>regular files</td> </tr> <tr> <td>d</td> <td>directories</td> </tr> <tr> <td>l</td> <td>symbolic links</td> </tr> <tr> <td>b</td> <td>block-special device files</td> </tr> <tr> <td>c</td> <td>character-special device files</td> </tr> </table> Examples on v240: <pre> # cd /etc # ls -l total 650 lrwxrwxrwx 1 root root 14 May 3 15:34 TIMEZONE -> ./default/init drwxr-xr-x 6 root other 512 May 3 16:15 X11 drwxr-xr-x 2 adm adm 512 May 3 16:19 acct -rw-r--r-- 1 root sys 253 Aug 6 2010 aggregation.conf lrwxrwxrwx 1 root root 14 May 3 16:03 aliases -> ./mail/aliases drwxr-xr-x 7 root bin 512 May 3 16:11 apache drwxr-xr-x 2 root bin 512 May 3 15:54 apache2 *****output truncated***** </pre> <pre> # pwd /devices/pci@1c,600000/scsi@2 # ls -l total 8 drwxr-xr-x 2 root sys 512 May 3 16:25 sd@0,0 brw-r----- 1 root sys 32, 0 Jul 7 13:54 sd@0,0:a crw-r----- 1 root sys 32, 0 Jul 14 16:50 sd@0,0:a,raw </pre> ==== directories ==== directories only store information on file name to inode number relationships A directory contains data for files that are logically located within directory ==== Regular files ==== Most common file types found in Solaris are regular files. Regular files can store different types of data including ASCII text or binary data. ==== Symbolic links ==== a symbolic link is a file that points to another file & contain only one type of data a symbolic link contains the path name of the file to which it points & the file can be located on other file systems the size of a symbolic link always matches the number of characters in the path name it contains Example: after the '->' there are 19 characters & the 19 before May is the file size. <pre> # ls -l /etc/prtvtoc lrwxrwxrwx 1 root root 19 May 3 15:34 prtvtoc -> ../usr/sbin/prtvtoc </pre> symbolic links can point to regular files, directories, other symbolic links, & device files. symbolic links can be absolute or relative path names ===== ln command ===== ln command with -s option creates a symbolic link <insert example of creating symbolic link> <insert picture of relationship between link & file> ==== device files ==== device file provides access to a device When using long listing on file the size field is populated by two numbers separated by comma The two numbers are called major & minor device numbers major device # identifies the specific device driver required to access device minor device # identifies specific unit of the type that the device driver controls Long listing: <pre>bash-3.00$ ls -l | grep pci drwxr-xr-x 4 root sys 512 May 3 16:25 pci@1c,600000 crw------- 1 root sys 109, 767 Jul 14 16:50 pci@1c,600000:devctl crw------- 1 root sys 109, 764 Jul 14 16:50 pci@1c,600000:intr crw------- 1 root sys 109, 765 Jul 14 16:50 pci@1c,600000:reg drwxr-xr-x 5 root sys 512 May 3 16:25 pci@1d,700000 crw------- 1 root sys 109, 1023 Jul 14 16:50 pci@1d,700000:devctl crw------- 1 root sys 109, 1020 Jul 14 16:50 pci@1d,700000:intr crw------- 1 root sys 109, 1021 Jul 14 16:50 pci@1d,700000:reg drwxr-xr-x 6 root sys 512 May 3 16:25 pci@1e,600000 crw------- 1 root sys 109, 511 Jul 14 16:50 pci@1e,600000:devctl crw------- 1 root sys 109, 508 Jul 14 16:50 pci@1e,600000:intr crw------- 1 root sys 109, 509 Jul 14 16:50 pci@1e,600000:reg drwxr-xr-x 4 root sys 512 May 3 16:25 pci@1f,700000 crw------- 1 root sys 109, 255 Jul 14 16:50 pci@1f,700000:devctl crw------- 1 root sys 109, 252 Jul 14 16:50 pci@1f,700000:intr crw------- 1 root sys 109, 253 Jul 14 16:50 pci@1f,700000:reg</pre> '''File pci@1c,600000:devctl refers to major device # 109 & minor device # 767''' You can also use the <code>file</code> command: <pre>bash-3.00$ file pci@1c,600000:devctl pci@1c,600000:devctl: character special (109/767)</pre> Use <code>devfsadm</code> command to create new device files A relationship exists between device file & device it controls. Major & minor device #s contained in inode establish relationship <image showing relationship from above example> Verify device driver is available as kernel module: <pre>bash-3.00# modinfo -w | grep -w scsi 22 1313a40 122a8 - 1 scsi (SCSI Bus Utility Routines) bash-3.00# modinfo -c | grep -w scsi 22 1 scsi LOADED/INSTALLED bash-3.00# modinfo -w | grep -w iscsi 96 7b600000 328c8 279 1 iscsi (Sun iSCSI Initiator v20100714-0) bash-3.00# modinfo -c | grep -w iscsi 96 1 iscsi LOADED/INSTALLED</pre> device files are categorized as character-special [character or raw devices] or block-special devices [block devices] device files in each category interact with devices differently ===== character-special device files ===== File type of "c" is character-special device file & data is accessed as a data stream <pre>crw------- 1 root sys 109, 767 Jul 14 16:50 pci@1c,600000:devctl</pre> Result of <code>file</code> command: <pre>bash-3.00# file pci@1c,600000:devctl pci@1c,600000:devctl: character special (109/767)</pre> ===== block-special device files ===== File type of "b" is a block-special device file & for disk devices, block-special device files call for I/O operations based on a defined block size Block size depends on particular device file <example of long listing of block file> data transferred between process & block-special device is first stored in kernel-managed memory-based cache block devices allow random seeks to be performed [character devices do not] ==== hard links ==== hard link is association between file name & an inode inode keeps count # of file names associated with it (hard links) output of long listing will show '''link count''' or total # of hard links to a file <pre>bash-3.00# ls -l mnttab -r--r--r-- 5 root root 1539 Jul 7 13:55 mnttab </pre> /etc/mnttab file has 5 link counts or hard links [between file permissions & owner] ===== creating new hard links ===== <code>ln</code> command creates new hard links to regular files <pre>$ ln file5 file6 $ ln file5 file7 $ ln file7 file8 $ ls -il total 64868 54 -rw------- 1 paul labnet 555969 May 6 13:52 file.7z 55 -rw-r--r-- 1 paul labnet 53 May 6 13:23 file1.gz 39 -rw-r--r-- 1 paul labnet 739704 May 6 13:42 file2.gz 41 -rw-r--r-- 1 paul labnet 0 May 5 12:35 file3 50 -rw-r--r-- 1 paul labnet 3976616 May 6 13:37 file4 52 -rw-r--r-- 4 paul labnet 3976541 May 6 13:43 file5 52 -rw-r--r-- 4 paul labnet 3976541 May 6 13:43 file6 52 -rw-r--r-- 4 paul labnet 3976541 May 6 13:43 file7 52 -rw-r--r-- 4 paul labnet 3976541 May 6 13:43 file8 53 -rw-r--r-- 1 paul labnet 11934208 May 6 13:48 filetar.tar 42 drwxr-xr-x 2 paul labnet 512 May 5 12:45 subdir1 $</pre> The <code>ln</code> command created files 6-8. Now files 5-8 refer to same inode [52]. Notice link count is now 4 for each of the files. You must use -i option with <code>ls</code> command to view inodes Use find command with -inum option to find files with same inode <pre>$ find . -inum 52 ./file6 ./file7 ./file5 ./file8</pre> <insert image showing file name to inode association> ===== deleting hard links ===== delete files normally & link count will decrease automatically <pre>$ rm file8 $ ls -li total 57076 54 -rw------- 1 paul labnet 555969 May 6 13:52 file.7z 55 -rw-r--r-- 1 paul labnet 53 May 6 13:23 file1.gz 39 -rw-r--r-- 1 paul labnet 739704 May 6 13:42 file2.gz 41 -rw-r--r-- 1 paul labnet 0 May 5 12:35 file3 50 -rw-r--r-- 1 paul labnet 3976616 May 6 13:37 file4 52 -rw-r--r-- 3 paul labnet 3976541 May 6 13:43 file5 52 -rw-r--r-- 3 paul labnet 3976541 May 6 13:43 file6 52 -rw-r--r-- 3 paul labnet 3976541 May 6 13:43 file7 53 -rw-r--r-- 1 paul labnet 11934208 May 6 13:48 filetar.tar 42 drwxr-xr-x 2 paul labnet 512 May 5 12:45 subdir1 $</pre> Once all files with same inode are deleted the inode will be deleted ==== Examples ==== Find files that match inode on same file system <pre># ls -l /etc/init.d/apache -rwxr--r-- 6 root sys 2452 Jun 23 2010 /etc/init.d/apache</pre> /etc/init.d/apache file has a 6 link count <pre># ls -i /etc/init.d/apache 2955 /etc/init.d/apache</pre> /etc/init.d/apache inode is 2955 <pre># find /etc -inum 2955 -exec ls -i {} \; 2955 /etc/init.d/apache 2955 /etc/rc0.d/K16apache 2955 /etc/rc1.d/K16apache 2955 /etc/rc2.d/K16apache 2955 /etc/rc3.d/S50apache 2955 /etc/rcS.d/K16apache</pre> The <code>find</code> command with -inum option allows you to search by inode. Now I know which files are pointing to same location as /etc/init.d/apache
Summary:
Please note that all contributions to GotOpinion may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GotOpinion:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information