file and directory operations Flashcards
Assuming you are currently in a directory containing a directory named templates. What is the command to delete templates?
rm -R templates
What is the command to delete recursively a directory and all its content? Give an example for a directory named files.
rm -R files
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)
tail -n myfile.txt
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)
tail -f -n 250 myfile.txt
What is the command to restart a Linux server immediately?
reboot now
What is the command to get all the IP addresses associated with a Linux installation?
ip addr show
What is the nginx command to tell nginx to reload its config?
nginx -s reload
What is the command to remove the user deploy from the wheel group on rhel?
gpasswd -d deploy wheel
What is the command to see all the groups a user called deploy belongs to?
groups deploy
What is the command to tell Linux to start a service at boot time? Give an example for a service called HelloWorld.
sudo systemctl enable HelloWorld
If you have a service with the logical name HelloWorld what is the command to get the log entries only for that service?
sudo journalctl -u HelloWorld
What is the command to get the status of a service called HelloWorld?
sudo systemctl status HelloWorld
What is the command to start a service called HelloWorld?
sudo systemctl start HelloWord
Are directory and filename case sensitive in Linux?
yes
How do you stop a service called HelloWorld?
sudo systemctl stop HelloWorld
How do you reload the services config in linux?
sudo systemctl daemon-reload
What is the command to set the timezone to EST?
sudo timedatectl set-timezone America/Toronto
On a rhel linux system where are the .service files located?
/etc/systemd/system/
For example:
/etc/systemd/system/HelloWorld.service
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
ssh -i .ssh/id_rsa root@146.190.242.245
to confirm: where are the nginx config files located on a rhel system?
/etc/nginx/conf.d/
For example:
/etc/nginx/conf.d/hello.conf
What is the curl flag to ignore a self-signed certificate?
curl -k http://142.112.48.65:80
Commands to shutdown a server
shutdown now
or
poweroff
How can you check if 2 files have the same content?
cmp -s /tmp/file1 /tmp/file2
What is the ls command flag to ignore directory?
ls -d