Linux+ 1.1 The shell

What is the result of the "uname -a" command?

All system information is displayed on the screen.

What command should you use to see a list of all the commands you recently used at the command prompt?

history

All users at your site are using the Bash shell. You want to set a variable that will apply to every user and always have the same value. What file would you place this variable in?

/etc/profile

Which of the following options is the standard shell for most Linux users?

Bourne shell
Bourne-again shell (bash)
Korn
Tcsh
C-shell

bash

You have the my app executable file. It is found in the current working directory, but not in the command path. What should you type at the command prompt to start the my app file and replace the shell with the my app process? (Tip: Enter the command as if at the command prompt.)

exec ./myapp

Your default run level on your Linux system is set to textual, multiple-user mode; however, you want the X Windows System to launch when you log into the system. Which file should you use?

~/bash_login

You are working at the command line and need to start a new Bourne-again shell (bash) session. What should you type?

bash

Which of the following files would you use to create aliases that are applied when a specific user starts a BASH session? (Select two.)

/etc/profile
~/.bash_logout
~/.bashrc
~/.profile

~/.bashrc ~/.profile

What line must you add to /etc/profile to make sure /sbin/custom is always part of the PATH, but also keep the current entries in the PATH statement?

PATH=PATH:/sbin/custom; export PATH

You have an executable file named ni that allows you to save a snapshot of your network information with the date and time into a log file. The file is in the /root directory, and /root is the current working directory. How would you run the executable file? (Select two.)

./ni
source ni
ni
/root/ni

./ni /root/ni

Which command will display the present working directory?

pwd

After a user starts a BASH session and the scripts in the /etc/profile are applied, what is the next file that could affect the shell session?

~/.bash_login
~/.profile
~/.bash_logout
~/.bash_profile

Login shells execute the configuration scripts they use in the following order: /etc/profile ~/.bash_profile (If this file is found, the shell does not look for additional configuration files) ~/.bash_login (If this file is found, the shell does not look for additional configuration files) ~/.profile (This file only executes in the absence of the preceding two)

A user is requesting that each time she logs in, a particular entry be written to a log file. This will only apply to her and she is using the Bash shell. In which configuration file would you make an entry for this action to stake place?

~/.profile

Shell Facts

The Linux shell is the Command Line Interface (CLI) or Text User Interface (TUI) that administrators use to control a Linux operating system. Users and programs use the shell to send commands to the system. A shell might be opened inside a Graphical User Interface (GUI), or might be the sole method used to run the computer. Although most Linux distributions now include a graphical interface, and many administration tools have been converted to a graphical format, many tasks are best performed from the command prompt. In addition, while graphical elements vary between distributions, shell commands are more likely to be consistent between distributions. The following table describes many common shell types: Shell Type Description bash The Bourne-again shell (bash) is the standard shell used in most Linux computers. It uses commands similar to a UNIX shell. Bash includes features such as: Command completion when pressing the tab key Command history Improved arithmetic functions sh The Bourne shell is an earlier version of the Bash shell, and is similar in many ways. Sh is the original shell created by Steve Bourne. ksh The Korn shell was developed by David Korn. Ksh has scripting features not found in bash. csh The C-shell uses syntax similar to syntax used in the C programming language. tcsh The tcsh shell is an improved version of csh. It offers command line editing and completion features not available with csh. Despite their differences, all shells share some common characteristics: A Linux system can use multiple shells at the same time. A list of shells is stored in the /etc/shells file. All shells are interfaces with the kernel, separate and distinct from it. Shells are run both interactively by end users and automatically by the computer's processes. Shells can run within one another either interactively when a user starts a second shell from the first shell's command line, or automatically by scripts or programs. Shells use configuration files to establish their operating environments.

Shell Commands Introduction

