In: Computer Science
1. Write a bash command that will display the value of all
environment variables
defined in your shell process, sorted in alphabetical order, and
numbered.
Here is a sample of the type of output your command should
produce:
1 }
2 ALSA_CONFIG_PATH=/etc/alsa-pulse.conf
3 AUDIODRIVER=pulseaudio
4 BASH_FUNC_mc%%=() { . /usr/share/mc/mc-wrapper.sh
5 COLORTERM=1
2. Write a bash command that will display the value (and only
the value) of the
JAVA_ROOT environment variable. Here is a sample of the type of
output your
command should produce:
/usr/lib64/jvm/jre
3. Write a bash command that will add your working directory and
your home directory
to the current value of the PATH variable. Make sure your new PATH
value works
no matter what your current working directory might be.
4. Write a bash command that will display the process ID number and
the total CPU time
for each process on the system. Do not display any additional
information. Here is a
sample of the type of output your command should produce:
PID TIME
24648 00:00:00
25431 00:00:00
27567 00:00:00
27568 00:00:00
27569 00:00:00
27570 00:00:00
5. Write a bash command that will display the name of every file
on the Linux system
whose file contaent contains the string "doug.jones". The command
must run in the
background, must redirect standard error to /dev/null, and must
redirect standard
output to ~/out.
6. Write a bash command that will kill all of the even-numbered
processes associated
with your userid, and no other processes.
7. Write a bash command that will start the program
/home/courses/140u-doug.jones/zombie_maker
as a background process, with standard output redirected to
/dev/null.
This program will create a zombie process.
8. Write a bash command that will display the process id, parent
process id, and wait
channel (search for wchan in man ps) for all zombie processes on
the server.
Do not display any additional information.
Here is an example of the type of output your command should
produce:
28318 28317 exit
9. Write a bash command that will kill job 1.
10. Write a bash command that will generate a file named
~/cpp_files
that contains the name and absolute path of all files on the
system
that contain the line
int main(int argc, char **argv)
The contents of the file ~/cpp_files should be in alphabetical
order.
The command you create should run in background, and redirect
standard
error to the file ~/stderr.
Answer 1
*********
printenv | nl
Answer 2
********
printenv | grep "jre"
Answer 3
*********
export PATH="$PATH:$pwd
Answer 4
*********
ps -O %px | awk '{print $1 " "$4}'
We are allowed to do only 4 exercise out of any given.
if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)