Documenting interesting stuff I learn about Linux/Unix
Configure alias
Alias can be configured through
alias <AN_ALIAS>=<THE_ACTUAL_COMMAND>
Example:
alias k=kubectl
- note that this only configures alias for the current shell session.
To permanently configure an alias do:
echo "alias k='kubectl'" >> ~/.zshrc
Use alias
to view all alias set
Locate files/directories
Files/directories could be located through:
locate <FILE_NAME>
Example:
locate hello_world.txt
- note that
locate
depends on the database/var/db/locate.database
which has to be initialized through:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Alternatively find
command could also be used:
find <FILE_NAME>
Example:
sudo find /opt -name caleston-code
Networking
DNS resolution
/etc/hosts
This is used for static hostname resolution where hostnames to IPs are mapped manually.
The order of resolution takes precedence over DNS resolution; the system checks /etc/hosts
before
querying a DNS server, if a match is found, DNS server is not consulted.
Example:
127.0.0.1 localhost
192.168.1.10 myserver.example.com myserver
/etc/resolv.conf
This specifies DNS servers for resolving domain names into IP addresses. It contains configuration options and search domains.
Example:
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com
Here, nameserver
specifies the DNS servers to query.
search
defines the fomain to append when trying to resolve a hostname. For example, if we try to resolve
myserver
, it will first attempt to resolve myserver.example.com