UNIX

Ace your homework & exams now with Quizwiz!

The figure below shows a sample of a passwd file. The field #1-7 is

#3 is user identifier #6 is home directory #7 is shell #4 is group identifier

wildcard shell patterns

* matches any string of character ? matches any single character [list] matches any character in list

korn shell clone from GNU

/bin/bash

C shell is

/bin/csh

korn shell

/bin/ksh

the bourne shell

/bin/sh

[Sobell1-4] Which of the following represents an absolute path?

/usr/bin/cat

[Sobell] With this option of chmod command,Owner, group, and others can read, write, and execute the file.

0777

[Unix&Shell4grep] What would be the result (that is, to count the number of the output lines) of the following grep command with the data.txt as shown below? grep '[Ss]ept' data.txt | grep 483 where the content of data.txt is: 48 Dec 3BC1997 CPPX 68.00 LVX2A 138483 Sept 5AP1996 USP 65.00 LVX2C 18947 Oct 3ZL1998 CPPX 43.00 KVM9D 512219 dec 2CC1999 CAD 23.00 PLV2C 68484 nov 7PL1996 CAD 49.00 PLV2C 234483 may 5PA1998 USP 37.00 KVM9D 644216 sept 3ZL1998 USP 86.00 KVM9E 234

2

[Unix&Shell4grep] What would be the result (that is, to count the number of the output lines) of the following grep command with the data.txt as shown below? grep '5..199[6,8]' data.txt where the content of data.txt is:48 Dec 3BC1997 CPPX 68.00 LVX2A 138483 Sept 5AP1996 USP 65.00 LVX2C 18947 Oct 3ZL1998 CPPX 43.00 KVM9D 512219 dec 2CC1999 CAD 23.00 PLV2C 68484 nov 7PL1996 CAD 49.00 PLV2C 234483 may 5PA1998 USP 37.00 KVM9D 644216 sept 3ZL1998 USP 86.00 KVM9E 234

2 this looks for a 5 with two random spots (hence the ..) and then a 6 or 8

[Unix&Shell4grep] What would be the result (that is, to count the number of the output lines) of the following grep command with the data.txt as shown below? grep '[A-Z][A-Z]..C' data.txt where the content of data.txt is:48 Dec 3BC1997 CPPX 68.00 LVX2A 138483 Sept 5AP1996 USP 65.00 LVX2C 18947 Oct 3ZL1998 CPPX 43.00 KVM9D 512219 dec 2CC1999 CAD 23.00 PLV2C 68484 nov 7PL1996 CAD 49.00 PLV2C 234483 may 5PA1998 USP 37.00 KVM9D 644216 sept 3ZL1998 USP 86.00 KVM9E 234

3

[Unix&Shell4grep] What would be the result (that is, to count the number of the output lines) of the following grep command with the data.txt as shown below?grep '5..199[6,8]' data.txt where the content of data.txt is:48 Dec 3BC1997 CPPX 68.00 LVX2A 138483 Sept 5AP1996 USP 65.00 LVX2C 18947 Oct 3ZL1998 CPPX 43.00 KVM9D 512219 dec 2CC1999 CAD 23.00 PLV2C 68484 nov 7PL1996 CAD 49.00 PLV2C 234483 may 5PA1998 USP 37.00 KVM9D 644216 sept 3ZL1998 USP 86.00 KVM9E 234

3

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod o+x abc", the file "abc" is executable by group.

False

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After executing the following command: "chmod g+x abc", the file abc will be executable by all.

false

[Sobell1-4] (T/F) The command "grep -i hello" prints all the lines in file, not containing the string "hello".

false

[Sobell1-4] (T/F) The command pwd is normally used to change the password.

false

how to end an if statement

fi

int -eq int2

checks to see if int is equal to second

-n string

checks to see if length of sting is not 0

-z string

checks to see if length of string is 0

wait

will block until the command finishes

[Sobell1-4] In Unix, if you wanted to allow a user to delete a file, you would give the file the what permission?

write

-w file

write to a file

how do we end a while until or for

you end it with the word "done"

[shell] If your "search path" does NOT include the path to a particular shell, and you try to run that shell by typing its name on the command line, what happens?

you will get an error message

[Sobell1-4] The file "assign4.html" has permissions set as: "r w x r w x r w x".This means that:

Everyone can read, write, and execute the file.

redirection of output

> command and input is < append output is >>

[Sobell1-4] What will the following command do?chmod og+r *.jpg

Change the permissions on any file ending with .jpg to be readable by all others

[shell] The following code (note backquotes around the ls ... done command) echo `ls | more | while read file do ls $file done `

Displays name of all the files (excluding hidden files) in your current directory

[shell] Under Bourne shell, the following command will do ____. echo `who | more`

Displays output of the "who | more" command

[shell] Under Bourne shell, the "export place" statement will do ____.

Makes a copy of the current value of the shell variable place available to the commands/scripts executed under the shell

[Sobell1-4] Which of these expressions shows the proper way to add the directory /usr/bin to your path?

PATH=$PATH:/usr/bin

[shell] If you type echo $PATH on the Bourne shell command line, what is displayed?

The current setting of the PATH variable

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. After the command "chmod og+rx abc", the file abc executable and readable by all.

