Linux Commands Flashcards

1
Q

bash

A

Drops you to prompt
Let’s you know you’re in the bash shell
Ubuntu runs this
(mint too since it’s a variation on Ubuntu)

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

echo $SHELL

A

Shows which shell you are in by folder

$SHELL = Variable that’s stored in the shell

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

csh

A

C shell

Based around C programming language

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

tshell

A

Variation on the csh (cshell)

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

Why in a terminal do you see directory structure?

A

Linux treats everything as a file. So the folder structure is used to organize everything.

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

For shells, what does CLI stand for?

A

Command line interpreter

The shell interprets commands as instructions to give the computer

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

What’s the difference between internal commands and external commands?

A

Internal commands are anything the shell does by default. Or built into the shell.

External commands are commands that call to a third party program or runs through the shell out to a third party program.

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

ls -l

ls -f | more

ls -lah

A

LS lists the files and folders in the working directory

ls -L gives the long output. Displays file details user and group that owns them including read write permissions.

-F shows folders from files because a file doesn’t need an extension in Linux

  • a show all including hidden
  • h human readable, files sizes as MB etc.
  • la long and show all

You can also use MAN to learn about sorting by size, etc.

MORE displays one screen at a time

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

pwd

A

Print working directory

Shows which folder you’re in currently.

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

Username@domain: ~

^^ this is the command prompt, what does the ~ mean?

A

It means we are in the home directory for that user
Example
/home/Username
Normally that would be the current working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
cd 
cd by itself 
cd /
cd /folder/folder
cd ..
A

Change directory.
Same as windows

Cd by itself goes to home folder

cd / takes you to root

cd /directory/folder takes you directly to that directory (from the root of the folder structure)

cd .. takes you up one folder in the directory structure

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

What’s the difference between exit and logout?

A

When in a GUI, exit will log you out and close the terminal window.

When you are in a LOGON SHELL, where all you see is the command line, Logout logs you out. Doesn’t shut down system or anything else etc.

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

What are the ways you can pull CLI commands from a command prompt?

Can you run these commands again?

A

Up and down arrows to select previous commands, but when SSH’d in you may not be able to use arrow keys.

history command shows the last 500 commands
Use !501 to run the 501st command
Use !! To run the last command. Helpful when remoting in.
These are stored in a text document locally.
~/.bash_history

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

What does .sh_history keep a record of?

A

Each shell maintains its own history separate from one another.

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

At the prompt with a long string,
How can you move forward and backward through the arguments?

How do you move to the front or the back of the string?

A

Esc+F or B = jump forward or backward through the arguments

Ctrl+a or e = Jump to the front or the end of the string (like the tv show)

Helpful for when connecting remotely to a server or in a VM because arrow keys will not work.

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

How do you create variables?

When interacting with variables on Linux, how do you set a variable?

And how do you print (display) a variable’s current value?

A

Example to set prompt name
PS1=“My Prompt:”

set $PS1
Sets variable values

unset $PS1
Removes All values from variable

echo $PS1
Prints variable value
You need the $ to call on variables

These variables are temporary unless added to the shell’s config profile
Bash RC or .profile, etc.

17
Q

What command shows all variables?

A

env

Environmental command shows a list of all the system variables that are set

18
Q

Which command helps you find information on a specific command?

Which command is used to find a command if you don’t recall the name?

A

Man [command]
Manual

2 options:
Most Linux distros use a whatis database command that’s a list of all commands and functions/descriptions on that distribution.

Finds a command based on what it does

apropos [keyword]
whatis [keyword]

19
Q

sudo

A

Runs command as Super user

20
Q

yum

A

Installs software and packages

21
Q

What does naming a file starting with a “.” do?

A

This hides the file by default

22
Q

File names in Linux maintain posix compliance. Give an example of one of the file name requirements.

A

Case sensitive unlike windows

Looks like Filenames can be set by the OS
Linux can have filenames up to 255 characters long, not counting the path.

23
Q

mv

mv * ../test

A

Rename or Move files or directories

Moves all files to a folder found in the parent directory (back one level) called test

24
Q

cp
cp * ./test
cp -R * ./test

A

Copies files or directories

cp * ./test
Copies all files to folder test, found in PWD

cp -R * ./test
Copy all folders and files to folder test, found in PWD.

25
Q

mkdir

A

Make directories

26
Q

rm
rm -r
rm -rf

A

Remove directory / delete

rm -r
Removes folders and files (recursive)

rm -rf
Forces the removal of they are protected.

27
Q

who

A

Shows who is logged in

28
Q

clear

A

Clears the terminal window

29
Q

systemctl

A

(Start / stop / enable / disable) manages OS services and start-ups

30
Q

firewalld-cmd

A

CentOS FW

31
Q

nano

A

Text editor

Not installed with minimum install

32
Q

touch [name]

A

Creates an empty file by a name you specified