Once upon a time, we talked a bit about man pages, and how useful they are for learning about a new program. We didn’t really get into how you find programs that you might want to run. This is what we’ll start exploring in the rest of this post. First, a few things to know. Most executable files, also called “binaries” are stored in a bin directory. This is just convention, since technically a binary file can live anywhere. [Read More]
and things of that nature.
So, you’re loving life, using ls(1) to list your files, and making directories with mkdir(1), impressing people by printing out their names using banner(1) , and jumping around the command line like a pro when someone asks you if you still have a copy of that photo you emailed them last year with all your old high school friends in it. Maybe? If you’re anything like me, your home directory is a bit of a mess, with folders and files everywhere. [Read More]
Using The Shell Effectively
How to win friends, and influence people (not really).
Once you get comfortable poking around with your shell, you start to wonder if there aren’t easier ways to do some common tasks. We’re constantly cd‘ing places, and running commands, and having to remember really long incantations just to list our files in reverse chronological order (ls -lrth). I’ve compiled the following list of useful shortcuts for using the command line. They have all been tested on bash(1) and ksh(1). [Read More]
Size Date Name
The end of ls
When I first started writing about the output of the ls command, I didn’t expect it would take four posts to get through, but here we are. We’re almost to the end, the only things left to talk about are the file size, the last modified time, and the filename. The file size is represented in bytes, unless you pass the -h flag to ls in which case, the size will be displayed in Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte, depending on how much stuff you have! [Read More]
Users and Groups
who are these people?
Moving on to the next bit of information that’s encoded in the ls command’s output, we get to the user and group section. This shows us the owner of the file, and the primary group associated with the file: $ ls -l total 4 -rw-r--r-- 2 gabe gabe 0 Nov 2 13:37 a-hard-link-to-a-new-file drwxr-xr-x 2 gabe gabe 512 Dec 5 13:30 a-new-dir -rw-r--r-- 2 gabe gabe 0 Nov 2 13:37 a-new-file lrwxr-xr-x 1 gabe gabe 10 Nov 8 11:36 a-symbolic-link-to-a-new-file -> a-new-file In this case, the user and the group are the same: gabe gabe [Read More]
Links, files, inodes
I need to issue a quick apology to anyone who has signed up via the subscribe button on the website, it seems that I had misconfigured some software and so new subscribers would get every single post emailed to them in one shot. That wasn’t my intention and I’ve since fixed the problem. Sorry about that. Moving on… Last time we created an empty file and were making our way through the output of the ls command, today we’ll continue where we left off and talk about links, and inodes. [Read More]
Files, Permissions, Binary
That escalated quickly
We’ve spent a fair amount of time poking around on our systems and we’ve seen plenty of files and directories while using the ls command. Today we’re going to dig a bit deeper into the concept of files and what to do with them. First, lets create a new directory to work in. Be sure you are in your home directory, and then use the mkdir (make directory) command to create a directory called “cotcli” (or whatever else you’d like to call it): [Read More]
Input Output Pipelines
Getting from here to there
Last week I mentioned the | (pipeline) operator, and gave a quick example of how to use it: ls -lS | less. What that does is take the output of the ls command and sends it to the less command as input. This is what pipelines or “pipes” are for. They allow you to take the output of one program and send it to another program for more processing. You can do this over and over again, for example: [Read More]
df and du
Where did all my space go?
Something I find myself doing frequently from the CLI is checking to see how much disk space I have left on my computer. To do this, I use the df command. I pass the -h flag so that the df program will display sizes in “human readable” format, like so: gabe@xps:~$ df -h Filesystem Size Used Avail Capacity Mounted on /dev/sd0a 1005M 1004M -49.8M 105% / /dev/sd0l 70.1G 24.5G 42. [Read More]
cd, cd .., cd -, and more.
When you first start using the CLI, you will spend most of your time navigating the file system, looking for things. In this post I’ll give you some tips that should make this process more enjoyable. When you first open the terminal program you should automatically be in your home directory. Your home directory is where all your files live. You can verify this by issuing the pwd command. You should see something that looks like this: /home/gabe or /Users/gabe if you are on a Mac. [Read More]