Working in the linux shell

¡Supera tus tareas y exámenes ahora con Quizwiz!

Where is the system console set? A) /root/.bash_profile B) Boot kernel command line C) /etc/systemd/system/default.target D) /etc/profile

B. A system console or multiple console devices are defined in the boot loader's kernel command line.

Select all commands that create an environmental variable in the bash shell. A) export <variable_name> = value B) setenv <variable_name> C) export <variable_name>=value D) <variable_name>=<value>;export <variable_name>

C, D. The command export <variable_name>=<value> will create an environmental variable. The command <variable_name>=<value>; export <variable_name> uses a compound command (;) to create and then export the variable.

what does PID stand for?

Process ID

which of the following commands is the correct way to output both the standard output and the standard error to the same file? ls -ld /etc/roses 2>&1 errorfile ls -ld /etc/roses 1>&2 errorfile

both will accomplish the same goal

what does the # represent in the /dev/pts/#

it represents the number of logical terminal sessions running, 0 being first, 1 being second, and so on

what is the definition of a local variable in a linux shell?

local variables only exist in the memory space of the shell in which it was created. This means that if a child is spawned, the local variable will not transfer over to the new process.

what are the two clocks used by the linux OS?

real time clock (RTC) OS clock

how to you check the status of noclobber?

set -o | grep noclobber

what command can you use to change the time zone data system wide?

timedatectl set-timezone <time_zone>

which system configuration files are user-specific config information?

~/.bash_profile ~/.bashrc ~/.bash.logout

the timedatectl set-timezone "America/New_York" will set the time zone system wide to eastern time and will update the symbolic link between which two directories?

/etc/localtime /usr/share/zoneinfo

which two configuration files are system configuration files (global) that are applied to all applicable users?

/etc/profile /etc/bashrc

list the 5 configuration files/directories that will be persistent after a user logs off or the system is rebooted

/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc ~/.bash.logout

which configuration files contain a series of commands used to configure the user's working environment?

/etc/profile ~/.bash_profile

what two directories are typically used to configure the system's time zone?

/etc/timezone /usr/share/zoneinfo

which of the following functions are associated with bash shell distributions? (select all that apply) A) Command-line interpreter B) User interface C) Programing Language D) System-wide editor

A, B, C the bash shell is a user interface, command-line interpreter, and a programming language

Which of the following will redirect the standard input and standard output to the same file? (Select all that apply.) A) >& B) 1>&2 C) 2>&1 D) > E) 2 <

A, B, C. The operator >& redirects both the standard output and the standard error to the same file. The operator 1>&2 redirects the standard output and ANDs the standard error to the same file. The operator 2>&1 redirects the standard error and ANDs the standard output

the command timedatectl list-timezones will list the timezone data from what directory?

/usr/share.info

what is the method of redirecting the standard output to the same location as the standard input?

2>&1 Remember fd2 (2) is the standard error and fd1 (1) is the standard output so 2> creates/ overwrites and 2>> appends

how many virtual text terminals does linux provide?

62

what operators are used to choose an alternate standard input device?

< and << example: cat < /etc/hosts

which operator for an alternate standard output will either create a file if one does not exist or it will overwrite it if it does exist?

>

which operators are used to choose an alternate standard output device?

> and >>

which standard output operator will either create or append (add to) a file?

>> example: pwd >> filea this will add the results of PWD to the filea file

Which commands are associated with environmental variables? (Select all that apply.) A) export <variable_name>=value. B) export <variable_name> C) <variable_name>=<value> D) env E) set

A, B, D. The command export <variable_name>=<value> will create an environmental variable, and the command export <variable_name> will assign an export attribute to an existing variable. The env command will display a list of all variables in the current shell that have been assigned an export attribute.

Which commands will display system clock information? (Select all that apply.) A) date B) hwclock C) timedatectl D) localectl

A, C. The commands date and timedatectl will display the system clock (operating system clock) information.

