Lpi linux certification in a nutshell by unknow
Author:unknow
Language: eng
Format: epub
Tags: Sciences
ISBN: 9781449390136
Published: 2010-06-14T10:00:00+00:00
In practice, users will generally (and often unknowingly) use the system-wide /etc/profile configuration file to start. In addition, theyâll often have three personal files in their home directory: ~/.bash_profile, ~/.bashrc, and ~/.bash_logout. The local files are optional, and bash does not mind if one or all of them are not available in your directory.
Each of these configuration files consists entirely of plain text. They are typically simple, often containing just a few commands to be executed in sequence to prepare the shell environment for the user. Since they are evaluated by bash as lines of program code, they are said to be sourced, or interpreted, when bash executes them.
Like most programming languages, shell programs allow the use of comments. Most shells, including bash, consider everything immediately following the hash mark (#) on a single line to be a comment. An important exception is the $# variable, which has nothing to do with comments but contains the number of positional parameters passed to a function. Comments can span an entire line or share a line by following program code. All of your shell scripts and configuration files should use comments liberally.
Files sourced at login time are created mainly to establish default settings. These settings include such things as where to search for programs requested by the user (the PATH) and creation of shortcut names for commonly used tasks (aliases and functions). After login, files sourced by each subsequent shell invocation wonât explicitly need to do these things again, because they inherit the environment established by the login shell. Regardless, it isnât unusual to see a userâs .bashrc file filled with all of their personal customizations. It also doesnât hurt anything, provided the .bashrc file is small and quick to execute.
Although it is not necessary to have detailed knowledge of every item in your shell configuration files, Exam 102 requires that you understand them and that you can edit them to modify their behavior and your resulting operating environment. The following examples are typical of those found on Linux systems and are annotated with comments. Example 13-1 shows a typical Linux systemwide profile. This file is executed by every userâs bash process at login time. A few environment variables and other parameters are set in it.
Example 13-1. An example system-wide bash profile
#!/bin/bash # /etc/profile pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } # ksh workaround if [ -z "$EUID" -a -x /usr/bin/id ]; then EUID=`id -u` UID=`id -ru` fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin fi # No core files by default ulimit -S -c 0 > /dev/null 2>&1 if [ -x /usr/bin/id ]; then USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi HOSTNAME=`/bin/hostname` HISTSIZE=1000 if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then INPUTRC=/etc/inputrc fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then .
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
AIX | Administration |
DNS & Bind | Shell |
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7744)
Filmora Efficient Editing by Alexander Zacharias(5459)
The Infinite Retina by Robert Scoble Irena Cronin(4905)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3908)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3798)
Edit Like a Pro with iMovie by Regit(3248)
Linux Administration Best Practices by Scott Alan Miller(2846)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2823)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2511)
Docker on Windows by Stoneman Elton(2310)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2299)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2224)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2098)
Creative Projects for Rust Programmers by Carlo Milanesi(2054)
Hands-On Linux for Architects by Denis Salamanca(2033)
Computers For Seniors For Dummies by Nancy C. Muir(1987)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(1977)
The Old New Thing by Raymond Chen(1931)
Linux Kernel Debugging by Kaiwan N Billimoria(1756)
