- Let's create a hard link of new directory as the source file
# mkdir /usr/test
- Let's create a symbolic link
# ln -s /usr/test/ /test ( # ln –s sourceFile symbolicLinkFile )
-
# ls –al /
…
lrwxr-xr-x 1 root wheel 10 Sep 25 11:18 test -> /usr/test/
…
-
# touch /usr/test/sample.txt
-
# ls /test
sample.txt
Note: sample.txt IS listed.
-
# ls -al /test
lrwxr-xr-x 1 root wheel 10 Sep 25 11:18 /test -> /usr/test/
Note: sample.txt IS NOT listed during detailed listing.
-
# ls -al /usr/test/
total 6
drwxr-xr-x 2 root wheel 512 Sep 25 11:21 .
drwxr-xr-x 18 root wheel 512 Sep 25 11:18 ..
-rwxr-xr-x 1 root wheel 61 Sep 25 11:22 sample.txt
-
# touch /test/sample2.txt
-
# ls -al /test
lrwxr-xr-x 1 root wheel 10 Sep 25 11:18 /test -> /usr/test/
Note: sample2.txt is NOT listed either.
-
# ls /test
sample.txt sample2.txt
-
# rm /test
Note: Symbolic link is deleted without any complain about files within directory
-
# ls /usr/test/
sample.txt sample2.txt
-
# rm /usr/test
rm: /usr/test: is a directory
Sunday, August 24, 2014
Unix - Symbolic links
A symbolic link or soft link is very much like a shortcut in Windows. Unlike a hard link, a symbolic link does not contain the data in the target file, and instead points to another file in the system.
Monday, June 23, 2014
Unix - Z File System (ZFS)
The Z file system (ZFS) developed by Sun Microsystems is a feature rich file system for server solutions. It is designed for high storage volumes, mirror and RAID options for redundancy, data snapshots, integrity checking, and automatic repairs.
Here are some ZFS troubleshooting commands and typical outputs:
Here are some ZFS troubleshooting commands and typical outputs:
- # zpool status
pool: zroot state: ONLINE scan: resilvered 30.6M in 0h0m with 0 errors on Sep 16 10:18:02 2013 config: NAME STATE READ WRITE CKSUM zroot ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 gpt/disk0 ONLINE 0 0 0 gpt/disk1 ONLINE 0 0 3 errors: No known data errors
- # zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT zroot 228G 124G 104G 54% 1.00x ONLINE -
- # zfs list
NAME USED AVAIL REFER MOUNTPOINT zroot 31.8G 417G 31K /zroot zroot/ROOT 3.38G 417G 3.38G / zroot/scratch 4.94G 417G 4.94G /scratch zroot/tmp 58.9M 417G 58.9M /tmp zroot/usr 21.0G 417G 31K /usr zroot/usr/home 17.9G 417G 17.9G /usr/home zroot/usr/local 813M 417G 813M /usr/local zroot/usr/obj 997M 417G 997M /usr/obj zroot/usr/ports 965M 417G 896M /usr/ports zroot/usr/ports/distfiles 67.6M 417G 67.6M /usr/ports/distfiles zroot/usr/ports/packages 1.30M 417G 1.30M /usr/ports/packages zroot/usr/src 359M 417G 359M /usr/src zroot/var 2.46G 417G 109M /var zroot/var/crash 2.15G 417G 2.15G /var/crash zroot/var/db 206M 417G 204M /var/db zroot/var/db/pkg 1.90M 417G 1.90M /var/db/pkg zroot/var/empty 31K 417G 31K /var/empty zroot/var/log 706K 417G 706K /var/log zroot/var/mail 59.5K 417G 59.5K /var/mail zroot/var/run 56.5K 417G 56.5K /var/run zroot/var/tmp 1.79M 417G 1.79M /var/tmp
- # ls -l /etc/zfs
total 1 -rw------- 1 root wheel 181 Jun 10 12:59 exports
-
# ls -l /boot/zfs /boot/zfsboot /boot/zfsloader
-r--r--r-- 1 root wheel 66048 Dec 4 2012 /boot/zfsboot -r-xr-xr-x 1 root wheel 303104 Oct 16 2013 /boot/zfsloader /boot/zfs: total 3 -rw-r--r-- 1 root wheel 1588 Sep 13 2013 zpool.cache
-
# ls -l /boot/gptboot /boot/gptzfsboot
-r--r--r-- 1 root wheel 16723 Dec 4 2012 /boot/gptboot -r--r--r-- 1 root wheel 43443 Dec 4 2012 /boot/gptzfsboot
Thursday, June 12, 2014
Unix - Hardware Timer Selection
- To find the timer counter being used by the computer:
myhost# sysctl kern.timecounter.hardware
kern.timecounter.hardware: HPET - List of available timers:
myhost# sysctl kern.timecounter.choice
kern.timecounter.choice: TSC(-100) HPET(900) - Selecting the timer of your choice:
myhost# sysctl kern.timecounter.hardware=TSC
Note: This selection does not persist after a reboot. To make this change persistent add the following line to the file /etc/sysctl.conf:
sysctl kern.timecounter.hardware=HPET
The integer value within brackets defines the quality of the time counter compared to others. A negative value means this time counter is broken and should not be used.
Saturday, May 31, 2014
Network Troubleshooting Commands
The following are the basic commands that helps to locate network issues. To open the command line interface or consoles:
* Ubuntu : 'Ctrl + Alt + T'
* Windows Systems : 'Window key + R' --> type 'cmd' and click 'OK/Run'
ifconfig / ipconfig
It is generally the very first to check whether the computer's network interface has got a valid IP address to establish communication with other devices in the network. MAC (physical) address of the network can also be found using these commands.
On Unix based systems,
e.g.1: ifconfig ==> Displays all the network interfaces, such as Ethernet and Loopback, MAC addresses, IP addresses, and subnet masks. Depending on the flavour of Unix and type of interface, some additional details such as number of packets transmitted and received, errors, active/disabled status, and size of the maximum transmittable unit (MTU) can also be found.
e.g.2: ifconfig eth0 down ==> Disables the Ethernet interface 'eth0'. Super user (root) only.
e.g.3: ifconfig eth0 up ==> Enables the Ethernet interface 'eth0'. Super user (root) only.
e.g.4: ifconfig eth0 192.168.1.1 netmask 255.255.255.0 ==> Assigns IP address and netmask manually. Super user (root) only.
On Windows systems,
e.g.1: ipconfig ==> Displays the IP address, netmask, and default gateway of all the network interfaces.
e.g.2: ipconfig /all ==> Displays more information about the network interfaces, including MAC address, DHCP status, and DNS servers used.
e.g.3: ipconfig /renew ==> Re-establishes TCP/IP connections on all network adapters and refreshes IP address with the DHCP server.
e.g.4: ipconfig /flushdns ==> Flushes the DNS cache stored locally (URL to IP address conversion)
ping
It is the basic command to check network reachability based on echos received from a network interface. It works in both Unix and Windows systems. However, command switches for a given additional option, such continuous ping, may vary.
On both Unix and Windows based systems,
e.g.1: ping 127.0.0.1 ==> reveals whether the IP protocol is up on you own computer (localhost). On Unix, continuously sends echo requests until terminated with 'Ctrl + C'.
e.g.2: ping www.yahoo.com ==> shows whether you can reach yahoo.com's server over the internet
On Windows,
e.g.1: ping -t www.google.com ==> On windows, continuously sends echo requests until terminated with 'Ctrl + C'.
Note:
traceroute / tracert
A command to identify the hops in the network, and in case of failures the output indicates the intermediate hops which packets travel successfully.
On Unix based systems,
e.g.1: traceroute www.yahoo.com ==> Names of hops along the network path and time taken to receive an echo response from them
On Windows,
e.g.1: tracert www.yahoo.com ==> Names of hops along the network path and time taken to receive an echo response from them
nslookup
Returns the corresponding IP address for a given URL (also vice-versa).
On both Unix and Windows based systems,
e.g.1: nslookup www.yahoo.com
netstat
A command to visualize the details of the ongoing network communication.
On both Unix and Windows based systems,
e.g.1: netstat ==> Details of all the established TCP connections
e.g.2: netstat -r ==> The routing table of your computer, including the default route and gateway details.
arp
Displays the IP address to MAC address conversion, and vice versa.
e.g.1: arp -a ==> Displays all the IP addresses and corresponding MAC addresses of the known network interfaces in the local broadcast domain
hostname
Gives the name assigned to your computer.
e.g.1: hostname ==> Hostname of your system
whoami / set U
Reveals the username currently used by you.
On Unix systems:
e.g.1: whoami ==> Shows your username (or 'root' in the case of superuser)
On Windows systems,
e.g.2: set U ==> Shows your username, domain, and user profile location.
* Ubuntu : 'Ctrl + Alt + T'
* Windows Systems : 'Window key + R' --> type 'cmd' and click 'OK/Run'
ifconfig / ipconfig
It is generally the very first to check whether the computer's network interface has got a valid IP address to establish communication with other devices in the network. MAC (physical) address of the network can also be found using these commands.
On Unix based systems,
e.g.1: ifconfig ==> Displays all the network interfaces, such as Ethernet and Loopback, MAC addresses, IP addresses, and subnet masks. Depending on the flavour of Unix and type of interface, some additional details such as number of packets transmitted and received, errors, active/disabled status, and size of the maximum transmittable unit (MTU) can also be found.
e.g.2: ifconfig eth0 down ==> Disables the Ethernet interface 'eth0'. Super user (root) only.
e.g.3: ifconfig eth0 up ==> Enables the Ethernet interface 'eth0'. Super user (root) only.
e.g.4: ifconfig eth0 192.168.1.1 netmask 255.255.255.0 ==> Assigns IP address and netmask manually. Super user (root) only.
On Windows systems,
e.g.1: ipconfig ==> Displays the IP address, netmask, and default gateway of all the network interfaces.
e.g.2: ipconfig /all ==> Displays more information about the network interfaces, including MAC address, DHCP status, and DNS servers used.
e.g.3: ipconfig /renew ==> Re-establishes TCP/IP connections on all network adapters and refreshes IP address with the DHCP server.
e.g.4: ipconfig /flushdns ==> Flushes the DNS cache stored locally (URL to IP address conversion)
ping
It is the basic command to check network reachability based on echos received from a network interface. It works in both Unix and Windows systems. However, command switches for a given additional option, such continuous ping, may vary.
On both Unix and Windows based systems,
e.g.1: ping 127.0.0.1 ==> reveals whether the IP protocol is up on you own computer (localhost). On Unix, continuously sends echo requests until terminated with 'Ctrl + C'.
e.g.2: ping www.yahoo.com ==> shows whether you can reach yahoo.com's server over the internet
On Windows,
e.g.1: ping -t www.google.com ==> On windows, continuously sends echo requests until terminated with 'Ctrl + C'.
Note:
- If no response for a well known server, then ping to the gateway IP addess found from the ifconfig / ipconfig command above. This reveals the connectivity to your network gateway.
- When URL is used with the ping command instead of an IP address, and it does not get resolved into an IP address, then the Domain Name System (DNS) resolution could be tested.
traceroute / tracert
A command to identify the hops in the network, and in case of failures the output indicates the intermediate hops which packets travel successfully.
On Unix based systems,
e.g.1: traceroute www.yahoo.com ==> Names of hops along the network path and time taken to receive an echo response from them
On Windows,
e.g.1: tracert www.yahoo.com ==> Names of hops along the network path and time taken to receive an echo response from them
nslookup
Returns the corresponding IP address for a given URL (also vice-versa).
On both Unix and Windows based systems,
e.g.1: nslookup www.yahoo.com
netstat
A command to visualize the details of the ongoing network communication.
On both Unix and Windows based systems,
e.g.1: netstat ==> Details of all the established TCP connections
e.g.2: netstat -r ==> The routing table of your computer, including the default route and gateway details.
arp
Displays the IP address to MAC address conversion, and vice versa.
e.g.1: arp -a ==> Displays all the IP addresses and corresponding MAC addresses of the known network interfaces in the local broadcast domain
hostname
Gives the name assigned to your computer.
e.g.1: hostname ==> Hostname of your system
whoami / set U
Reveals the username currently used by you.
On Unix systems:
e.g.1: whoami ==> Shows your username (or 'root' in the case of superuser)
On Windows systems,
e.g.2: set U ==> Shows your username, domain, and user profile location.
Sunday, April 13, 2014
IPv4 Martian Addresses
Martian addresses are the blocks of IPv4 addresses that are reserved for special use by the Internet Assigned Numbers Authority (IANA), and are NOT meant to be reached over the Internet. The following are the IANA reserved category addresses which are generally considered as Martian addresses:
Depending on the manufacturer of routers used at the customer premises or at the network service providers end these Martian addresses may also be blocked within Layer 3 Virtual Private Networks (IP VPNs) or Local Area Networks (LANs). E.g., Juniper Network routers block Martian addresses within IP VPNs.
Private Network IP Address Blocks
IP address blocks that are dedicated for private LANs are also included within the Martian Address blocks according to some definitions.
Bogon IP Address Blocks
IP address blocks that are yet to be allocated to any user or delegated to any regulator agency by the IANA are called Bogon IP addresses. These blocks change with time.
Address block | Use |
0.0.0.0/8 | "This" network |
100.64.0.0/10 | Carrier-grade NAT |
127.0.0.0/8 | Loopback |
169.254.0.0/16 | Link local |
192.0.0.0/24 | IETF protocol assignments |
192.0.2.0/24 | TEST-NET-1 |
198.18.0.0/15 | Network interconnect device benchmark testing |
198.51.100.0/24 | TEST-NET-2 |
203.0.113.0/24 | TEST-NET-3 |
224.0.0.0/4 | Multicast |
240.0.0.0/4 | Reserved for future use |
Depending on the manufacturer of routers used at the customer premises or at the network service providers end these Martian addresses may also be blocked within Layer 3 Virtual Private Networks (IP VPNs) or Local Area Networks (LANs). E.g., Juniper Network routers block Martian addresses within IP VPNs.
Private Network IP Address Blocks
IP address blocks that are dedicated for private LANs are also included within the Martian Address blocks according to some definitions.
Subnet Address block | Use |
10.0.0.0/8 | Class A private networks (used as /8 subnets) |
172.16.0.0/12 | Class B private networks (used as /16 subnets) |
192.168.0.0/16 | Class C private networks (used as /24 subnets) |
Bogon IP Address Blocks
IP address blocks that are yet to be allocated to any user or delegated to any regulator agency by the IANA are called Bogon IP addresses. These blocks change with time.
Thursday, April 10, 2014
Unix - SSH/SCP
- Check SSH server running:
# cat /etc/rc.conf | grep ssh sshd_enable="YES"
- SSH access to a remote machine:
#/$ ssh username@remoteMachine
'remoteMachine' is the DNS resolvable hostname of the remote host. IP address can also be used instead of the remote machine's hostname. - Securely transfer file over SSH:
#/$ scp -q -C -l 80000 username@remoteMachine:/home/username/test.txt \
/home/username/.
- Enable root access over SSH (only if it is essential):
# vi /etc/ssh/sshd_config PermitRootLogin yes # service sshd restart (or, # /etc/rc.d/sshd restart)
- Generate and copy SSH keys:
#/$ cd ~ #/$ ssh-keygen -t rsa #/$ scp ~/.ssh/id_rsa.pub remoteMachine:.ssh/authorized_keys
'RSA' is used here as authentication mechanism. Similarly 'DSA' can also be used. - Verify whether SSH key is working:
#/$ ssh remoteMachine hostname
Displays remote machine's hostname without a password prompt. - Monitoring/tracing SSH/SCP activities:
# cat /var/log/auth.log
Displays detailed log.
Note: Unix commands and file locations used here have been tested on FreeBSD systems.
Tuesday, April 8, 2014
Crimping an Ethernet LAN cable
Steps:
- Insert the cat 5e/6 cable into the boot/cap.
- Remove approximately 1 inch of the sleeve of the wire.
- Straighten the wires (ie, untwist the twisted pairs).
- Arrange the wires in the right order as shown below. Choose either (EIA/TIA 568) A or B type, and if it is a straight cable follow the colour sequence of the first image on both the ends of the cable.
- Cutoff excess length of the wire (to make it levelled inside the RJ-45 clip).
- Insert the wire into the RJ-45 clip while maintaining the order of the wires all the way in until you can see all the wires touching on the right side wall of the clip as shown by the red line (ie, you have to insert the beyond the end of arrows shown here.)
- Crimp the RJ-45 clip firmly with the crimping tool.
- Fix the boot.
Subscribe to:
Posts (Atom)