Intro to Unix Shell

The Unix shell is a command-line environment for interacting with your operating system, typically macOS or Linux.

It allows you to launch programs, manage files, and much more, all through a terminal interface.

echo "Hello, world!"

Instead of clicking around with a mouse, the shell lets you tell your computer what to do by typing words and commands.

This document touches on the basics of:

Working with Files

The Unix shell lets you create, view, copy, move, and delete files quickly using commands.

Instead of using a graphical interface which you may be used to, you can type commands to handle files right from the terminal.

touch newfile.txt

This creates an empty file called newfile.txt if it doesn't already exist.

cp file1.txt file2.txt

This copies file1.txt to a new file called file2.txt.

mv file1.txt Documents/

This moves file1.txt into the Documents directory. It can also rename files if you provide a new name.

Using these commands, you can quickly manage many files without leaving the command line.

Viewing File Content

The Unix shell provides many commands to look inside files without opening them in a full editor.

This is useful for quickly checking logs, configuration files, or code.

cat filename.txt

This prints the entire contents of a file directly in the terminal.

less filename.txt

This opens a file in a scrollable viewer so you can move up and down easily.

head filename.txt

Displays just the first few lines of a file, useful for a quick peek.

tail filename.txt

Shows the last few lines of a file, helpful for checking logs.

These commands make it quick and easy to read file contents directly from the command line.

Useful Tips

Besides basic commands, the Unix shell has many small features and shortcuts that can make your work much faster and easier.

One of the most helpful tools is tab completion. When typing a file or folder name, you can press the Tab key to automatically complete it or show suggestions.

cd Doc

Pressing Tab after typing Doc might complete it to Documents/ if that folder exists.

Here are some other useful tips for working in the shell:

Practicing these small shortcuts helps make using the shell feel much faster and more comfortable.