Assume the directory /fred does not exist and the files error1 and error2 contain content. What will the command ls -ld /etc /fred > error1 2>> error2 do? (Select all that apply.) A) Overwrite the content of the file error1. B) Overwrite the content of the file error2. C) Append file error1. D) Append file error2.

A. The > operator will create a file or overwrite the content of a file. The operator >> will create a file or append the file.

what does ASCII stand for?

American Standard Code for Information Interchange

Which of the following statements concerning a local variable are true? A) The variable will be copied when a new process is spawned B) The variable will not be copied when a new process is spawned C) the variable name must be in capital letters D) the variable name must be in lowercase letters

B

User student1 has logged on an discovered a user-specific variable assignment is causing a problem. Select all actions student1 must complete to permanently resolve the problem? A) Remove the variable assignment from ~/.bashrc B) Remove the variable assignment from ~/.bash_profile C) Remove the variable from history D) Remove the variable assignment from /etc/profile

B and C remember, the ~/.bash_profile contains user environment statements and the variable must be removed from it so its no recreated the next time the user logs on

Which commands are associated with local variables? A) export <variable_name> = value B) <variable_name>=<value> C) env D) set

B, D. The command <variable_name>=<value> will create a local variable. The set command will display a list of all local variables.

What must you do if you modify settings in the file /etc/locale.conf using the localectl command? A) Reboot the system B) Execute the command source /etc/locale.conf C) Reload systemd D) Execute the command localectl

B. Anytime you modify /etc/locale.conf—either by the localect command or manually—you must read the new configuration into memory by executing the command source /etc/locale.conf.

User student1 executes the command history and sees a list of commands, but realizes the bash shell is no longer storing command history. Select all the conditions that would cause the problem. A) The file ~/.bash_history does not exist. B) The shell history option has been turned off. C) The history command is missing. D) Someone has executed the command history -c to remove command history entries from memory.

B. The history option is turned off. The file ~/.bash_history is only populated when the user logs off or the number of commands stored in memory exceed the number specified in the variable HISTSIZE. If the file ~/.bash_history is missing, the current command history would still be visible. The command history -c would remove history commands from memory, but would not prevent the addition of new commands.

where will the errors be written given the following command: ls -ld /etc/fred > error1 2>> error2 A) error1 B) error2 C) None of the above D) Both error1 and error2

B. The operator 2> redirects the standard error. In question 14, the operator 2>> appends error messages to file error2.

What does the <set> command do? A) Displays a list of shell options and their status B) Displays a list of environmental variables C) Displays a list of local variables

C

You find when executing the command rm, it actually executes the alias rm, which is equal to rm -i. Without removing the alias from memory, what command or commands would offer a way around the issue? (Select all that apply.) A) unalias rm B) /rm C) \rm D) /usr/bin/rm

C, D. The backslash ( \ ) negates the special meeting of a character; when placed in front of an aliased command, it negates the alias. You could also supply the absolute path to the command. The absolute path to a command takes precedence over aliases, functions, and builtins.

Which locale variable will override all locale category settings? A) LANG B) LOCALE C) LC D) LC_ALL

D. The LC_ALL variable will override all local category variables and the LANG variable.

what are the two types of variables in the linux shell?

Local and environmental/global

lets say you wanted to check the contents of a local variable called "SOURCE", how would you do that?

echo $SOURCE this should display the value if a value is set

what command will give you a list of all the environmental variables in the current shell?

env

what command should you use to see if a specific variable is an environmental command and has the export attribute?

env | grep <variable_name>

true or false system configuration files override user configuration files

false, its the other way around User configurations override system config files

what are the 4 file descriptors used to determine inputs, outputs, errors, etc...

fd0 stdin (standard input) fd1 stdout (standard output) rd2 stderr (standard error) fd255 keeps track of controlling information

what command is used to manage the RTC time?

hwclock