The Linux shell is the command line interface (CLI) or text user interface (TUI) that administrators use to control a Linux computer. While many Linux distributions offer a Graphical User Interface (GUI) that can perform the same tasks, the Linux+ exam tests only for command line tasks. Keep in mind the following tips for working in the shell: The tilde symbol (~) in the prompt indicates the present working directory is the home directory of the current user. The command path is the set of directories in which Linux searches to find executable files for the commands typed into the shell prompt: The path does not include the present working directory. To see the path, type echo $PATH. To add a directory to a path, type PATH=$PATH:directory_path. To execute programs: Type the executable name in the present working directory if the program is in the command path. Type ./filename to run an executable in the present working directory. (./ indicates the present working directory.) Type the full pathname to the file to run an executable from anywhere. File names and paths are case-sensitive. Type the beginning of the name, then press Tab to complete a file, command, or directory name. (Press Tab twice if there is more than one possible file, command, or directory name.) Press the up arrow at the command prompt to print the last command. Press it again to scroll through all previous commands. The following table describes several common commands used from the shell.

pwd

Show the present working directory

whoami

Display the current username

uname

Print system information. Be aware of the following uname options: -a prints all system information. -o prints the operating system. -p prints the processor's architecture type.

su

Switch users in the shell prompt. Be aware of the following su options: su -l user_name switches to the specified user in a login shell. su user_name (without the dash, but with the username) switches to the user. su - user_name (with the dash and username) switches to the user and loads the user's environmental variables. su - (with the dash, but no username) switches to the root user and loads the root user's environmental variables. The root user account is the Linux system superuser. The root user can perform any task; some utilities do not work if the administrator is not logged in as the root user. su (no dash or username) switches to the root user and but does not load the root user's environmental variables. Linux uses different prompt symbols to indicate the current user: # indicates the current user is the root user. $ indicates the current user is a normal user. Note: su requires the password of the user except when switching from root to a normal user.

exit

To exit the login shell or back to the original user after using the su command

exec

Execute an executable and to replace the shell with the new process created by the executable file

cd

Change directories. For example when the /usr directory is the current directory: cd bin changes to the bin directory in the current directory. cd /usr/bin changes to the bin directory from anywhere in the file system.

ls

Show names of files and directories in the current directory. The ls command commonly uses the following options: -a shows all files and directories, including hidden files. -l shows information about files including size, permissions, owner, and modified date. -d displays only directories. -s sorts files by size. -X sorts by extension. Many distributions have a color scheme for different file types: Directories are blue. Text files are white. Links are cyan. Image files are magenta. Compressed files are red.

history

See all commands in the history queue. The -c option clears the history list. Note: History command queues are separate for each user. A command typed as one user cannot be used after using the su command to switch to another user.

clear

See all commands in the history queue. The -c option clears the history list. Note: History command queues are separate for each user. A command typed as one user cannot be used after using the su command to switch to another user.

chsh

Change the default shell. Be aware of the chsh options: -s changes to a different installed shell. The command prompts for a password. -l lists all installed shells. For example, chsh -s /bin/ksh changes the default shell for the user to the Korn shell if it is installed on the computer.

Shell Configuration Facts

Shell configuration files are scripts that execute when a shell starts. The shell type determines which shell configuration files are executed. Shell types include: Login shells run when the system starts and is only using the Text User Interface (TUI) as the user interface. Non-login shells run when the system boots into a Graphical User Interface (GUI) and a user starts a terminal session. The following are the names of the files used when the shell starts: Configuration File Description Used by shell type ~/.bashrc ~/.bashrc stores shell preferences for individual users. non-login (login on some distributions) /etc/profile /etc/profile stores system-wide configuration commands and is used primarily to set environment variables. login ~/.bash_profile ~/.bash_profile stores shell preferences for individual users. login ~/.bash_login ~/.bash_login stores commands that execute when a user logs in. login ~/.profile ~/.profile stores configuration preferences similar to /etc/profile, but for individual users. login ~/.bash_logout ~/.bash_logout stores commands that execute when a user logs out. login Be aware of the following: Login shells execute the configuration scripts they use in the following order: /etc/profile ~/.bash_profile (If this file is found, the shell does not look for additional configuration script files) ~/.bash_login (If this file is found, the shell does not look for additional configuration script files) ~/.profile (This file only executes in the absence of the preceding two) The su -l command switches to a user into a login shell; however, without the -l option, a non-login shell is started.

Linux+ 1.1 The shell - Subjecto.com

