BIO 4306 Exam 1: quizzes and Unix intro

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/125

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

126 Terms

1
New cards

pwd lets you:

see which directory you're presently in

2
New cards

Which command would take you directly to the file RNAsamp.txt, which is located in your home directory?

cd ~/RNAsamp.txt

3
New cards

Which keyboard shortcut lets you move your cursor to the start of a line (on a Mac at least)?

CTL+A

4
New cards

Which of the following options makes the list command put file size output using metric units (KB, MB, etc.) rather than just listing in bytes?

-h

5
New cards

Which of the following is an allowable file name?

yanni.best_hits

6
New cards

How do you create a new file using nano?

nano newfile.txt

7
New cards

You open a .txt file using nano, but there are all sorts of unexpected characters in addition to your expected text. What happened?

It was a .txt file, but saved as Rich Text Format

8
New cards

What happens when you execute this command? cat file1.txt file2.txt

You read file1 and file2 back to back as one output

9
New cards

I can't remember all these goofy key commands in less! What do I type (while I'm in less) to allow me to learn them?

h

10
New cards

How do I output the first 10 lines of the Unix manual entry on ls?

head man ls

11
New cards

Create a new directory called "birds" and then create a new directory called "jays" inside of that

mkdir - p birds/jays

12
New cards

What does mv introns1.txt introns2.txt accomplish?

renames introns1.txt to the name "introns2.txt"

13
New cards

What does cp file1.txt file2.txt accomplish if both files are already existing?

contents of file2 replaced by contents of file1; file1 remains intact

14
New cards

What is the purpose of "$" in the command echo $a ?

indicates that a is a variable

15
New cards

What does this command do? less ../file1.txt

it reads file1.txt located in the directory above the pwd

16
New cards

How would you sort the contents of a file, such as species names, and then store the sorted list?

sort species.txt > sortedspecies.txt

17
New cards

How could you combine the contents of two files into one file?

less file1.txt >> file2.txt

18
New cards

What would this display? species.txt | sort

nothing, because it wasn't read by cat or less before being piped to "sort"

19
New cards

Why do you need to use sort before you use uniq, as in: specieslist.txt | sort | uniq ?

unique checks for duplicates only in the next line

20
New cards

Are these equivalent? sort < animallist.txt vs. sort animallist.txt

yes

21
New cards

What does the command "wc" output?

number of lines, words, characters

22
New cards

What does sort -r do?

reverses the alphanumeric sort order

23
New cards

Which is the appropriate format to perform a calculation using the "bc" app in Unix?

echo '(1+2)*3' | bc

24
New cards

"animallist.txt" contains several lines, each line naming the animal and briefly describing it. What would this command return? grep mouse animallist.txt

Just the lines in animallist.txt that had the word "mouse" in them

25
New cards

What does this command return, using a file fruit_facts.txt that consists of several lines of text describing various fruits? grep -vi apple fruit_facts.txt

all the lines not containing apple or Apple

26
New cards

What would this command return? ls animals_folder/ | grep animal

The filenames in animals_folder that have the text "animal" in them

27
New cards

How many players listed on the Baylor football roster document posted on Canvas are juniors ("Jr.")? Use grep to solve this! Hint: -c

24

28
New cards

Using that Baylor football roster, how many Safeties ( listed as "S") on the team? Hint: -w

8

29
New cards

