TestOut Linux Pro Exam

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

su - [username]

(with the dash and the username) switches to the user and loads that user's environmental variables.

su -

(with the dash, but without the username) switches to the root user and loads the root user's environmental variables.

su [username]

(without the dash, but with the username) switches to the user in the current shell.

man -k

-k option with man allows you to search across all manual page names and descriptions to find a specific keyword. Example: man userdel shows the man pages for the userdel command. Example: man -k user lists all the commands with user in the command name or description.

cd

Changes 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 /usr/bin directory from anywhere in the file system.

chsh

Changes the default shell.

clear

Clears the shell screen.

dd

Cuts a line from the text.

dw

Cuts a whole word and trailing space.

de

Cuts a whole word, but omits the trailing space.

d$ or D

Cuts all text following the cursor to the end of the line.

Many distributions use a color scheme to identify different file types as follows:

Directories are blue. Text files are white. Links are cyan. Executable files are green. Compressed files are red.

whoami

Displays the current username.

Ctrl+g

Displays the file name, the total number of lines in the file, and the cursor position.

Type the full path to the executable file. (run an executable)

Does not reside in the current working directory and its directory is not included within the path environment variable

Esc key

Enter the command mode from the edit mode.

Insert key i s

Enters insert mode from command mode.

exec

Executes an executable to replace the shell process with the new process created by the executable file.

exit

Exits the current shell (which may close the login shell) or to go back to the original user after using the su command.

# [number_line]

Goes to a specific line in the document while in command mode. For example, #94 moves the cursor to line 94.

/etc/shells

If a shell type is installed, it will be listed in the /etc/shells file. You can switch to any shell by typing the shell's name. For example, type ksh within any shell to switch to the Korn shell.

[command] --help | more

If necessary, pipe the command through more using the command [command] --help | more to scroll through the on-screen help.

~

If the current working directory is the home directory (the default directory when the user first logs in), the tilde symbol (~) is displayed instead.

/usr/man or /usr/share/man

Man pages are typically stored in the /usr/man or /usr/share/man directory. Subdirectories store man pages for different types of commands or languages.

Within the /usr/share/doc directory are subdirectories for many components. Typical files in each subdirectory include:

NEWS README AUTHOR OVERVIEW COPYING Use the cat command to display the contents of the files in each subdirectory.

From a desktop GUI

Open a terminal session from the applications menu.

O

Opens a new line above the current line.

o

Opens a new line below the current line.

p

Places text in memory into the document.

From the Console (The keyboard and monitor attached to a computer running Linux)

Press the following key combinations: Ctrl+Alt+F1 (in some Linux distributions, Alt+F1) will start or switch to the first Linux shell session. Ctrl+Alt+F2 through Ctrl+Alt+F6 (in some Linux distributions, Alt+F2 through Alt+F6) will switch to the second through sixth shell sessions. While Linux distributions will vary, in most cases when a GUI is installed, it will use the first console session. Use Ctrl+Alt+F1 to switch to a graphical login screen. If you are already logged in, Ctrl+Alt+F7 will switch to the desktop GUI.

uname -a

Prints all system information

uname

Prints system information. The uname command has the following options:

Type the filename at the shell prompt. (run an executable)

Resides in a directory that is included in the $PATH environment variable

Type ./ followed by the filename. (run an executable)

Resides in the current working directory and the current directory is not included within the path environment variable

?[term]

Searches backward for all instances of a term. Press n to go to the previous term and N to go to the next term.

/[term]

Searches forward for all instances of a term. Press n to go to the next term and N to go to the previous term.

ls

Shows names of files and directories in the current directory.

pwd

Shows the present working directory.

echo $MANPATH

Some distributions use the MANPATH environment variable to identify the location where man pages are stored. Type echo $MANPATH to see the value of this variable.

MANPATH_MAP directive in the /etc/man_db.conf or /etc/manpath.config file

Some distributions use the MANPATH_MAP directive in the /etc/man_db.conf or /etc/manpath.config file to specify the directories where man pages are stored.

vi [file_name]

