Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help to answer those questions? 1. What command obtains information about t

ID: 3755343 • Letter: N

Question

Need help to answer those questions?

1. What command obtains information about the ps utility?

2. What command sorts the contents of all files in the current directory with names beginning with the letter f?

3. What command creates a new file called all consisting of the lines in the files file1, file2, and file3?

4. Explain what the following command lines accomplish (explain means explain the command….I am not looking for the output you get from eve when you attempt to execute the command):

a. $grep 'Linux is fun' *

b. $sort > file4

c. $grep $USER /etc/passwd

d. $echo $PATH $PATH

e.$grep '1 2 3' f*

5. What will be the content of file1 after the following command? Explain why?

$echo $USER $HOME > file1

6. Explain what the following command is attempting to accomplish?

$grep sometext *

7. whatever directory you are presently in is know as

a. current working directory

b. home directory

c. the bin

d. child directory

e. None of the above

Explanation / Answer

1. What command obtains information about the ps utility?

ans:

ps command is used to list the currently running processes and their PIDs along with some other information depends on different options.

ps --help is the command which will tell us how to use ps command

ps will be used to get pid,tty,time,cmd etc of the process.

PID – the unique process ID

TTY – terminal type that the user is logged into

TIME – amount of CPU in minutes and seconds that the process has been running

CMD – name of the command that launched the process.

2. What command sorts the contents of all files in the current directory with names beginning with the letter f?

find ./f* -type f -exec sort -o {} {} ;

3. What command creates a new file called all consisting of the lines in the files file1, file2, and file3?

cat file1 file2 file3 > output.txt

4. Explain what the following command lines accomplish (explain means explain the command….I am not looking for the output you get from eve when you attempt to execute the command):

a. $grep 'Linux is fun' * ====> prints the all files which contains "Linux is fun" and matching line

b. $sort > file4 =====> Write sorted concatenation of all FILE(s) to standard output into file4

c. $grep $USER /etc/passwd ====> grep username /etc/passwd ===> prints the line from /etc/passwd which matches with username($USER = current username)

d. $echo $PATH $PATH ====> will prints $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

$PATH and $PATH value will be printed

echo $ will print $

e.$grep '1 2 3' f* ====>

will display file containing 1 2 3 and whose name starts with f

  

5. What will be the content of file1 after the following command? Explain why?

$echo $USER $HOME > file1

answer:

here first '$' means non root user is executing command 'echo $USER $HOME >file1'

echo is used to print the given expression

environment variables can be accessed using '$', by default linux operating system will set USER=current user, HOME=user's home directory

these environment variables can be accessed by '$'

ex: echo $USER -----> Will print the current user

echo $HOME -----> Will print the user's home directory

echo $USER $HOME -----> Will print current username, user's home directory

'>' is the file redirection symbol, this will redirect the output to given file

echo $USER $HOME > file1 ----> file1 contents will be user,user's home directory

cat file1

ubuntu /home/ubuntu

6. Explain what the following command is attempting to accomplish?

$grep sometext *

'$' non root user executing command grep sometext *

if root user then automaticall # will displayed

example: vagrant@vagrant-ubuntu-trusty-64:~/$ ls

root@vagrant-ubuntu-trusty-64:~/# ls

grep sometxt *

ex: grep a *

it will print all files which contains 'a'

7. whatever directory you are presently in is know as

answer: a) current working directory

command to get current working directory is "pwd"