True

[Sobell1-4] (T/F) Consider a file abc which can be "read, write, execute" only by the owner. The result of the following command "chmod 700 abc" is equivalent to "chmod og-rwx abc".

True

[Sobell1-4] (T/F) The command "ls" lists the contents of a directory.

True

-s file

True if FILE exists and has a size greater than zero

-d file

True if FILE exists and is a directory.

kill

Use This as a last resort to destroy any jobs or programs that you suspended and are unable to restart.

[Shell] In bash or ksh, what is the difference between the expressions VAR and $VAR?

VAR refers to a variable name and $VAR to its value

$SHELL

What shell you are using

[Sobell1-4] When creating a directory as an ordinary user, which of the following is true?

You must be in your home directory or its subdirectories.

0640

[Sobell] With this option of chmod command,Owner, group, and others can read, write, and execute the file.

what is the shell metacharacters that allow you to delimit literal wild card characters in a command?

[] square brackets

[Sobell1-4] When you use the ln command, which of the following occurs?

a file is created that points to an existing file

[Shell] What is a shell in UNIX?

a program through which users can issue commands to UNIX

$HOME

absolute pathname of your home directory

what does & do?

any command ending with & will tell it to run in the background

[Sobell] This outputs the contents of a text file. You can use it to read brief files or to concatenate files together.

cat

[Sobell1-4] Which command will print the contents of all files in the current directory whose names start with the character "a" and end with a period (".") followed by any two characters followed by a number?

cat a*.??[0-9]

Change to another directory.

cd

[Sobell1-4] Change the current directory to /usr/local/bin

cd /usr/local/bin

chmod

change file security setting

[Sobell1-4] How do you change the access permission (for the user's group to read/write) to all the files in the current directory containing the word "cali" in their names?

chmod g+rw *cali*

[Sobell1-4] What is the generic syntax for all UNIX commands?

command name, followed by options, followed by arguments

copy a file

cp

[Sobell1-4] Make a copy of file "upper" in the directory two levels up.

cp upper ../..

$PWD

current working directory

rmdir

delete a directory

rn

delete a file

[Sobell1-4] What is the command to search all files in your current directory for the word "hello"?

grep hello *

[Sobell1-4] How do you print the first 15 lines of all files ending by ".txt"?

head -15 *.txt

man

help manual

what is a shell script

is a regular text file that contains shell or unix commands a script can be invoked as: sh name [arg[ sh < name [args] name [arg]

parameters

is one of the following a variable a positional parameter

Sobell] This terminates a process by PID

kill

ls

list filenames and directories

$PATH

list of directories to search for

[Sobell] This will list the files and the subdirectories in a directory.

ls

[Sobell1-4] How do you list all the files that are in the current directory?

ls -a

[Unix&Shell2] To match filenames that start with 'CPP', followed by any two characters, followed by any non-digit string:

ls CPP??[!0-9]*

Make a directory.

mkdir

[Sobell1-4] Which command is used to create the directory "abc" in the previous (parent) directory?

mkdir ../abc

[Sobell1-4] How do you create a new directory called "flower"?

mkdir flower

[Sobell1-4] Which of the following is not a benefit of the fact that many UNIX commands operate on plain ASCII text files?

most current UNIX installations have a graphical user interface

move a file to another location

mv

[Sobell1-4] To rename the file "a.html" to "b.html", which command do you use?

mv -i a.html b.html

[shell] Under Bourne shell, the following command creates a user-defined shell variable, called name, and initializes it to be John Doe.

name="John Doe"

what is #!

of tje #! is not specified then the current shell assumes it is a script in its own language (which leads to problems) so the #! is important for ex #!/bin/sh will call the shell command

$PS1

primary prompt

means of inout

program arguments stadard input environment variables

Display current working directory - i.e. where am I?

pwd

[Sobell1-4] In Unix, the octal number "5" corresponds to which ___ file permission.

r - x

-r file

read file

means of output

return status code standard out standard error

scripting vs c programming

scripting is easy to work with files and other programs but is slower

[shell] The following command increments the value of a Bourne shell variable, sum, by one.

sum=`expr $sum + 1`

$TERM

terminal type being used

int1 -ne int2

test inequality

boolean operators

the same way you would compare anything its and or && || 0 means success anything else is a failure code

what is a shell

the user interface to an OS system functionality execute other programs manage files etc

[Unix&Shell1] The -follow option with find command is ____.

to chase down the source of the files for symbolic linked files

[vim editor] For deleting, D is _____

to delete the rest of the line

-f file

true if a file exists and is a regular file

[Sobell1-4] What is the effect of the command alias up2="cd ../.."?

typing "up2" at a shell prompt takes you up two levels in the directory tree

[Sobell] ___ Specifies the file-creation permissions mask

unmask

$USER

username ID

the C shell

uses {}'s inadequate for scripting


Related study sets

RN Individual Influences Assessment

View Set

GI NCLEX REVIEW QUESTIONS for ADULT GI

View Set

Julius Caesar Multiple Choice: Pg 1

View Set

Physics 5 (Additional Applications of Newton's Laws)

View Set

Physiology - Lab 10 PhysioEx 9 Quiz Review

View Set