Linus Flashcards

1
Q

What is a shell?

A

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.

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

What are the common shells?

A
  • bash- Bourne-Again Shell
  • sh- Bourne Shell
  • ksh- Korn Shell
  • csh- C Shell
  • tcsh- TC Shell
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Features ofbash

A

bash- The Bourne-again shell - 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

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

Features ofsh

A

sh- The Bourne shell - An earlier version of the Bash shell, and is similar in many ways. Sh is the original shell created by Steve Bourne

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

Features ofksh

A

ksh- The Korn shell - Developed by David Korn. Ksh has scripting features not found in bash.

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

Features ofcsh

A

cshThe C-shell - Uses syntax similar to syntax used in the C programming language.

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

Features oftcsh

A

tcsh- The TC shell - An improved version of csh. It offers command line editing and completion features not available with csh.

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

Common characteristics of all shells

A

◇ 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.

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

How do you get into the shell?

A

◇ Boot into it at run level 3 (no GUI)

◇ Access it through a terminal window using a terminal application within the GUI

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

What is the difference between how a Linux shell recognizes the path to executable programs compared to how a DOS environment recognizes the path?

A

◇ In DOS or Windows, the shell searches for your command in the current directory first, followed by the directories in the PATH variable.
◇ In Linux, the shell only searches the directories in the PATH variable for your command. It does not search the current directory.

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

How can you execute commands that are not in thePATHenvironment variable?

A

◇ Use an absolute path
◇ Use a relative path
◇ Copy or move the command file to a directory that is in the path (like ~/bin or /bin)
◇ Add the directory that contains the command file to the PATH variable

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

How can you execute commands in the current working directory?

A

Prefix the command with a “dot-slash” (./)

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

What types of items can Tab complete be used to complete once you start typing the entities’ name?

A

Files and directories.

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

What is tab-completion?

A

A shell feature that gives you the ability to type part of a filename and then have the shell complete the filename (or provide a list of matching suggestions) by hitting the tab key.

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

How does command history work?

A

Every time you enter a command, that command is written to a hidden file in your home directory. You can access previous commands with the up- and down-arrow keys.

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

What common commands are used to navigate through shells?

A

◇ ‘pwd’
◇ ‘ls’
◇ ‘cd’

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

Which file contains the history of shell commands?

A

~/.bash_history

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

What does the tilde symbol (~) in the command prompt represent?

A

The tilde symbol (~) in the prompt indicates the present working directory is the home directory of the current user.

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

What is the command path?

A

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:.

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

How do you execute programs in the shell?

A

◇ 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.

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

Are filenames and paths case-sensitive?

A

Yes

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

How does tab-completion work?

A

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.)

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

How do you recall the previous command and scroll through all previous commands?

A

Press the up arrow at the command prompt to print the last command. Press it again to scroll through all previous commands.

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

What does thepwdcommand do?

A

Shows the present working directory.

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

What does thewhoamicommand do?

A

Displays the current username.

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

What does theunamecommand do?

A

unameprints system information.

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

What does the commanduname -ado?

A

uname -aprints all system information.

28
Q

What does the commanduname -odo?

A

uname -oprints all system information.

29
Q

What does the commanduname -pdo?

A

uname -pprints all system information.

30
Q

What does thesucommand do?

A

suswitches users. With no arguments, switches to the root user.

31
Q

What does the commandsu -l user_namedo?

A

su -l user_nameswitches to the specified user in a login shell.

32
Q

What does the commandsu user_namedo?

A

su user_name(without the dash, but with the username) switches to the user.

33
Q

What does the commandsu - user_namedo?

A

su - user_name(with the dash and username) switches to the user and loads the user’s environmental variables.

34
Q

What does the commandsu -do?

A

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. It can perform any task; some utilities do not work if the administrator is not logged in as the root user.

35
Q

What are the different shell prompt symbols and what do they represent?

A

◇ ‘#’ indicates the current user is the root user.

◇ ‘$’ indicates the current user is a normal user.

36
Q

What does theexitcommand do?

A

Exits the login shell or exits back to the original user after using the su command.

37
Q