Linux+ 1.1 The shell

Your page rank:

Total word count: 1833
Pages: 7

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

What is the result of the "uname -a" command?

All system information is displayed on the screen.

What command should you use to see a list of all the commands you recently used at the command prompt?

history

All users at your site are using the Bash shell. You want to set a variable that will apply to every user and always have the same value. What file would you place this variable in?

/etc/profile

Which of the following options is the standard shell for most Linux users?

Bourne shell
Bourne-again shell (bash)
Korn
Tcsh
C-shell

bash

You have the my app executable file. It is found in the current working directory, but not in the command path. What should you type at the command prompt to start the my app file and replace the shell with the my app process? (Tip: Enter the command as if at the command prompt.)

exec ./myapp

Your default run level on your Linux system is set to textual, multiple-user mode; however, you want the X Windows System to launch when you log into the system. Which file should you use?

~/bash_login

You are working at the command line and need to start a new Bourne-again shell (bash) session. What should you type?

bash

Which of the following files would you use to create aliases that are applied when a specific user starts a BASH session? (Select two.)

/etc/profile
~/.bash_logout
~/.bashrc
~/.profile

~/.bashrc ~/.profile

What line must you add to /etc/profile to make sure /sbin/custom is always part of the PATH, but also keep the current entries in the PATH statement?

PATH=PATH:/sbin/custom; export PATH

You have an executable file named ni that allows you to save a snapshot of your network information with the date and time into a log file. The file is in the /root directory, and /root is the current working directory. How would you run the executable file? (Select two.)

./ni
source ni
ni
/root/ni

./ni /root/ni

Which command will display the present working directory?

pwd

After a user starts a BASH session and the scripts in the /etc/profile are applied, what is the next file that could affect the shell session?

~/.bash_login
~/.profile
~/.bash_logout
~/.bash_profile

Login shells execute the configuration scripts they use in the following order: /etc/profile ~/.bash_profile (If this file is found, the shell does not look for additional configuration files) ~/.bash_login (If this file is found, the shell does not look for additional configuration files) ~/.profile (This file only executes in the absence of the preceding two)

A user is requesting that each time she logs in, a particular entry be written to a log file. This will only apply to her and she is using the Bash shell. In which configuration file would you make an entry for this action to stake place?

~/.profile

Shell Facts

The Linux shell is the Command Line Interface (CLI) or Text User Interface (TUI) that administrators use to control a Linux operating system. Users and programs use the shell to send commands to the system. A shell might be opened inside a Graphical User Interface (GUI), or might be the sole method used to run the computer. Although most Linux distributions now include a graphical interface, and many administration tools have been converted to a graphical format, many tasks are best performed from the command prompt. In addition, while graphical elements vary between distributions, shell commands are more likely to be consistent between distributions. The following table describes many common shell types: Shell Type Description bash The Bourne-again shell (bash) is the standard shell used in most Linux computers. It uses commands similar to a UNIX shell. Bash includes features such as: Command completion when pressing the tab key Command history Improved arithmetic functions sh The Bourne shell is an earlier version of the Bash shell, and is similar in many ways. Sh is the original shell created by Steve Bourne. ksh The Korn shell was developed by David Korn. Ksh has scripting features not found in bash. csh The C-shell uses syntax similar to syntax used in the C programming language. tcsh The tcsh shell is an improved version of csh. It offers command line editing and completion features not available with csh. Despite their differences, all shells share some common characteristics: A Linux system can use multiple shells at the same time. A list of shells is stored in the /etc/shells file. All shells are interfaces with the kernel, separate and distinct from it. Shells are run both interactively by end users and automatically by the computer’s processes. Shells can run within one another either interactively when a user starts a second shell from the first shell’s command line, or automatically by scripts or programs. Shells use configuration files to establish their operating environments.

Shell Commands Introduction

