

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















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. 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+F 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. From a desktop GUI - ✔✔Open a terminal session from the applications menu. 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 zsh - ✔✔The Z Shell (zsh) is an improved version of Bash and is available on many Linux distributions. 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. ksh - ✔✔The Korn shell (ksh) provides scripting features not found in Bash. Ksh was developed by David Korn. csh - ✔✔The C-shell (csh) uses syntax similar to the 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 that are not available in csh.
Shells use configuration files to establish their operating environments. 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 ~ - ✔✔If the current working directory is the home directory (the default directory when the user first logs in), the tilde symbol (~) is displayed instead.
$ character - ✔✔indicates that the current user is a normal user. $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. 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 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 file names and paths - ✔✔are case sensitive 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. Type history - ✔✔to display the commands stored in the history queue.
uname - p - ✔✔prints the processor's architecture type su - ✔✔Switches users in the shell prompt. The su command has the following options: su - l [username] - ✔✔switches to the specified user and creates a new login shell. su [username] - ✔✔(without the dash, but with the username) switches to the user in the current shell. 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. 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. 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. exit - ✔✔Exits the current shell (which may close the login shell) or to go back to the original user after using the su command. exec - ✔✔Executes an executable to replace the shell process with the new process created by the executable file. 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. ls - ✔✔Shows names of files and directories in the current directory. 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 - d - ✔✔displays only directories.
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. chsh - l - ✔✔lists all installed shells 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. man [command or file] - ✔✔open the man interface to view a man page 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. /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.
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. 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.
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. 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. [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.
[command] --help | more - ✔✔If necessary, pipe the command through more using the command [command] --help | more to scroll through the on-screen help. 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. help - d - ✔✔outputs a short description for each topic. help - m - ✔✔displays command usage in a pseudo-manpage format. help - s - ✔✔outpus only a short usage synopsis for each matching topic. /usr/share/doc directory - ✔✔contains documentation resources for many of the different components of the Linux system. Within the /usr/share/doc directory are subdirectories for many components. Typical files in each subdirectory include: - ✔✔NEWS README
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. 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. Command line mode - ✔✔used to load files and to save files after editing them in the file system. 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. vi - ✔✔starts vi. Type the command at the shell prompt. 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. Insert key
i s - ✔✔Enters insert mode from command mode. Esc key - ✔✔Enter the command mode from the edit mode. Delete key - ✔✔deletes text Insert key - ✔✔Toggle between insert and replace mode while in edit mode.
command mode. For example, #94 moves the cursor to line 94. 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. dd - ✔✔Cuts a line from the text. p - ✔✔Places text in memory into the document.
C - ✔✔Changes text from current cursor position to the end of the line. cc - ✔✔Changes text of the entire line. ZZ - ✔✔Saves current file and exits vi. h - ✔✔Moves the cursor one space to the left. j - ✔✔Moves the cursor down a line. k - ✔✔Moves the cursor up a line. l - ✔✔Moves the cursor one space to the right. z - ✔✔Exits without saving. : - ✔✔Enters command line mode from command mode. w - ✔✔Saves the current document. w [file_name] - ✔✔Names and save the file.
w![file_name] - ✔✔Overwrites the file. q - ✔✔Exits vi. This produces an error if the text was modified. q! - ✔✔Exits vi without saving. wq or exit - ✔✔Saves the document and exits vi. e! - ✔✔Reloads the file from the last saved version. This discards all edits and reloads the last saved version of the file into vi. nano editor - ✔✔To start the editor, type nano at the shell prompt. The nano editor is simpler to use than the vi editor.Common keystroke shortcuts are listed at to the bottom of the nano interface.A caret (^) in the shortcut means press and hold the Ctrl key.'M-' listed in the shortcut means press and hold the Meta key. On modern keyboards, the Alt or Esc key is substituted for the Meta key.Ctrl+G (listed as ^G) displays the full help text, which includes a full list of shortcuts.Prompts are displayed when user input is needed.The Home, End, PgUp, PgDn and arrow keys move the cursor in the same was as other common editors.