DQ - BASH Flashcards

(77 cards)

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
Wildcard for numbers
[[:digit:]]
26
Wildcard for letters or numbers
[[:alnum:]]
27
Wildcard for lowercase letter
[[:lower:]]
28
Wildcard for uppercase letter
[[:upper:]]
29
All files whose name is three characters long
???
30
All files ending with .tsv
*.tsv
31
All files starting with the first 2 decades of this century, followed by an underscore
20[01][[:digit:]]_*
32
All files starting with either a lowercase letter or zero, followed by a question mark and ending in .txt
[[:lower:]0]\?*.txt
33
Identify current user
whoami
34
Identify user id, group id, and groups for a user
id
35
Identify all groups for a user
group
36
See file's metadata
stat file
37
Adding execution permission to the owner on file
chmod u+x file
38
Removing writing permission to the primary group on file
chmod g-w file
39
Setting read and execution permissions to others on file
chmod o=rx file
40
Add write permissions to owner, remove execute from primary group, and set others to read only
chmod u+w,g-x,o=r file
41
Octal notation for permissions
R W X | 4 2 1
42
Changing both the ownership and the group of file1 to new_owner and new_group
sudo chown new_owner:new_group file1
43
Changing the ownership of file while maintaining its group
sudo chown new_owner file
44
Changing the group of file while maintaining its ownership
sudo chown :new_group file
45
Run a command with superuser privileges
sudo command
46
Identify the type of a command
type command
47
Create an alias for the "date" command as d
alias d=date
48
Remove the alias named d
unalias d
49
Get a brief description of what an executable file does
whatis command
50
Access the manual of an executable file
man command
51
Access the manual of a built-in command
help command
52
See the contents of a file with less
less filename
53
See the contents of a file with less without wrapipng lines
less -S filename
54
What are the five different types of commands?
``` file builtin alias function keyword ``` (Only the executable files and built-ins have documentation)
55
Seeing the first 15 rows of filename
head -n 15 filename
56
Seeing the last 15 rows of filename
tail -n 15 filename
57
Counting number of lines, words, and characters in filename
wc filename
58
Pretty printing a CSV file:
column -s"," -t filename
59
Extract a random sample of five rows from filename
shuf -n 5 filename
60
Determining the type of filename
type filename
61
Concatenate files together
cat file1 file2
62
Concatenate files together in revers order will preserving line order
tac file1 file2
63
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
sort -t"," -k1,1 -k3,3gr -k5-7 file1 file2
64
Remove duplicate lines from a file
sort -u filename
65
Selecting columns 2 , 3 and 7 through 9 on filename with : as a separator
cut -d":" -f2,3,7-9
66
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
grep -vnih 'RegEx_Patern' filename
67
See all the lines of a file except for the first row
tail -n+2
68
Simply pring to screen "Hello, world!"
echo "Hello, world!"
69
Create empty files
touch file1 file2
70
Overwrite a file by redirecting the output of a command
cmd >filename
71
Append a file with the output of a command
cmd >>filename
72
Pipe the output of a command to the input of another command
cmd1 | cmd2
73
Discard the output of a command
cmd >/dev/null
74
Redirect stdout to a file
cmd >filename --OR-- cmd 1>filename
75
Redirecting stdout and stderr to out and err respectively
cmd >out 2>err
76
Redirecting stdout and stderr to all_output
cmd >all_output 2>&1
77
Redirecting stdin from the shell to a file named input_file
cmd