Getting the location of commands in Unix

Unix Shells

AFAIK, there are four ways to find out where a command is in your path.

Shell Builtins

  • command -v (POSIX shell way)

    • Shows the command that would be run by your shell (without actually running it)
  • type [-afptP] (bash builtin way)

    • Essentially the same function as command, but with more options

Both command and type can output the location of any executable, script, alias, or shell builtin in your $PATH and your shell environment.

Init Systems

The initial process that runs on a Unix/Linux system is responsible for forking the rest of the processes that are needed in order to “boot” the system. This is the core function of an init-system. It is effectively the first process where execution is handed off from the kernel to “userspace”, where processes get PIDs, cpu time and network/memory/disk access via calls to the kernel or kernel modules (drivers).

Find with find

The find command is a pretty basic utility, but it does have loads of options, which may be intimidating at first, but keep in mind it has about every criteria you would possibly need when searching for attributes of files or directories.

It is also the standard way to search files/directories by criteria like name, date created, size, permissions, user, and more.

The syntax and options may seem irregular compared to other commands, but I’ll show a few examples:

Calendar_Icon

If you want to schedule a program to run on a Unix based OS, there are a handful of options, but the prominent ones found on Linux are cron and systemd timers.

Initially released in 1975, cron has stood the test of time when it comes to running a task on a schedule and it continues to be the standard solution for all kinds of users.

How does it work

There is a file called crontab which tells the cron daemon what to run and when to run it.

PowerShell_Logo

For non-commercial purposes documentation or on a website) that reference your connection with Microsoft PowerShell.

Things To Know About PowerShell

First and foremost, PowerShell is unlike traditional Unix/Linux shells such as bash or zsh. It is explicitly object oriented and the most of the benefits come from the fact that the majority of “builtin” commands (also known as cmdlets) and everything related to input/output comes in the form of objects which in turn have members, methods and inheritance. This way data is more “structured” compared to shells that deal with plain text.

Globe

Browsing the web involves lots of different protocols that most people probably don’t consider.

DNS is one of those protocols, so in this post, we’ll briefly go over the basics of DNS, why browsers are switching to DNS Over HTTPS (DoH), and how to get public DNS Records.

What is DNS

The core function of DNS (Domain Name System) is to associate Domain Names to IP Addresses and vice versa. The concept is deceivingly simple, and incredibly useful.

Arrows

horizontal by Ben Davis from the Noun Project

Dear Reader: This post is aimed at beginners so if you are already familiar with how APIs work, you might not get much from my explanation, but you are welcome to skim.


One of the most common activities a Web Developer will do is fetch data from some API, parse it, and then do something with that data, like displaying it on the page.

Rows

Reading input line by line is something that seems like a basic and banal operation, but it’s not really as basic as some higher level languages make it out.

Let’s look at a couple ways we can do this in Bash and other languages like Python and C.

Bash

The syntax of bash always seems a bit awkward.

For this example, assume we have a file called test.txt and we want to echo every line.

Disk usage by partition

Checking on disk usage of mounted partitions in Linux is one command.

df -h

The -h makes the output human readable (think MB, GB instead of bytes or kilobytes)

Disk usage by directory

The command used to check disk usage of directories on Linux is du.

Note the regular output is in kilobytes, but like other utils that work with sizes, adding -h will make the results human readable.

Documenting your code is incredibly important. Not only does it help your future self understand, but it also helps others find their way around.

This post will be talking about some of the tools developers can use to generate docs for their projects.

The Premise Is Simple

There are a plethora of tools out there that allow you to create, organize, and serve documentation, but they are all more or less based around the same core concept, which is this: