Environment Variables, Aliases Flashcards

1
Q

When performing a long listing what do the objects show?

A

permissions links owner group size datemodified file/directory
i.e drwxr-xr-x. 2 cloud_user cloud_user 6 Oct 15 16:20 Desktop

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

How do you list files/directories?

A

ls

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

How do you list files/directories in order of size?

A

ls -S

i.e ls -lS

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

How do you do a detailed listing of files/directories?

A

ls -l

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

How do you do a reverse listing?

A

ls -r

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

How do you list a directory including its contents?

A

ls -R

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

How do you list in order of modification time?

A

ls -t

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

How do you get a listing of environment variables?

A

env

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

How do you view the directory locations bash will look in when entering a command?

A

echo “$PATH”

contained in the PATH environment variable

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

How do you reference something in the current directory?

A

.

i. e ./script1
* dot source

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

What is the command to list the current user?

A

whoami

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

What is the command to switch user?

A

su

i.e su user2

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

What is the command to switch the the root user?

A

su - *resets env variables

su *just switches user

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

What is the command to run as root interactively without the root password?

A

sudo -i

*useful if no root password exists (common)

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

What is the command to print the name of the OS?

A

uname

-r release -v kernel build -m/-p architecture -o os name -a all

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

What is the command to print the current working directory?

A

pwd

echo “$PWD”

17
Q

What is the command to change to the home directory?

A

cd

cd ~

18
Q

What is the command to change a directory up once

A

cd ..

19
Q

What is the command to return to the previous directory?

A

cd -
*used OLDPWD env variable
echo $OLDPWD

20
Q

What is the command to print a history of commands typed?

A

history

*located in ~/.bash_history

21
Q

What is the command to print the contents of a file to the screen?

A

cat

22
Q

How do you see the maximum commands the history file will store?

A

echo $HISTFILESIZE

23
Q

How do you see the configuration of the history command?

A

echo $HISTCONTROL

i.e ignoredups *ignores consecutively repeated commands

24
Q

How do you execute a specific command in denoted in history?

A

!

i.e !14

25
Q

What configuration scripts are executed upon signing in through the login shell?

A

1 /etc/profile - sets up environment variables
2 ~/.bash_profile | ~/.bash_login | ~/.profile - first file executed, sets up user env variables
3 ~/.bashrc - sets up user created functions and command aliases
4 /etc/bashrc - sets up system wide functions and command aliases

26
Q

What script will be executed at user logout if it exists?

A

~/.bash_logout

*user defined commands can be placed here to perform actions at logout

27
Q

What configuration scripts are executed upon opening a non login shell (standard)?

A

1 ~/.bashrc - sets up user created functions and commands

2 /etc/bashrc - sets up system wide functions and command aliases

28
Q

How do you modify the $PATH env variable?

A

append: PATH=$PATH:/directory
prepend: PATH=/directory:$PATH

29
Q

How do you create a variable and use it in other shells?

A

export VARIABLENAME

30
Q

What is the structure that constitutes a command?

A

Command Option Argument

i.e ls -l file

31
Q

What is the command to create an alias?

A

alias =’’

i.e alias lr=’ls -R’

32
Q

What is the command to remove a created alias?

A

unalias

i.e unalias lr

33
Q

How do you create a persistent alias?

A

Append alias to ~/.bashrc

34
Q

How do you get a listing of shell and environment variables?

A

set