what command is used to set the RTC time and date?

hwclock -set -date "dd mm yyyy HH:MM"

what is the following command doing? ls -ld /etc/roses 2>&1 errorfile

it is listing the files available in the /etc/roses directory, since there is no directory there, it passes the error message to the file called errorfile

what is the following command doing? ls -l > filea

it is taking the output of the results from ls -l and placing it into a file named filea

what is the purpose of a pipe ( | )?

its directs the output of one command to the input of another command Example: history | grep ls the example will call the history command and the entire list of the history file. its output (the whole list) is passed to grep which searches for instances of the command ls and displays those instances instead of the whole history file list

what is the definition of an environmental (or global) variable in the linux shell?

its simply a variable that is able to spawn into child processes and other shell instances. this feature is known as 'export' allowing the variable to be 'exported' to other processes

how would you create a local variable named "life" and gave it a value of "42"?

life=42

what are 'locale' settings?

locale settings are used to set language and country specific settings (regional settings)

what command will display the the zone info path?

ls -l /etc/localtime

when a parent process spawns a child process, does the PID remain the same?

no, the PID changes for the child process before the child process is killed and returned to the parent

you try to execute the command below and get an error saying: cannot overwrite existing file. what is the problem? ls -l > filea

noclobber is turned on

what command will list the processes in the current terminal?

ps

what command will list the PPID (parent process ID) showing you what parent the process belongs to?

ps -f

Wht command can you use that will display a list of all the variables and functions that exist in the current shell process?

set

how do you turn off noclobber?

set +o noclobber

how do you turn noclobber on?

set -o noclobber

you run the command <timedatectl | grep local> and get the following output: <RTC in local TZ: no> what does this mean?

that the RTC is set to UTC

you run the command <timedatectl | grep local> and get the following output: <RTC in local TZ: yes> what does this mean?

that the RTC is set to local time

lets say you execute 'declare -p truck' and in the properties section you notice an 'x' in the properties section, what does the 'x' indicate about the variable?

that the variable is an environmental variable

what is a PID?

the PID (process ID) is a special identifier the OS assigns a program/application while its running

what is the real time clock (RTC) and what does it do?

the RTC is a battery powered circuit on the motherboard that maintains time even when the system is powered off or power is removed

what command with display the local, universal, RTC, time zone, and DLST information?

timedatectl

what command will list the available timezones?

timedatectl list-timezones

what command will set the RTC to the UTC?

timedatectl set-local-rtc 0

what command will set the RTC to the local time?

timedatectl set-local-rtc 1

what command would you use to set the system time only?

timedatectl set-time "HH:MM:SS"

what command would you use to set the system date?

timedatectl set-time "YYY-MM-DD"

what command wold you use to set both the system date and time?

timedatectl set-time "YYYY-MM-DD HH:MM:SS"

what command can you use to see if the rtc is set to local time or UTC?

timedatectl | grep local

what command will show you the device path for the current terminal session?

tty

lets say you want to create a new alias, but you need to check if the alias is already being used by another alias, function, or command. what command can you use to check?

type -a <perposed_alias_name>

in the /etc/profile configuration file, what parameter will determine what permissions will be denied when a file is created?

umask

what command would you use to unset an alias?

unalias <alias_name>

what command can be used to determine the absolute path to a command? (where the command is located/drawn from/ its executable file)

whereis -b <command>

which user configuration file calls the /etc/bashrc file ?

~/.bashrc

terminal devices my be represented by what 4 possible device paths ?

/dev/pts/# /dev/console /dev/tty /dev/ttyS

which terminal device is a virtual text terminal?

/dev/tty#

which configuration file holds system wide configurations for aliases, functions, shell configurations, and PS1 prompt configuration?

/etc/bashrc

which configuration files are used to configure how the bash shell executes?

/etc/bashrc ~/.bashrc

in the /etc/profile configuration file, what parameter will display the system's DNS name?

