Target audiences:
Analysts let loose on the server for the first time.
Students developing operational habits.

Maybe you’re an analyst who’s been given credentials to where the data scientists run their scripts. Or maybe it’s the first day of classes, and you’ve been given credentials to the homework server.

Ok, now what?


If this is your first time using the command line, it can feel meaningless or even disquieting to look at that blinking cursor without context. Here’s some:

Get Situational Awareness

I’ve written elsewhere on this blog about how important situational awareness is when dealing with data. Let’s apply those same principles:

Where?

Odds are, you’re on someone else’s computer, and it’s a Linux machine. Linux is an open-source operating system. You can think of it as a third OS, like the cousin to Microsoft Windows, or MacOS.

Think of servers as large, often shared, computers. Maybe it’s “in the cloud.” You’re probably accessing it remotely, and not walking up to an oversize computer and desk chair.

This image has an empty alt attribute; its file name is image.png
That’s me! And I’m on a computer named “DESKTOP-JCGIQGF”, apparently.

But where am I? Linux, like Windows or MacOS, has folders and directories, like Desktop, or your Downloads folder. When you first log in, you’re by default in your home directory. What’s that? To find out, enter pwd:

The terminal has returned the result of your command, and waits for more.

pwd returns where we are right now. cd lets you move around:

I happen to know I want to look at a folder at /mnt/c/, called “comp15”

and then pwd confirms this as well:

What?

We know where we are, but we can’t see anything. What’s here? Enter ls:

ls lists the files and folders. Here I’ve got a bunch of folders.

Check out man ls for helpful flags you can add. ls -alh returns something quite different! Try it yourself.

Another neat command you can use to investigate your surrounds is tree:

A snippet of the results of the contents in subfolders that start with p

When?

Maybe you’re investigating some logs or processes. What time is it? I mean, what time is it on this computer? Timezones and time discrepancies can be a nightmare. Simple – enter date:

What time the computer thinks it is right now.

This can be super important for communicating with others about things happening on the server. Observe the timezone. Shared computers, like AWS EC2 servers, often default to UTC, instead of local timezone.

If you’re an analyst that cares about logs on a shared server, there’s a good chance you’re in the unenviable position of investigating crontab runs. I won’t deepdive that here – check out this intro. crontab -l will show what cron schedules exist, if any.

Who?

If you’re on a shared computer, it can be tough to tell who’s doing what right now. That gets into more advanced topics, but htop can provide insight into what’s happening on that computer right now:

Not much is happening on my computer right now – just me and the OS hanging out.

tl;dr:

Congrats! You’re on a linux server. You can get situational awareness quickly by finding out Where (pwd,cd), What (ls,tree), When (date,crontab), and even a little bit of Who (htop).