The Linux shell is the command line interface (CLI) or text user interface (TUI) that administrators use to control a Linux computer. While many Linux distributions offer a Graphical User Interface (GUI) that can perform the same tasks, the Linux+ exam tests only for command line tasks. Keep in mind the following tips for working in the shell: The tilde symbol (~) in the prompt indicates the present working directory is the home directory of the current user. The command path is the set of directories in which Linux searches to find executable files for the commands typed into the shell prompt: The path does not include the present working directory. To see the path, type echo $PATH. To add a directory to a path, type PATH=$PATH:directory_path. To execute programs: Type the executable name in the present working directory if the program is in the command path. Type ./filename to run an executable in the present working directory. (./ indicates the present working directory.) Type the full pathname to the file to run an executable from anywhere. File names and paths are case-sensitive. Type the beginning of the name, then press Tab to complete a file, command, or directory name. (Press Tab twice if there is more than one possible file, command, or directory name.) Press the up arrow at the command prompt to print the last command. Press it again to scroll through all previous commands. The following table describes several common commands used from the shell.

pwd

Show the present working directory

whoami

Display the current username

uname

Print system information. Be aware of the following uname options: -a prints all system information. -o prints the operating system. -p prints the processor’s architecture type.

su

Switch users in the shell prompt. Be aware of the following su options: su -l user_name switches to the specified user in a login shell. su user_name (without the dash, but with the username) switches to the user. su – user_name (with the dash and username) switches to the user and loads the user’s environmental variables. su – (with the dash, but no username) switches to the root user and loads the root user’s environmental variables. The root user account is the Linux system superuser. The root user can perform any task; some utilities do not work if the administrator is not logged in as the root user. su (no dash or username) switches to the root user and but does not load the root user’s environmental variables. Linux uses different prompt symbols to indicate the current user: # indicates the current user is the root user. $ indicates the current user is a normal user. Note: su requires the password of the user except when switching from root to a normal user.

exit

To exit the login shell or back to the original user after using the su command

exec

Execute an executable and to replace the shell with the new process created by the executable file

cd

Change directories. For example when the /usr directory is the current directory: cd bin changes to the bin directory in the current directory. cd /usr/bin changes to the bin directory from anywhere in the file system.

ls

Show names of files and directories in the current directory. The ls command commonly uses the following options: -a shows all files and directories, including hidden files. -l shows information about files including size, permissions, owner, and modified date. -d displays only directories. -s sorts files by size. -X sorts by extension. Many distributions have a color scheme for different file types: Directories are blue. Text files are white. Links are cyan. Image files are magenta. Compressed files are red.

history

See all commands in the history queue. The -c option clears the history list. Note: History command queues are separate for each user. A command typed as one user cannot be used after using the su command to switch to another user.

clear

See all commands in the history queue. The -c option clears the history list. Note: History command queues are separate for each user. A command typed as one user cannot be used after using the su command to switch to another user.

chsh

Change the default shell. Be aware of the chsh options: -s changes to a different installed shell. The command prompts for a password. -l lists all installed shells. For example, chsh -s /bin/ksh changes the default shell for the user to the Korn shell if it is installed on the computer.

Shell Configuration Facts

Shell configuration files are scripts that execute when a shell starts. The shell type determines which shell configuration files are executed. Shell types include: Login shells run when the system starts and is only using the Text User Interface (TUI) as the user interface. Non-login shells run when the system boots into a Graphical User Interface (GUI) and a user starts a terminal session. The following are the names of the files used when the shell starts: Configuration File Description Used by shell type ~/.bashrc ~/.bashrc stores shell preferences for individual users. non-login (login on some distributions) /etc/profile /etc/profile stores system-wide configuration commands and is used primarily to set environment variables. login ~/.bash_profile ~/.bash_profile stores shell preferences for individual users. login ~/.bash_login ~/.bash_login stores commands that execute when a user logs in. login ~/.profile ~/.profile stores configuration preferences similar to /etc/profile, but for individual users. login ~/.bash_logout ~/.bash_logout stores commands that execute when a user logs out. login Be aware of the following: Login shells execute the configuration scripts they use in the following order: /etc/profile ~/.bash_profile (If this file is found, the shell does not look for additional configuration script files) ~/.bash_login (If this file is found, the shell does not look for additional configuration script files) ~/.profile (This file only executes in the absence of the preceding two) The su -l command switches to a user into a login shell; however, without the -l option, a non-login shell is started.

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending