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?

A

ls -d

25
Q

What is the ls command to seach for files (not directories) that starts with a?

A

ls -d a*

26
Q

What is the ls command to seach for files (not directories) that starts with a or c?

A

ls -d [ac]*

27
Q

What is the command to install firewalld in rhel?

A

dnf install firewalld

28
Q

Once you install firewalld what do you need to do first?

A

To make sure it start at boot:
systemctl enable firewalld
To start it now without rebooting:
systemctl start firewalld

29
Q

In firewalld how do you authorize your IP for everything if your IP is 142.112.48.65?

A

firewall-cmd –permanent –add-rich-rule=’rule family=”ipv4” source address=”142.112.48.65” accept’

30
Q

How do you reload firewalld after you made changes?

A

firewall-cmd –reload

31
Q

How can you see the current rules in firewalld?

A

firewall-cmd –list-all

32
Q

How can you permanently remove a service called cockpit?

A

firewall-cmd –permanent –remove-service=cockpit

33
Q

To complete: How can you test a rule to let’s say remove ssh from firewalld?

A

firewall-cmd –remove-service=ssh
(We omit the firewalld –permanent flag

34
Q

How can we reload systemctl?

A

systemctl daemon-reload

35
Q

Where do you need to put your .service file when you deploy a .net app on a rhel server?

A

/etc/systemd/system/

36
Q

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.

A

/etc/nginx/conf.d/hello.conf

37
Q

For the following command:
firewall-cmd –remove-service=cockpit
What will be the lifetime of this command?

A

The rule will be in effect immediately and until your reboot the server or do:
firewall-cmd –reload

38
Q

or the following command:
firewall-cmd –permanent –remove-service=cockpit
What will be the lifetime of this command?

A

The rule won’t be in effect immediately. It will be in effect once you run:
firewall-cmd –reload
or:
reboot the server

39
Q

How can you get the status of selinux?

A

run:
sestatus

40
Q

How can you verify a certificate with curl?

A

curl –verbose https://www.google.com
If we see the line:
* SSL certificate verify ok.
It means it’s good.

41
Q

How can you check the time from the command line in linux?

A

type:
date

42
Q

How do you chain commands?

A

Using &&

43
Q

In a rhel system how can you get the list of the last updates installed?

A

sudo dnf history list last
or
sudo dnf history list

The last flag restrict the list to the most recent updates

44
Q

In a rhel system how can you check if updates are available without upgrading the system?

A

dnf check-upgrade

45
Q

In a rhel system how do you perform an update?

A

dng upgrade