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
Q

control L

A

clears the screen; alternative to clear command

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

Delete directory Dir8

A

rm -r Dir8

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

Print output for lscpu into an existing file called fil5 without erasing the existing data within the file

A

lscpu > > fil5

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

While editing in vi (insert mode), add numbers to each line

A
  1. Press ESC
  2. :set nu
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Obtain the word count for file10

A

wc -l file10

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

Print the first 10 lines for file6

A

head -10 file6

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

Building a webpage with the message:
This is my first website, and I’m loving it!

A
  1. systemctl start httpd
  2. systemctl enable httpd
  3. cd /var/www/html/
  4. touch index.html
  5. vi index.html
  6. <h1> This is my first website, and I’m loving it! <h1>
    </h1></h1>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Without switching to the root user, install apache on your server w/o having to confirm the installation

A

sudo yum install httpd -y

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

As the root user, remove the korn shell on your server

A

yum remove ksh

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

Find the inode # of file15

A

ls -i file15

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

ls -li Dir4

A

Displays inode #, link #, permissions, user, group info and date for files in Dir4

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

Display the following message on the command line:

“We are learning and becoming better!”

A

echo We are learning and becoming better!

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

history

A

display a list of previously executed commands in the current shell session

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

Within the bash shell

echo $? is to …

A

display the exit code for the previous command, establishing if the command was successful = 0 or not >0

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

uptime

A

displays the length of time the system has been running

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

uname -m

A

kernel size/architecture

Alternate commands displaying the same information: arch, uname-i, uname -p

41
Q

Use this command to assess the system’s RAM

A

free

42
Q

lsblk

A

Checks drives and partitions

43
Q

nproc

A

Displays the number of processors (cpus)

44
Q

This command can help identify zombie processes

A

top

45
Q

Create a file called file5

A

touch file5

46
Q

Create and enter file10 simultaneously

A

vi file10

Can also use vim if installed

47
Q

pwd

A

Prints the working/current directory
Shows where you are in the system

48
Q

Exit insert mode of vi and exit and save the documents contents

A

1) Esc
2) :wq

49
Q

You are stuck in vi mode and can’t remember how to exit. This command will help you exit, by stopping the process:

A

CTL Z

50
Q

Display contents of file7 in a way that gives the contents one page a time while loading the file completely

A

more file7

51
Q

Display contents of file16 in a way that gives the contents one page at a time without loading the entire file at once

A

less file16

52
Q

grep -i

A

Used to filter text within a file by eliminating the case sensitivity of grep (by using -i)

53
Q

Command used in the command line to combine commands into one command

A

The Pipe (|)

(The Pipe)

54
Q

Simultaneously create file17 and direct the output from the command iostat into file 17

A

iostat > file17

55
Q

Add directed output from the nproc command into an existing file called file24

A

nproc > > file24

56
Q

yum repolist

A

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
Q

yum whatprovides

A

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
Q

How to confirm that your system is connected to the internet?

A

ping [website address]
Gives the public ip address as verification

59
Q

sudo su

A

Switch to root user

60
Q

git init

A

Initialize a local repository (turns a folder/directory into a local repository)

61
Q

git switch feature1

A

Change from current branch to feature1 branch

62
Q

Switch from root user to regular user status

A

exit

63
Q

git checkout feature2

A

Switch from current branch to feature2 branch

64
Q

Rename the master branch to main branch

A

git branch -M main

65
Q

Show the state of the files that are to be sent to a cloud based repository

A

git status

66
Q

You’ve committed file1, but realized it was supposed to be file2. What steps do you take to correct this error?

A

1) git log - will give the commit ID
2) git reset [commit ID]

67
Q

Link local repository (branch1) to GitHub

A

1) git remote add origin [url to GitHub repository]
2) git remote -v to verify
3) git push -u origin branch1

68
Q

df

A

displays disk space used and available

69
Q

sudo useradd

A

Add user account

70
Q

sudo groupdel

A

Delete group account

71
Q

Create a hard link from file2 to file24

A

sudo ln file2 file24

72
Q

ls -s file8 file28

A

Soft link or symlink b/w file8 and file28

73
Q

Filter out the first column of information from /etc/passwd file

A

awk -F “:” ‘{print$1}’ /etc/passwd

74
Q

awk -F “/” ‘{print$4}’ /etc/passwd

A

Filtering out the 4th column information of file /etc/passwd

75
Q

ll | awk ‘{print$2}’

A

Filtering out second row of ll output using the pipe command

76
Q

sed -i ‘[1]i [Message]’ file20

A

Entering message into file 20 w/o using vi command

77
Q

Steps to login w/o ssh key

A

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
Q

ls -a

A

Displays all directories w/in a directory including hidden directories

79
Q

tail -6 file10

A

Display the last 6 lines of file 10

80
Q

man

A

Gives manual for any given command :)

81
Q

crontab -u Andre -e

A

Edit crontab for user Andre

82
Q

As the current user, view the crontab entries

A

crontab -l

83
Q

Execute the sleep command in the background for 60 seconds

A

sleep 60 &

84
Q

fg 22

A

Calls job 22 to the foreground from the background

85
Q

echo $first_name

A

Displays the value for the variable first_name

86
Q

Declare the value, Jason, for the variable, User 1

A

User1=Jason

87
Q

Print (or call) environment variables

A

env or printenv

88
Q

export Group = Security

A

Changing the status of the variable Group from a regular variable to an environment variable

89
Q

What command can you use to check the port on which apache is listening?

A

sudo netstat -anpl | grep httpd

90
Q

To create a new database and name a database we run the following MySQL command:

A

create database [database_name]

91
Q

What’s the code to build a docker image?

A

docker build -t [image_name] .

92
Q

Name 3-5 common commands you may find in a Dockerfile

A
  • FROM [image and tag]
  • RUN [commands]
  • COPY ./[index_file_name] [path]
  • CMD [command] -D FOREGROUND
  • EXPOSE [port]
93
Q

What docker command prints the gateway address and container ip address?

A

docker inspect [container_ID]

94
Q

Please give me the docker command to remove all docker images

A

docker rmi -f $(docker images -q)

95
Q

What is the docker command required to run a container w/o exiting from that container?

A

docker run -it [image_id] bash

96
Q

What is the result of this command:
docker node ls

A

Provides a list the nodes in a docker swarm cluster

97
Q

What command is used to declare an environment variable

A

export [variable_name]=[variable value]

98
Q

How do you undeclare an environment variable previously declared?

A

unset [variable_name]