1.5 KiB
1.5 KiB
LPIC-1 103.1: Working on the command line
Quoting, exported variables, running your own scripts, builtins and programs, and searching the manual.
Before you start
The lab installs man-db and builds the manual's search index if needed.
Work as root (sudo -i) unless a task says otherwise, and write answers
to the files in /root/lab-answers/.
Tasks
- Predict what each of these prints, then check:
echo '$HOME',echo "$HOME",echo \$HOME,echo "It's $USER". Write the four outputs, as root, one per line in that order, to/root/lab-answers/1. - Set a variable, show that
bash -c 'echo $var'can't see it, export it, and try again. Check it yourself: the second try prints the value. - Write a two-line script,
hello.sh, in your home directory, make it executable withchmod +x, and run it with./hello.sh. Then try running it by name alone, and write why that fails to/root/lab-answers/3. - Run
typeoncd,ls,echoandssh, and compare withwhich. Write the ones that are shell builtins to/root/lab-answers/4. - Find the man page for the
crontabfile format (not the command) usingman -k, and write how you'd open it (such asman 1 ls) to/root/lab-answers/5.
Hints
- Single quotes keep everything literal, double quotes expand
$, and\protects one character. export var,env | grep var.#!/bin/bashon line 1;echo $PATH.type -a;whichonly searchesPATH.man -k crontab(orapropos); the number in brackets is the section.