Unix Commands Flashcards

1
Q

Basic utilities are

A

grep, sed, awk, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

grep stands for

A

global regular expression print

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

basic grep command

A

grep “searchtext” filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

grep -n “searchtext” filename

A

shows the matched text with line numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

grep -vn “searchtext” filename

A

shows the results and the lines that don’t match the searchtext

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

grep - c “searchtext” filename

A

suppress printing of the matching lines but display only the number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

grep -l “searchtext” *

A

shows the file name in which the searchtext is found

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

grep -i “SEARCHTEXT” filename

A

ignores the case and displays the results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

grep -x “searchtext” filename

A

displays only the exact match

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

grep -A2 “searchtext” filename

A

displays the matched text plus additional two rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

% ls

A

lists the contents of your current working directory whose name doesn’t begin with a dot (.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

% ls -a

A

to list all files in your home directory including those that begin with a dot (.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

% mkdir

A

to make a sub directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

% cd

A

to change to a directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

% cd .

A

in unix . means current directory. this command is to stay in the same directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

. .

A

two dots means parent of the current directory

17
Q

% cd ..

A

will take you one directory up the hierarchy

18
Q

print working directory

A

pwd

19
Q

% pwd

A

prints the full path of the working directory

20
Q

% cd ~

A

change to home directory; same as cd

21
Q

% cd . .

A

change to parent directory

22
Q

cp file1 file 2

A

copy file1 and call it file2

23
Q

mv file1 file2

A

move or rename file1 to file2

24
Q

rm file

A

remove a file

25
Q

rmdir directory

A

remove a directory

26
Q

cat file

A

display a file

27
Q

more file

A

display a file one page at a time

28
Q

head file

A

display the first few lines of a file

29
Q

tail file

A

dsplay the last few lines of a file

30
Q

wc file

A

count the number of lines/words/characters in file