I foolishly wrote "grep docx -R" and, mercifully, Unix gave me a warning. How do I now exit this warning mode and return to my normal command line? [Read your notes; don't experiment on your computer]

^c

30
New cards

A "folder" is called a _______ in Unix talk

"directory"

31
New cards

pwd

"present working directory" — This tells you what folder (aka "directory") you're presently in

32
New cards

ls

"list" — This lists all the files in your pwd

33
New cards

ls dir1

"list" the files in directory "dir1", which must reside in your pwd or this won't work

34
New cards

cd dir1

"change directory" to directory dir1 — This changes your location into another directory within the

pwd

35
New cards

cd ~

Goes to your home directory

36
New cards

cd /

Goes to root of hard drive

37
New cards

cd /dir1/subdir1/subsubdir1

from the root directory, go to subdir1, then go to subsubdir1 within that. This is

called the absolute path of the target directory subsubdir1.

38
New cards

cd dir2/subdir2/subsubdir2

from the pwd, go to dir2, then to subdir2, then to subsubdir2. This is called the

relative path.

39
New cards

cd ..

Goes to the parent directory of the pwd

40
New cards

cd ../..

Goes to parent of the parent directory of the pwd

41
New cards

cd -

Goes to the previous pwd. Very useful for jumping back and forth between distant directories.

42
New cards

CTL+A

move cursor to start of a line

43
New cards

CTL+E

move cursor to end of a line

44
New cards

up & down arrows

rotate through previous commands

45
New cards

Tab

auto completion

46
New cards

Tab Tab

lists all the possible auto completion hits and then starts a fresh line, waiting for you to type in the hit

that you choose

47
New cards

Note the backslash (\) that "escapes" the character immediately downstream

This is a character, like a space,

that would trip up Unix. You are supposed to write in these backslashes yourself , but tab completion does it for you automatically

48
New cards

up arrow:

previous commands. Keep pushing until you retrieve the previous command you want. Then use your

back and front arrow to navigate through the command and delete and type to modify it

49
New cards

CTL+L

Clear screen, but you can still scroll up to see old lines

50
New cards

CMD+K

Really clears screen; all old lines gone

51
New cards

CTL+C

Escape from a program if you're stuck; gets you your prompt back

52
New cards

exit

Type this to get out of Unix

53
New cards

You still have to quit Terminal by

CMD+Q(or go to the Mac File menu at the top bar and choose "quit")

Q to quit

54
New cards

Format for the command line

Typed commands run everything in Unix.

55
New cards

Commands have options that modify how they work

and arguments that the command works on

56
New cards

Here is the format:

command -options arguments

57
New cards

ls -a ~/mydir

Here, ls is the command (list), -a is the option (list

all the files, even the hiden ones), and ~/mydir is the

argument. Mydir is the directory, residing in the home directory (~), whose files you want listed. The front slash indicates that ~ is the parent directory and mydir is the child directory within it

58
New cards

Options can be written two ways:

-a (written as a single letter) or --all (written in expanded form)

59
New cards

You can have multiple options: for example, the

ls ("list") command can take these three options all at once:-l -a -h

or -lah.

You would write it like this: ls -lah

60
New cards

ls -lah

In this case, -l is the option to print out the

long version of the output, and -h is the option to print out a "human-readable" version with file sizes in normal kilobytes rather than in bytes

61
New cards

Options can have their own arguments: -w 50

or -w50

this sets the width option of a certain command to 50

62
New cards

Rules for naming files:

no symbols except . _ - (but not as first character of name). Never use spaces. Good to use file appendages:

.txt, .py, etc. Not required, because Unix doesn't use file extensions. But including them helps humans identify the file type. Don't use a Unix command name as a file name

63
New cards

Text Editors:

These are the equivalent to Microsoft Word for Unix, but far simpler and without the GUI

64
New cards

nano, which has now completely replaced pico

Basic and easy to use. To save changes made to a file (or a new file): ^x, then y (yes), then Return.

65
New cards

nano oldfile.txt

Now you can edit the existing file oldfile.txt

66
New cards

nano newfile.txt

Now it will create newfile.txt, a new file. You will be put into a nano window. Now you can write whatever text you want. Hit Return key to get a new

line. Navigate using your arrow keys.

67
New cards

^K

cuts text in nano

68
New cards

^U

uncuts (pastes) text in nano

69
New cards

^

is the control button in nano

70
New cards

T or F: Text files should have only text, not formatting, in order for them to work properly in the following examples.

True

71
New cards

Text files:

Be sure you set the preference for having the extensions (like .txt or .docx) displayed in the file name

72
New cards

Reading Files:

You can use nano to read just fine, but there are tools solely for reading files. "Reading" means outputting to the screen

73
New cards

cat:

originally used to concatenate several files and output them to the screen as one. Now, most often used just to read a single file (cat oldfile.txt)

74
New cards

What is the problem with cat?

whole file outputted at once; have to scroll back to read it

75
New cards

more:

outputs paginated text, but doesn't allow you to go backwards through the pages completely replaced by

less

76
New cards

example of command less:

less oldfile.txt

77
New cards

less:

allows backwards scrolling. Memory efficient (loads one page at a time, not whole document). Man pages use less

78
New cards

less f

forward

79
New cards

less b

backwards

80
New cards

less q

quit

81
New cards

less g

go to the start of the doc

82
New cards

less G

go to the end of the doc

83
New cards

less h

to get help with the long list of key commands

84
New cards

example command head:

head oldfile.txt

85
New cards

head:

outputs first 10 lines of a file

86
New cards

tail:

outputs last 10 lines of a file

87
New cards

head or tail:

to check out the contents and format of a huge file

88
New cards

The man pages:

The Unix manual entry for each command ("man pages"). Automatically opens in

less, so need to know how to navigate in

less

89
New cards

man ls

opens the man pages for the command ls

90
New cards

man less

opens the man pages for the command

less

91
New cards

man cat

opens the man pages for the command

cat

92
New cards

mkdir testdir1

Makes a directory in your pwd

93
New cards

mkdir existingdir1/testdir2

Makes a directory within an existing directory in your pwd

94
New cards

mkdir -p testdir1/testdir2

Creates a directory and then another directory within the new directory

95
New cards

mkdir -vp testdir1/testdir2

creates a directory and then another directory within the new directory and outputs the result: testdir1/testdir2 (verbose)

96
New cards

mv oldfile.txt testdir1/oldfile.txt

Moves existing file to another directory (in brown is optional; you could rename it this way)

97
New cards

mv testdir1 testdir2

Moves testdir1 into testdir2. So you move directories the same way as files

98
New cards

T or F: Don't use the rename function; in Unix, we use mv (as above) if moving it

True

99
New cards

Do not use rename function in Unix. Example of renaming a file:

mv oldfile1.txt oldfile2.txt

100
New cards

mv -n

no overwriting