| Class | First bits | Address range | Subnet mask |
| Class A | 0 | 1.x.x.x ~ 127.x.x.x | 255.0.0.0 (/8) |
| Class B | 10 | 128.0.x.x ~ 191.255.x.x | 255.255.0.0 (/16) |
| Class C | 110 | 192.0.0.x ~ 223.255.255.x | 255.255.255.0 (/24) |
| Class D | 1110 | 224.0.0.0 ~ 239.255.255.255 | - |
| Class E | 1111 | 240.0.0.0 ~ 255.255.255.254 | - |
Saturday, February 15, 2014
IPv4 Address Classes
Though Classless Inter-Domain Routing (CIDR) and Variable-Length Subnet Mask (VLSM) are the order of today's IPv4 networking, classification of IPv4 address spaces into classes A, B, C, or D remains common. The following table shows the classes that were designated during the days of classful routing:
Saturday, January 4, 2014
Unix - Disk Management
Identifying the harddisks installed
- Listing all the disks and drives attached to the system
# camcontrol devlist (or, atacontrol list) at scbus2 target 0 lun 0 (ada0,pass0) at scbus3 target 0 lun 0 (cd0,pass1)
- Listing harddisks detected during the system bootup
# dmesg | grep ad ada0 at ata4 bus 0 scbus2 target 0 lun 0 ada0:
ATA-8 SATA 2.x device ada0: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes) ada0: 238418MB (488281250 512 byte sectors: 16H 63S/T 16383C) ada0: Previously was known as ad4 Trying to mount root from ufs:/dev/ada0p2 [rw]... - Listing harddisks and their partitions
# ls /dev | grep ad ad4 ad4p1 ad4p2 ad4p3 ada0 ada0p1 ada0p2 ada0p3
- Listing hardware level information of a harddisks
# diskinfo -c ada0 ada0 512 # sectorsize 250000000000 # mediasize in bytes (232G) 488281250 # mediasize in sectors 0 # stripesize 0 # stripeoffset 484406 # Cylinders according to firmware. 16 # Heads according to firmware. 63 # Sectors according to firmware. WD-WMAV12345678 # Disk ident. I/O command overhead: time to read 10MB block 0.124816 sec = 0.006 msec/sector time to read 20480 sectors 2.126440 sec = 0.104 msec/sector calculated command overhead = 0.098 msec/sector
- #fdisk ada0
******* Working on device /dev/ada0 ******* parameters extracted from in-core disklabel are: cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl) Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 238 (0xee),(EFI GPT) start 1, size 488397167 (238475 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 255/ sector 63
Identifying the harddisk partitions
- Identifying basic information about harddisk partitions
# gpart show => 34 488281183 ada0 GPT (232G) 34 128 1 freebsd-boot (64k) 162 478150528 2 freebsd-ufs (228G) 478150690 8388608 3 freebsd-swap (4.0G) 486539298 1741919 - free - (850M) - Displaying detailed information of harddisk partitions
# gpart list Geom name: ada0 modified: false state: OK fwheads: 16 fwsectors: 63 last: 488281216 first: 34 entries: 128 scheme: GPT Providers: 1. Name: ada0p1 Mediasize: 65536 (64k) Sectorsize: 512 Stripesize: 0 Stripeoffset: 17408 Mode: r0w0e0 rawuuid: 740aff84-9a1e-11e3-b778-002219173177 rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f label: (null) length: 65536 offset: 17408 type: freebsd-boot index: 1 end: 161 start: 34 2. Name: ada0p2 Mediasize: 244813070336 (228G) Sectorsize: 512 Stripesize: 0 Stripeoffset: 82944 Mode: r1w1e1 rawuuid: 740b80b0-9a1e-11e3-b778-002219173177 rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b label: (null) length: 244813070336 offset: 82944 type: freebsd-ufs index: 2 end: 478150689 start: 162 3. Name: ada0p3 Mediasize: 4294967296 (4.0G) Sectorsize: 512 Stripesize: 0 Stripeoffset: 17408 Mode: r1w1e0 rawuuid: 740eaebd-9a1e-11e3-b778-002219173177 rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b label: (null) length: 4294967296 offset: 244813153280 type: freebsd-swap index: 3 end: 486539297 start: 478150690 Consumers: 1. Name: ada0 Mediasize: 250000000000 (232G) Sectorsize: 512 Mode: r2w2e3
df -h Filesystem Size Used Avail Capacity Mounted on /dev/ada0p2 220G 7.6G 195G 4% / devfs 1.0k 1.0k 0B 100% /dev nfsServer:/home 435G 15G 420G 3% /usr/home
Mounting and unmounting external drives
For a USB memory stick,- # mount -t msdosfs /dev/da0s1 /tmp/usb
- # umount /tmp/usb
Note: Unix commands and file locations used here have been tested on FreeBSD systems.
Labels:
commands,
disk management,
mounting,
partitions,
Unix
Saturday, December 28, 2013
Unix - File Access Rights and Ownerships
File Attributes
#/$ ls -l /tmp drwxr-xr-x 4 vijay wheel 10 Apr 16 2010 testFolder -rw-r--r-- 2 vijay wheel 368884 Feb 13 2012 news.txt -rwx------ 2 vijay wheel 2687 Feb 13 2012 secret.txt -rwxr-xr-x 2 vijay wheel 11762 Nov 10 2011 code.c
Symbolic permissions
| Option | Letter | Represents |
| (who) | u | User |
| (who) | g | Group owner |
| (who) | o | Other |
| (who) | a | All (“world”) |
| (action) | + | Adding permissions |
| (action) | - | Removing permissions |
| (action) | = | Explicitly set permissions |
| (permissions) | r | Read |
| (permissions) | w | Write |
| (permissions) | x | Execute |
| (permissions) | t | Sticky bit |
| (permissions) | s | Set UID or GID |
To modify the access rights, modify the file attributes.
| # chmod 777 testfile | Allows access by File Owner, Group Members, and All-other-users. |
| # chmod –R 755 /tmp/test/ | -R affects access rights all the files and sub-folders in /tmp/test/ |
| # chmod go= testfile | Symbolic permission (who) (action) (permissions) |
| # chmod go-w,a+x testfile |
Extended file attributes
# getfacl testfile # setfacl -k testfile # setfacl -m u:trhodes:rwx,group:web:r--,o::--- testfile
setuid (4), setgid (2), and sticky (1) permissions
# chmod 4755 testfile=> File will always use permissions and the same user ID of who assigned it)
-rwsr-xr-x (x of owner is replaced with s)
# chmod 2755 testfile
=> File will always use permissions of the group (of the group to assigner belongs)
-rwxr-sr-x (x of group is replaced with s)
# chmod 1777 testdir
=> Allows file deletion only by the owner (make sense for directories)
drwxrwxrwt (x of all-users is replaced with t)
File flags (FreeBSD specific)
File flags are used to prevent accidental editing/removal of files (non-directory) by the root and/or the file owners in FreeBSD.To view them:
# ls -lo /etc | grep rc.conf -rw-r--r-- 1 root wheel schg 1897 Mar 1 2012 rc.conf
In the above case, the secret tool 'schg' makes the file rc.conf unmodifiable even by the superuser (root) without removing the flag. This feature provides one additional level of protection for important files from accidental modifications by the system administrator(s).
Super user (root) only assignable flags
- sappnd, sappend : sets the system append-only flag (by super-user only)
- sunlnk, sunlink : sets the system undeletable flag (by super-user only)
- schg, schange, simmutable : sets the system immutable flag (by super-user only)
Normal user assignable flags
- uappnd, uappend : sets the user append-only flag (by owner or super-user only)
- uunlnk, uunlink : sets the user undeletable flag (by owner or super-user only)
- uchg, uchange, uimmutable : sets the user immutable flag (by owner or super-user only)
To edit these flags chflags command is used. For example:
# chflags sunlink testfile => Undeletable # chflags nosunlink testfile # chflags schg httpd.conf => System immutable (no change) flag # chflags noschg httpd.conf
File Ownership
To change the file ownership:# chown –R vijay:wheel *
Note: Unix commands and file locations used here have been tested on FreeBSD systems.
Wednesday, September 11, 2013
Unix - DHCP
After addition of a new network interface card (NIC) in a DHCP client and/or changing cable from one port to another, client might not establish the network connectivity. In such cases first check whether the active NIC's MAC address is there on DHCP server's database. If it is not there then add the MAC address and restart the server. If the problem persists, refresh the DHCP client as below:
# service netif restart
# dhclient eth1
# service netif restart
# dhclient eth1
Subscribe to:
Posts (Atom)