HOSTNAME

which terminal device represents a pseudo terminal?

/dev/pts/#

A user creates the environmental variable test in their logon shell. They then execute the command bash. Executing the command env | grep test verifies the variable is present in the child process. The user executes the command unset test. Which of the following statements is true? A) The variable test is removed from the parent and child processes. B) The variable test is removed from the child process and the child process is exited. C) The variable is removed from the child process. D) The variable is removed from the child process and becomes a local variable in the parent process.

C. Each process executes in its own memory space. Any actions in a child process will not affect the parent process. Therefore, removing a variable from a child process will not affect the variable in the parent process.

A user wants to redirect the standard output of a command to a file without overwriting the contents of the file. Which redirection operators should be applied? A) > B) 2> C) >> D) 2>>

C. The > and >> symbols redirect the stdout of a file. The >> symbol will create a file if one does not exist and append to an existing file if it does exist, so it is the best choice for this scenario. The > symbol will create a file if it does not exist, but will or overwrite the file if it does exist. The 2> operator redirects the standard error and would overwrite the file. 2>> would redirect the standard error and append the file.

Which device name represents the terminal connected to the current process? A) /dev/null B) /dev/pts/0 C) /dev/tty0 D) /dev/console

C. The device name /dev/tty0 represents the terminal connected to the current process.

Where are time zone data files stored? A) /etc/locale B) /etc/local C) /usr/share/zoneinfo D) /usr/lib/time

C. The directory /usr/share/zoneinfo contains time zone data files

The file error1 exists in the current directory, but when a user attempts to redirect the output of a command to the file, they receive the message "cannot overwrite an existing file." What is the cause of and fix to this problem? A) noglob is turned on and it must be turned off using set -o noglob. B) noglob is turned on and it must be turned off using set +o noglob. C) noclobber is turned on and it must be turned off using set -o noclobber. D) noclobber is turned on and it must be turned off using set +o noclobber.

D. The bash option noclobber prevents redirecting the standard output to an existing file. The command set +o noclobber will turn the option off.

in the /etc/profile configuration file, what parameter determines how many command lines will be stored by the history file?

HISTSIZE

lets say your system uses the alias ls='ls -color=auto' and lets say for some reason you dont want to use the color output when using the ls command. what can you do to prevent the alias from triggering?

\ using a \ before the command itself will cause the command to execute as default and ignore the alias

how do you set an alias command?

alias <alias>='<command>'

Lets say you wanted to see all the aliases associated with the command 'ls' what command would you use to accomplish this?

alias | grep ls this will output all the aliases that use the ls command

What is an ALIAS command?

an alias is simply a user created command. example: the command 'ls' by default is monochrome. but usually there is an alias prebuilt that is as follows: ls='ls -color=auto' this alias means that every time you execute the 'ls' command, that the output will use colors to indicate filetypes

how do you create an environmental (or global) variable?

by using the export command example export truck=chevy

what command will display the day, month, time (24hr), time zone, and year?

date

what command will display the current time zone information of the system?

date +%Z

what command will allow you to set the current date and time?

date -s "day month date HH:MM:SS EDT YYYY"

what command will display the UTC time?

date -u think of the '-u' as being 'U'TC time

what command will display the properties of a variable?

declare -p <variable_name>


Conjuntos de estudio relacionados

Chapter 17: function of the heart

View Set

Chapter 22: Performance and Breach of sales and lease Contracts

View Set

NCE Research and Program Evaluation B

View Set

AP U.S. History- Chapter 17 I.d.'s

View Set

Unidad 1: Preguntas- ¿Cómo te llamas?

View Set

Chapter 15 Microbiology Innate Immunity

View Set

E5 Chapter 27: Reproductive: Images-T/F-Fill in the Blank

View Set

Chapter 12: Politics and the Fate of the Union, 1824-1859

View Set

biology exam 1 natural selection

View Set