Command Deck Flashcards

Review command function

1
Q

ll

A

list directories/files with permissions details
Similar to ls-l

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

rm

A

removes a file/deletes a file

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

rm -r

A

removes/deletes a directory or file

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

Go back to the root directory (“/root” NOT “/”)

A

cd ~

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

Make a copy of dir4 to be copied into dir5

A

cp -r dir4 dir5

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

Change the name of file good_burger to bad_burger

A

mv good_burger bad_burger

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

Move file3 into dir1

A

mv file3 dir1/

The files and folders have to be in the same directory level to move files into folders

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

Display the contents of file5 with numbered lines

A

cat -n file5

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

Find file study.log in the system

A

find / -name study.log

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

Login to the following server remotely using vsc:

Server Name: 198.58.119.40
Username: u5bt
Password: abc

A

Command:
ssh u5bt@198.58.119.40

Prompt:
user u5bt
enter password: enter abc

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

Login to a LightSail Centos 7 server remotely with the public ip_address 184.24.68.30 using key access. The key is deVops

A
  1. cd into Downloads folder to access the key
  2. type: ssh -i deVops.pem centos@184.24.68.30
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Display the following message in the command line:

Thank you God for this opportunity. I pray for future success.

A

echo Thank you God for this opportunity. I pray for future success.

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

whoami

A

Gives your user id

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

id -r user2

A

Print real user ID for user2

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

id -G user3

A

Print effective group ID for user3

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

iostat

A

Check cpu, os, kernel name and version, hard drive info, server size, cpu percentage, date, ip address

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

Run an inventory on the server

