file and directory operations Flashcards

1
Q

Assuming you are currently in a directory containing a directory named templates. What is the command to delete templates?

A

rm -R templates

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

What is the command to delete recursively a directory and all its content? Give an example for a directory named files.

A

rm -R files

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

What is the command to list the last 250 lines from a file called myfile.txt ?
(assuming you are currently in the directory of the file)

A

tail -n myfile.txt

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

What is the command to keep listing the last 250 lines from a file called myfile.txt as it changes?
(assuming you are currently in the directory of the file)

A

tail -f -n 250 myfile.txt

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

What is the command to restart a Linux server immediately?

A

reboot now

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

What is the command to get all the IP addresses associated with a Linux installation?

A

ip addr show

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

What is the nginx command to tell nginx to reload its config?

A

nginx -s reload

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

What is the command to remove the user deploy from the wheel group on rhel?

A

gpasswd -d deploy wheel

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

What is the command to see all the groups a user called deploy belongs to?

A

groups deploy

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

What is the command to tell Linux to start a service at boot time? Give an example for a service called HelloWorld.

A

sudo systemctl enable HelloWorld

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

If you have a service with the logical name HelloWorld what is the command to get the log entries only for that service?

A

sudo journalctl -u HelloWorld

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

What is the command to get the status of a service called HelloWorld?

A

sudo systemctl status HelloWorld

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

What is the command to start a service called HelloWorld?

A

sudo systemctl start HelloWord

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

Are directory and filename case sensitive in Linux?

A

yes

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

How do you stop a service called HelloWorld?

A

sudo systemctl stop HelloWorld

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

How do you reload the services config in linux?

A

sudo systemctl daemon-reload

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

What is the command to set the timezone to EST?

A

sudo timedatectl set-timezone America/Toronto

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

On a rhel linux system where are the .service files located?

A

/etc/systemd/system/
For example:
/etc/systemd/system/HelloWorld.service

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

What is the command to ssh in a remote server at 146.190.242.245 with the root user if you are in your home directory and your key is at .ssh/id_rsa

A

ssh -i .ssh/id_rsa root@146.190.242.245

20
Q

to confirm: where are the nginx config files located on a rhel system?

A

/etc/nginx/conf.d/
For example:
/etc/nginx/conf.d/hello.conf

21
Q

What is the curl flag to ignore a self-signed certificate?

A

curl -k http://142.112.48.65:80

22
Q

Commands to shutdown a server

A

shutdown now
or
poweroff

23
Q

How can you check if 2 files have the same content?

A

cmp -s /tmp/file1 /tmp/file2

24
Q

What is the ls command flag to ignore directory?

25
What is the ls command to seach for files (not directories) that starts with a?
ls -d a*
26
What is the ls command to seach for files (not directories) that starts with a or c?
ls -d [ac]*
27
What is the command to install firewalld in rhel?
dnf install firewalld
28
Once you install firewalld what do you need to do first?
To make sure it start at boot: systemctl enable firewalld To start it now without rebooting: systemctl start firewalld
29
In firewalld how do you authorize your IP for everything if your IP is 142.112.48.65?
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="142.112.48.65" accept'
30
How do you reload firewalld after you made changes?
firewall-cmd --reload
31
How can you see the current rules in firewalld?
firewall-cmd --list-all
32
How can you permanently remove a service called cockpit?
firewall-cmd --permanent --remove-service=cockpit
33
To complete: How can you test a rule to let's say remove ssh from firewalld?
firewall-cmd --remove-service=ssh (We omit the firewalld --permanent flag
34
How can we reload systemctl?
systemctl daemon-reload
35
Where do you need to put your .service file when you deploy a .net app on a rhel server?
/etc/systemd/system/
36
Where do you put the nginx config for a .net app you deploy? Let's say for a project called hello ? Provide the full path including the name of the file.
/etc/nginx/conf.d/hello.conf
37
For the following command: firewall-cmd --remove-service=cockpit What will be the lifetime of this command?
The rule will be in effect immediately and until your reboot the server or do: firewall-cmd --reload
38
or the following command: firewall-cmd --permanent --remove-service=cockpit What will be the lifetime of this command?
The rule won't be in effect immediately. It will be in effect once you run: firewall-cmd --reload or: reboot the server
39
How can you get the status of selinux?
run: sestatus
40
How can you verify a certificate with curl?
curl --verbose https://www.google.com If we see the line: * SSL certificate verify ok. It means it's good.
41
How can you check the time from the command line in linux?
type: date
42
How do you chain commands?
Using &&
43
In a rhel system how can you get the list of the last updates installed?
sudo dnf history list last or sudo dnf history list The last flag restrict the list to the most recent updates
44
In a rhel system how can you check if updates are available without upgrading the system?
dnf check-upgrade
45
In a rhel system how do you perform an update?
dng upgrade