Starts vi and immediately begins working on the named file (either a new file or an existing file). Type the vi command at the shell prompt.

su

Switches users in the shell prompt. The su command has the following options:

shh

The Bourne shell (sh) is an earlier version of bash, and is similar in many ways. The sh shell was originally created by Steve Bourne.

sh

The Bourne shell is the oldest Linux shell, but is not widely used. This shell was developed for UNIX in the 1970s.

bash

The Bourne-again shell (Bash) is the default shell used by most Linux distributions. It uses commands similar to a UNIX shell. The Bash includes: Command and file name completion when pressing the Tab key Command history

csh

The C-shell (csh) uses syntax similar to the syntax used in the C programming language.

ksh

The Korn shell (ksh) provides scripting features not found in Bash. Ksh was developed by David Korn.

A man page usually consists of several elements that are used to organize the information. Most man pages will include the following:

The TITLE section is the first line of the man page. It lists the name of the command or file followed by the section number. The NAME section displays the name of the command or file and a short summary that describes what it does. The SYNOPSIS section reviews the syntax for using a command or a brief overview of what a configuration file is used for. The DESCRIPTION section describes how the command or configuration file works. It also provides a list of options that can be used. The AUTHOR section displays the name of the programmer who wrote the command or service referenced in the man page. The REPORTING BUGS section provides contact information to report any bugs you discover. The COPYRIGHT section identifies who owns the copyright to the command or service referenced in the man page. The SEE ALSO section lists man pages or other resources that are related to the current man page. The last line of a man page displays the version number and revision date of the command or service.

zsh

The Z Shell (zsh) is an improved version of Bash and is available on many Linux distributions.

Linux shell history of commands

The commands are stored as a history queue within the hidden .bash_history file in your home directory. Press the Up and Down keys to scroll through your previously typed commands.You can edit the command or re-run it as is by pressing Enter.

Tab

The commands are stored in the .bash_history file in your home directory. After typing the beginning of a command, file, or directory, press Tab to complete it. If pressing Tab does not fully complete the command, file, or directory, press Tab again.If there is no matching command, file, or directory name, your command entry will not change.If there is more than one matching command, file, or directory name, a list of all matches will be displayed to help you resolve your command entry.

echo $0

The echo $0 command can be used to return the current shell type. The special variable $0 normally holds the command used to start a script. A shell session is initiated by a script. Consequently, $0 will hold the name of the script which is consistent with the shell type. For example, $0 in a console session running bash might hold the value -bash, $0 in a terminal application opened from a desktop menu might hold the value bash. When you type ksh, the ksh script is run, a Korn shell session is opened and $0 will hold the value ksh.

echo $SHELL

The echo $SHELL command returns the default or preferred shell. The environment $SHELL holds the user's preferred shell which is typically set in /etc/passwd. For example, if bash is the user's preferred shell, $SHELL will hold the value, /bin/bash. The preferred shell does not change when you switch shell types.

root user

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.

all shells share some common characteristics:

The shell provides a command line interface that allows the user to interact with the Linux kernel. A Linux system can run multiple shell sessions at the same time. One shell session can run within another shell session. This may be done interactively, such as 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.

tcsh

The tcsh shell is an improved version of csh. It offers command line editing and completion features that are not available in csh.

bash shell default command line prompt

The username of the current user The @ symbol The hostname A space The base name of the current working directory

Insert key

Toggle between insert and replace mode while in edit mode.

u

Undoes the last action.

Use the following keystrokes to navigate within info nodes

Use the Up arrow key to move up one line. Use the Down arrow key to move up one line. Use the PgUp key or the Del key to move up one display page. Use the PgDn key or the space bar to move up one display page. Use the h key to show the info help node. Use the Tab key to move to the next hyperlink within the info nodes. Use the Home key to move to the beginning of a node. Use the Enter key to follow the selected hyperlink. Use the n key to move to the next info node. Use the p key to move to the previous info node. Use the q key to exit the info reader.

Use the following keystrokes to navigate within man pages.

