Introduction to shell navigation

Shell basics / Unix system

Introduction to shell navigation

Learning Objectives

How to navigate in an Unix system

How to list files and directories

How to display the content of a file

How to create a file or directory

How to remove a file or directory

How to move or copy a file or directory

  • What is a command shell?

    A shell is a computer program that presents a command line interface which allows you to control your computer using commands entered with a keyboard instead of controlling graphical user interfaces (GUIs) with a mouse/keyboard combination

Access the shell on my computer.

On a Mac or Linux machine, you can access a shell through a program called Terminal, which is already available on your computer. If you’re using Windows, you’ll need to download a separate program to access the shell.

Windows:

Command Prompt: Press Win + R, type "cmd," and press Enter. This opens the Command Prompt, which is a basic shell environment.

Third-Party Terminal: You can install third-party terminal emulators like Git Bash or Windows Terminal for a more feature-rich command-line experience.

MacOS:

Terminal: Open the "Terminal" application. You can find Terminal in the Utilities folder within the Applications folder, or use the Spotlight search (press Cmd + Space and start typing "Terminal").

After launching your terminal, you will see something like this

bash-5.0$

This provides a lot of information about the remote server that you’re logging in to. We’re not going to use most of this information for our workshop, so you can clear your screen using the clear command.

$ clear

This will scroll your screen down to give you a fresh screen and will make it easier to read. You haven’t lost any of the information on your screen. If you scroll up, you can see everything that has been output to your screen up until this point.

The part of the operating system responsible for managing files and directories is called the file system. It organizes our data into files, which hold information, and directories (also called “folders”), which hold files or other directories.

Several commands are frequently used to create, inspect, rename, and delete files and directories.

In this article, I will introduce our first three commands: pwd (print working directory), cd (change directory), and ls (list files and directories).

Those new to the command line will need to pay close attention to this lesson since the concepts will take some getting used to.

File System Organization

Like Windows, the files on a Linux system are arranged in what is called a hierarchical directory structure. This means that they are organized in a tree-like pattern of directories (called folders in other systems), which may contain files and subdirectories. The first directory in the file system is called the root directory. The root directory contains files and subdirectories, which contain more files and subdirectories and so on and so on

  • pwd (print working directory)

Let's say you open a terminal and you're in your home directory. If you type:

pwd

The terminal will respond with the full path of your current working directory, which might look something like:

/Users/YourUsername

This tells you that your current working directory is your home directory.

  • ls (list contents)

ls prints the names of the files and directories in the current directory in alphabetical order, arranged neatly into columns.

This command has various options that you can use to customize the output. Here are a few commonly used options:

ls -l: Displays a long format list that includes detailed information about each file, such as permissions, owner, size, and modification date.

ls -a: Lists all files, including hidden files (those starting with a dot).

You can make more research on ls commands, unfortunately I gave just few,there are more to learn.

cd( change directory)

The cd command is used to change the current working directory in a Unix or Unix-like operating system. You can use it to navigate between directories.

E.g

cd /path/to/directory: Changes the current directory to the specified path.

cd ..: Moves up one level in the directory hierarchy.

cd: Without any arguments, it takes you to your home directory.

Remember that the cd command only affects your current terminal session's working directory. Once you close the terminal or open a new one, the working directory will reset to your home directory.

Here is a link to some basic commands

Learn more commands

Manipulating files

Conclusion:

In this article, we are able to cover the basics of Shell navigation, there are more resources online to help you advance your learning, while learning make sure to get on your computer and keep up with some practice to balance your learning process.