A
  1. Check # hard drives - iostat or lsblk
  2. Check # of cpus (and data) - iostat or nproc (lscpu)
  3. Check cpu percentage - iostat
  4. Check kernel type and name - uname + uname -r
  5. Check OS type - cat /etc/*release
  6. Check memory - top or free
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

lscpu

A

access system inventory
* brand, model, model name, speed and so on

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

List commands required to obtain cpu information

A
  1. lscpu
  2. nproc
  3. iostat
  4. top
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

List commands required to obtain hard drive information

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

Obtain OS name, version and associated information on a Ubuntu server

A

lsb_release -a

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

Obtain OS name, version and associate information on a Centos server

A
  1. cat /etc/os-release
    OR
  2. cat /etc/*release
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Obtain kernel name

A

uname or uname -s

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

Command for kernel release (version)

A

uname -r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
control L
clears the screen; alternative to clear command
26
Delete directory Dir8
rm -r Dir8
27
Print output for lscpu into an existing file called fil5 without erasing the existing data within the file
lscpu > > fil5
28
While editing in vi (insert mode), add numbers to each line
1. Press ESC 2. :set nu
29
Obtain the word count for file10
wc -l file10
30
Print the first 10 lines for file6
head -10 file6
31
Building a webpage with the message: This is my first website, and I’m loving it!
1. systemctl start httpd 2. systemctl enable httpd 3. cd /var/www/html/ 4. touch index.html 5. vi index.html 6.

This is my first website, and I’m loving it!

32
Without switching to the root user, install apache on your server w/o having to confirm the installation
sudo yum install httpd -y
33
As the root user, remove the korn shell on your server
yum remove ksh
34
Find the inode # of file15
ls -i file15
35
ls -li Dir4
Displays inode #, link #, permissions, user, group info and date for files in Dir4
36
Display the following message on the command line: "We are learning and becoming better!"
echo We are learning and becoming better!
37
history
display a list of previously executed commands in the current shell session
38
Within the bash shell echo $? is to ...
display the exit code for the previous command, establishing if the command was successful = 0 or not >0
39
uptime
displays the length of time the system has been running
40
uname -m
kernel size/architecture Alternate commands displaying the same information: arch, uname-i, uname -p
41
Use this command to assess the system's RAM
free
42
lsblk
Checks drives and partitions
43
nproc
Displays the number of processors (cpus)
44
This command can help identify zombie processes
top
45
Create a file called file5
touch file5
46
Create and enter file10 simultaneously
vi file10 Can also use vim if installed
47
pwd
Prints the working/current directory Shows where you are in the system
48
Exit insert mode of vi and exit and save the documents contents
1) Esc 2) :wq
49
You are stuck in vi mode and can't remember how to exit. This command will help you exit, by stopping the process:
CTL Z
50
Display contents of file7 in a way that gives the contents one page a time while loading the file completely
more file7
51
Display contents of file16 in a way that gives the contents one page at a time without loading the entire file at once
less file16
52
grep -i
Used to filter text within a file by eliminating the case sensitivity of grep (by using -i)
53
Command used in the command line to combine commands into one command
The Pipe (|) | (The Pipe)
54
Simultaneously create file17 and direct the output from the command iostat into file 17
iostat > file17
55
Add directed output from the nproc command into an existing file called file24
nproc > > file24
56
yum repolist
Used to display a list of enabled YUM repositories on your system. It provides information about the repositories configured on your system and their respective status.
57
yum whatprovides
Used to find which package provides a specific file or command. This is particularly helpful when you need to locate the package that contains a particular file or command you want to use.
58
How to confirm that your system is connected to the internet?
ping [website address] Gives the public ip address as verification
59
sudo su
Switch to root user
60
git init
Initialize a local repository (turns a folder/directory into a local repository)
61
git switch feature1
Change from current branch to feature1 branch
62
Switch from root user to regular user status
exit
63
git checkout feature2
Switch from current branch to feature2 branch
64
Rename the master branch to main branch
git branch -M main
65
Show the state of the files that are to be sent to a cloud based repository
git status
66
You've committed file1, but realized it was supposed to be file2. What steps do you take to correct this error?
1) git log - will give the commit ID 2) git reset [commit ID]
67
Link local repository (branch1) to GitHub
1) git remote add origin [url to GitHub repository] 2) git remote -v to verify 3) git push -u origin branch1
68
df
displays disk space used and available
69
sudo useradd
Add user account
70
sudo groupdel
Delete group account
71
Create a hard link from file2 to file24
sudo ln file2 file24
72
ls -s file8 file28
Soft link or symlink b/w file8 and file28
73
Filter out the first column of information from /etc/passwd file
awk -F ":" '{print$1}' /etc/passwd
74
awk -F "/" '{print$4}' /etc/passwd
Filtering out the 4th column information of file /etc/passwd
75
ll | awk '{print$2}'
Filtering out second row of ll output using the pipe command
76
sed -i '[1]i [Message]’ file20
Entering message into file 20 w/o using vi command
77
Steps to login w/o ssh key
1) vi /etc/ssh/sshd_config 2) :set nu 3) Change PasswordAuthetication no to PasswordAuthentication to yes 4) systemctl restart sshd 5) Create a user and user password 6) Log in to visual studio code remotely using the username and password
78
ls -a
Displays all directories w/in a directory including hidden directories
79
tail -6 file10
Display the last 6 lines of file 10
80
man
Gives manual for any given command :)
81
crontab -u Andre -e
Edit crontab for user Andre
82
As the current user, view the crontab entries
crontab -l
83
Execute the sleep command in the background for 60 seconds
sleep 60 &
84
fg 22
Calls job 22 to the foreground from the background
85
echo $first_name
Displays the value for the variable first_name
86
Declare the value, Jason, for the variable, User 1
User1=Jason
87
Print (or call) environment variables
env or printenv
88
export Group = Security
Changing the status of the variable Group from a regular variable to an environment variable
89
What command can you use to check the port on which apache is listening?
sudo netstat -anpl | grep httpd
90
To create a new database and name a database we run the following MySQL command:
create database [database_name]
91
What's the code to build a docker image?
docker build -t [image_name] .
92
Name 3-5 common commands you may find in a Dockerfile
* FROM [image and tag] * RUN [commands] * COPY ./[index_file_name] [path] * CMD [command] -D FOREGROUND * EXPOSE [port]
93
What docker command prints the gateway address and container ip address?
docker inspect [container_ID]
94
Please give me the docker command to remove all docker images
docker rmi -f $(docker images -q)
95
What is the docker command required to run a container w/o exiting from that container?
docker run -it [image_id] bash
96
What is the result of this command: docker node ls
Provides a list the nodes in a docker swarm cluster
97
What command is used to declare an environment variable
export [variable_name]=[variable value]
98
How do you undeclare an environment variable previously declared?
unset [variable_name]