DQ - BASH Flashcards

1
Q

Listing the non-hidden contents of the current directory without any options

A

ls

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

Listing the non-hidden contents of path /home/dq

A

ls /home/dq

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

Listing the non-hidden contents of the current directory in long format

A

ls -l

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

Listing all contents of the current directory

A

ls -a

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

Listing all contents of /home/dq in long format, except for the directories . and ..

A

ls -Al

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

Change to directory /filename

A

cd /filename

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

Change to the parent directory of the current directory

A

cd ..

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

Change to the parent directory of the parent directory of the current directory

A

cd ../..

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

Change to your home directory

A

cd

       OR

cd ~

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

Change to the home directory of user dq

A

cd ~dq

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

Change to the previous directory

A

cd -

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

Creating a directory called my_dir

A

mkdir my_dir

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

Deleting an empty directory called my_dir

A

rmdir my_dir

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

Interactively creating a copy of file my_file1 as my_file2

A

cp -i my_file1 my_file2

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

Create a copy of directory my_dir1 as my_dir2

A

cp -R my_dir1 my_dir2

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

Deleting file my_file

A

rm my_file

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

Deleting the non-empty directory my_dir

A

rm -R my_dir

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

Moving my_file to my_dir

A

mv my_file my_dir

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

Renaming my_file as our_file

A

mv my_file our_file

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

Wildcard to match any single character

A

?

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

Wildcard to match any multitude of string characters

A

*

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

Wildcard to match k,3, z, or J

A

[k3zJ]

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

Wildcard matching any character NOT in k,3, z, or J

A

[!k3zJ]

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

Wildcard for letters (case insensitive)

A

[[:alpha:]]

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

Wildcard for numbers

A

[[:digit:]]

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

Wildcard for letters or numbers

A

[[:alnum:]]

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

Wildcard for lowercase letter

A

[[:lower:]]

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

Wildcard for uppercase letter

A

[[:upper:]]

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

All files whose name is three characters long

A

???

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

All files ending with .tsv

A

*.tsv

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

All files starting with the first 2 decades of this century, followed by an underscore

A

20[01][[:digit:]]_*

32
Q

All files starting with either a lowercase letter or zero, followed by a question mark and ending in .txt

A

[[:lower:]0]\?*.txt

33
Q

Identify current user

A

whoami

34
Q

Identify user id, group id, and groups for a user

A

id

35
Q

Identify all groups for a user

A

group

36
Q

See file’s metadata

A

stat file

37
Q

Adding execution permission to the owner on file

A

chmod u+x file

38
Q

Removing writing permission to the primary group on file

A

chmod g-w file

39
Q

Setting read and execution permissions to others on file

A

chmod o=rx file

40
Q

Add write permissions to owner, remove execute from primary group, and set others to read only

A

chmod u+w,g-x,o=r file

41
Q

Octal notation for permissions

A

R W X

4 2 1

42
Q

Changing both the ownership and the group of file1 to new_owner and new_group

A

sudo chown new_owner:new_group file1

43
Q

Changing the ownership of file while maintaining its group

A

sudo chown new_owner file

44
Q

Changing the group of file while maintaining its ownership

A

sudo chown :new_group file

45
Q

Run a command with superuser privileges

A

sudo command

46
Q

Identify the type of a command

A

type command

47
Q

Create an alias for the “date” command as d

A

alias d=date

48
Q

Remove the alias named d

A

unalias d

49
Q

Get a brief description of what an executable file does

A

whatis command

50
Q

Access the manual of an executable file

A

man command

51
Q

Access the manual of a built-in command

A

help command

52
Q

See the contents of a file with less

A

less filename

53
Q

See the contents of a file with less without wrapipng lines

A

less -S filename

54
Q

What are the five different types of commands?

A
file
builtin
alias
function
keyword

(Only the executable files and built-ins have documentation)

55
Q

Seeing the first 15 rows of filename

A

head -n 15 filename

56
Q

Seeing the last 15 rows of filename

A

tail -n 15 filename

57
Q

Counting number of lines, words, and characters in filename

A

wc filename

58
Q

Pretty printing a CSV file:

A

column -s”,” -t filename

59
Q

Extract a random sample of five rows from filename

A

shuf -n 5 filename

60
Q

Determining the type of filename

A

type filename

61
Q

Concatenate files together

A

cat file1 file2

62
Q

Concatenate files together in revers order will preserving line order

A

tac file1 file2

63
Q

Concatenate csv files together and then sort by the following in order:
Column 1 lexicographical order ascending
Column 3 numerical order descending
Columns 5 through 7 as one field

A

sort -t”,” -k1,1 -k3,3gr -k5-7 file1 file2

64
Q

Remove duplicate lines from a file

A

sort -u filename

65
Q

Selecting columns 2 , 3 and 7 through 9 on filename with : as a separator

A

cut -d”:” -f2,3,7-9

66
Q

Print the lines of a file that does not match a regex pastern. Include the line number and make the search case-insensitive, and exclude the filename prefix

A

grep -vnih ‘RegEx_Patern’ filename

67
Q

See all the lines of a file except for the first row

A

tail -n+2

68
Q

Simply pring to screen “Hello, world!”

A

echo “Hello, world!”

69
Q

Create empty files

A

touch file1 file2

70
Q

Overwrite a file by redirecting the output of a command

A

cmd >filename

71
Q

Append a file with the output of a command

A

cmd&raquo_space;filename

72
Q

Pipe the output of a command to the input of another command

A

cmd1 | cmd2

73
Q

Discard the output of a command

A

cmd >/dev/null

74
Q

Redirect stdout to a file

A

cmd >filename

                            --OR--

cmd 1>filename

75
Q

Redirecting stdout and stderr to out and err respectively

A

cmd >out 2>err

76
Q

Redirecting stdout and stderr to all_output

A

cmd >all_output 2>&1

77
Q

Redirecting stdin from the shell to a file named input_file

A

cmd