What does theexeccommand do?

A

Runs an executable and replaces the shell with the new process created by the executable file.

38
Q

What does thecdcommand do?

A

Changes directories.

39
Q

What does thelscommand do?

A

Shows names of files and directories in the current directory.

40
Q

What are some commonlsoptions and what do they do?

A

◇ ls -ashows all files and directories, including hidden files.
◇ ls -lshows information about files including size, permissions, owner, and modified date.
◇ ls -ddisplays only directories.
◇ ls -ssorts files by size.
◇ ls -Xsorts by extension.

41
Q

What does a blue file color represents?

A

Blue: directories

42
Q

What does thehistorycommand do and what does the-coption do?

A

Shows all commands in the current user’s history queue. The -c option clears the history list.

43
Q

What does a white file color represents?

A

White: text files

44
Q

What does a cyan file color represents?

A

Cyan: symbolic links

45
Q

What does a magenta file color represents?

A

Magenra: image file

46
Q

What does a red file color represents?

A

Compressed file

47
Q

What does theclearcommand do?

A

Clears the shell screen.

48
Q

What does thechshcommand do and what do the options-sand-ldo?

A

chshchanges the default shell.◇ chsh -schanges to a different installed shell. The command prompts for a password.
◇ chsh -llists all installed shells.

49
Q

What is aloginshell used?

A

A shell that is started when a user first logs onto a system - such as when your system is configured to boot directly into a shell environment (likebash).

50
Q

What is anon-loginshell?

A

A shell that is started from within a running system by a user who has already logged onto that system - such as when you start a terminal program from within a GUI.

51
Q

What is the effect of a leading period (.) before a filename?

A

The file is hidden and is not displayed by the ‘ls’ command unless the ‘-a’ switch is used.

52
Q

Which shell configuration files are executed by non-login shells?

A

Only.bashrc

53
Q

Which shell configuration files are used by RedHat, CentOS, and Fedora Linux (in addition to/etc/profile)?

A

◇ ~/.bashrc
◇ ~/.bash_profile
◇ ~/.bash_logout

54
Q

Which shell configuration files are used by SUSE Linux (in addition to/etc/profile)?

A

◇ ~/.bashrc

◇ ~/.profile

55
Q

How do you list hidden files in addition to regular files?

56
Q

How do some distributions run the~/.bashrcshell configuration file in login shells?

A

By calling (sourcing) the script from within the.bash_profilescript.

57
Q

How do you append a path onto the end of the currentPATHvariable?

A

PATH=$PATH:new_path

58
Q

What are shell configuration files?

A

Scripts that execute when a shell starts.

59
Q

What determines which shell configuration files are executed?

A

The shell type.

60
Q

What are the two different types of shells?

A

◇ 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.

61
Q

How is~/.bashrcused?

A

Shell configuration file. Stores shell preferences for individual users. Executed by non-login shells (and by login shells for some distributions).

62
Q

How is/etc/profileused?

A

Shell configuration file. Stores system-wide configuration commands and is used primarily to set environment variables. Executed by login shells.

63
Q

How is~/.bash_profileused?

A

Shell configuration file. Stores shell preferences for individual users. Executed by login shells.

64
Q

How is~/.bash_loginused?

A

Shell configuration file. Stores commands that execute when a user logs in. Executed by login shells. (Not executed if~/.bash_profileexists.)

65
Q

How is~/.profileused?

A

Shell configuration file. Stores configuration preferences similar to /etc/profile, but for individual users. Executed by login shells. (Not executed if~/.bash_profileor~/.bash_loginexist.)

66
Q

How is~/.bash_logoutused?

A

Shell configuration file. Stores commands that execute when a user logs out. Executed by login shells. Executed by login shells.

67
Q

Which shell configuration files are executed by login shells and in what order?

A
  1. /etc/profile
  2. ~/.bash_profile(If this file is found, the shell does not look for additional configuration script files)
  3. ~/.bash_login(If this file is found, the shell does not look for additional configuration script files)
  4. ~/.profile(This file only executes in the absence of the preceding two)
  5. ~/.bashrc(Depending on the distribution)