Use a terminal session to:
- Make a directory called LabTask1 off your home directory (0.0%).
Do the following questions in the directory.
Answer
cd
mkdir LabTask1
- Find out your
- User ID (the number)
- Primary group ID (the number)
- The names of all groups you belong to
- The absolute path of your shell
(tcsh/bash/zsh/whatever)
- The absolute path of your home directory
- Your PATH environment variable
Put the answers into a text file. (0.5%)
Answer
For csc322 ...
502
20
staff everyone
/bin/tcsh
/Users/geoff
.:/Users/geoff/bin:/sbin:/bin:/Users/geoff/MyApplications/Development/Anaconda/bin:/usr/local/sbin:/usr/local/bin:/usr/local/java/bin:/usr/X11R6/bin:/opt/local/bin:/opt/local/sbin:/usr/sbin:/usr/bin:/usr/ucb:/etc:/opt/gradle/gradle-6.6/bin
- Write a shell script that will provide the above information (the script
must be a executable, and must work regardless of which directory it is
in). (1.0%)
Answer
#!/bin/tcsh
id -u
id -g
id -nG or groups
which tcsh
cd; pwd or echo $HOME or printenv HOME
or echo $PATH or printenv PATH
and use chmod 755 or chmod +x to make it executable.
- Imagine you start a program from your command line prompt.
- What is your program's parent process?
- What is that process' parent process?
- What is that process' parent process?
(0.5%)
Answer
- Read the man pages about the ls and wc commands.
Devise a minimal pipeline command that will print the number of files and
subdirectories in the current directory (including hidden ones, but
not the current and parent directory entries). (0.5%)
Answer
ls -A | wc -l