Use the Up arrow key to move up one line. Use the Down arrow key to move up one line. Use the PgUp key to move up one display page. Use the PgDn key or the space bar to move up one display page. Use the Home key to go to the beginning of the man page. Use the End key to go to the end of the man page. Use the / key to search for text within the man page and the n key to move to the next occurrence of the searched for text. Use the q key to exit the man page.

Linux shell

a program that traditionally provides the text user interface (TUI) for Linux. The term shell is descriptive, since it is considered an outer layer of the operating system. The shell is the interface between you, a user or administrator, and the internal parts of the operating system including its very core which is the kernel. The shell's main function is to read and parse your commands and then to execute them through interactions with the Linux kernel.

the vi or vim editor

a utility that creates and modifies text files. It is the defacto command line text editor included with most Linux distributions.

history

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

file names and paths

are case sensitive

info [command or file]

can open the info reader to view an info node command Example: info mkdir opens the info page for the mkdir command.

chsh -s

changes to a different installed shell. The command prompts for a password. For example, chsh -s /bin/ksh [username] changes the default shell for the user to the Korn shell if it is installed on the computer.

apropos [keyword]

command displays one-line man page descriptions for any command or man page description that contains the keyword. The apropos results is intended to to help you learn what command or program to use when performing a certain task. Example: apropos declare

whatis [keyword]

command displays one-line man page descriptions for commands that exactly match the keyword. The whatis results are intended to give you a general idea of what a command or component will do. Example: whatis grep If the whatis database has not been created, run the /usr/sbin/makewhatis command. Use makewhatis -u to update the database after changes have been made to the man pages.

/usr/share/doc directory

contains documentation resources for many of the different components of the Linux system.

$PATH environment variable

contains the set of directories that are searched when you type an executable file at the shell prompt. The shell does not look in the current working directory for the executable file. To see the list of directories, type echo $PATH at the shell prompt. To add a directory to a path, type PATH=$PATH:[directory_path] and then type export PATH.

Delete key

deletes text

The Info reader

displays Info pages (which are called Info nodes). Info nodes are similar to man pages, but are more verbose and emphasize how to use Linux commands and utilities. Info nodes use hypertext links to navigate between nodes.

help -m

displays command usage in a pseudo-manpage format.

the man interface

displays manual (man) pages, which are text-based help files for a specific command, service, or configuration file. A man page shows a command's syntax, options, and related files and commands.

ls -d

displays only directories.

$ character

indicates that the current user is a normal user.

# character

indicates that the current user is the root user.

chsh -l

lists all installed shells

man [command or file]

open the man interface to view a man page

help -s

outpus only a short usage synopsis for each matching topic.

help -d

outputs a short description for each topic.

uname -o

prints the operating system

uname -p

prints the processor's architecture type

ls -a

shows all files and directories, including hidden files.

ls -l

shows extended information about files, including size, permissions, owner, and modified date.

ls -X

sorts by extension

ls -s

sorts files by size

vi

starts vi. Type the command at the shell prompt.

su (no dash or username)

switches to the root user, but does not load the root user's environmental variables. su requires the password of the user except when switching from root to a normal user.

su -l [username]

switches to the specified user and creates a new login shell.

command mode

the initial mode vi uses when started. It provides commands that can cut and replace text. It is also the mode from which you access the other vi modes.

Edit mode

the mode that vi uses to write and edit text in the file. It has two operation modes: Insert mode adds text between the preceding and subsequent text. Replace mode overwrites subsequent text.

Type history -c

to clear the history queue.

Type history

to display the commands stored in the history queue.

[command] --help

to view the help available for a command

[command] -h

to view the help available for a command Example: echo -h displays help on the echo command.

Both the whatis and apropos commands

use the whatis database.

Command line mode

used to load files and to save files after editing them in the file system.

help [pattern]

view information about a built-in command that matches a pattern of characters Example: help exec displays help on the exec command. Example: help ex displays help on three commands, exec, exit and export.


संबंधित स्टडी सेट्स

Psychology Learnsmart 1, 2, 3, 5

View Set

Sem 3 - Unit 3 - Miscarriage/Fertility - NCO

View Set

CISSP Chapter 15: Security Assessment and Testing

View Set