Linux on call · Chapter 6 of 30

Getting help and your shell

By the end of this chapter you can look up any option yourself, tell what kind of thing a command is and where it lives, and make the shell work for you with aliases and history. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.

  • Part: Finding your way
  • 5 tasks
  • Linux
  • In the all labs plan

The first 2 chapters of Linux on call are free. This one comes with the all labs plan.

Why you need this

Ravi wants a listing of the files folder with the biggest files first, and Kabir is writing deploy notes that need the exact place the node and tree programs live. Bunty has a question for Kabir every five minutes ("what is the option for...?"), types ls -la fifty times a day, and lost a long command he got right yesterday.

So far you learned options by being told them. There are hundreds, and nobody remembers them all: Kabir does not either. What he knows is how to ask the machine, and how to make the shell remember things for him.

What you build: 5 tasks

Each task has tests. You write the code in the lab's editor and press Check.

  1. Task 1

    List the files folder biggest first in sizes.txt

    Find an option of ls by yourself, in its help.

    1. Run ls --help. It lists every option of ls.

    2. Find the option that sorts by file size.

    3. Run ls with that option on the files folder. The biggest file should be at the top.

    4. Save that listing in sizes.txt, in the chapter folder.

    To pass: you ran ls --help (or help, or man) in the chapter folder. sizes.txt lists all five files in the files folder, from biggest to smallest. A long listing with sizes is fine too.

  2. Task 2

    Save where node and tree are in where.txt

    Find where the programs node and tree are saved.

    1. Use which with the names node and tree. It prints the full path of each program.

    2. Check that you see two paths, each starting with /.

    3. Save that output in where.txt, in the chapter folder.

    To pass: where.txt has the full path of node and the full path of tree, each starting with /.

  3. Task 3

    Make an alias ll for ls -la and use it

    Give the command ls -la a short name, ll.

    1. In the chapter folder, run alias with the name ll and the command ls -la in quotes. Put no spaces around the =.

    2. Run ll once, on its own or with a folder name after it.

    3. You should see the long listing, with hidden files too.

    To pass: you made the alias ll for ls -la, and then you ran ll. Both were typed in the chapter folder, and both worked. A command with a typing mistake does not count, so type it again.

  4. Task 4

    Save your history in history.txt, after the alias

    Save the list of commands you typed in a file.

    1. Make the alias ll first (task 3).

    2. Run history. It prints your commands, with a number on each line.

    3. Save that output in history.txt, in the chapter folder.

    To pass: you ran history in the chapter folder, after you made the alias. history.txt has your numbered command list, with the line that made the alias ll.

  5. Task 5 · interview question

    Interview: what type says about ls, cd and ll

    Interview question: what kind of command are ls, cd and ll?

    1. Use the same terminal where you made the alias ll. A new terminal does not know ll.

    2. Run type with the three names ls, cd and ll.

    3. Check that you see three lines, one for each name.

    4. Save that output in type.txt, in the chapter folder.

    To pass: type.txt has the three lines type prints. They say that ls is a program in a folder, cd is a shell builtin, and ll is an alias.

What you will learn

  • --help and help: every command explains its own options.
  • type, which and PATH: what a name really is (a program, a builtin, an alias) and where the shell finds it.
  • alias: a short name for a command you type often.
  • history: the commands you typed, numbered, searchable, and repeatable.

More in Finding your way

Build "Getting help and your shell" yourself

Tapri’s ordering app moves onto a Linux server, and the server is now yours to run. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.

The first 2 chapters of Linux on call are free. This one comes with the all labs plan.