Exploring your Linux Shell Options
Bash: Bourne again Shell
BSH: Bourne Shell
Tcsh: based on csh
Csh: cshell
Ksh: korn shell
Zsh: Z shell
GUI use xterm or konsole to launch an x term program that will run a shell.
Using Internal and External Commands:
Change directory:
Cd /home/sally
Cd ~ : goes to your home directory
Display the working directory
PWD
Display a line of tekst
Echo
Execute a program
Exec myprog (it replaces the shell)
Time an operation
Time pwd (tells you how long the system takes to execute a command)
Set options
Terminate the shell
Exit or logout
./myprog you can run it in current directory
/home/arthur/thisprog you run it in the directory
Roots path should never include the current directory
Performing some shell command tricks
Press tab key for automaticly fill in the command
History with the up or down key or ctrl+p or ctrl+n. Ctrl+r is reverserd search, ctrl+s searches
forward, ctrl+g terminate the search
Move within the line: press ctl+a or ctrl+e to move the cursor to the start or end of the line
Delete text: Ctrl + D delete character und the cursor, ctrl k deletes al text from the cursor till the end.
Ctrl X + k deletes all text from cursor to beginning.
Transport text: ctrl + t
Change Case esc + u converts text from the cursor to the end of the word to uppercase. Esc + L
converts text to the end of the word to lowercase. Esc +c converts the letter to uppercase.
Invoke an editor: Ctrl+ x ctrl +e
History -c (clears) stored in the .bash_history in home directory
, Exploring Shell configuration
~/.bashrc and ~/.profile files are the main user configuration files for bash and /etc/bash.bashrc and
/etc/profile are the main global configuration files.
Using environment Variables
Are like variables in programming languages, they hold data to be referred to by the variable name.
$ export NNTPSERVER=news.abigisp.com
$ echo $NNTPSERVER
Exploring types of Streams
Three are most important:
Standard input: programs accept keyboard input via standard input or stdin. Most cases
from keyboard.
Standard output: Text mode programs, displayed on the screen, full screen text mode
session or in a GUI windows such as xterm, aka stdout.
Standard Error: This output stream is intended to carry high priority information such as
error messages.
Redirecting input and output
$echo $NNTP > nntpserver.txt
Redirection
Operator Effect
> Creates a new file containing standard output. If the specified file exists, it’s overwritten.
>> Appends standard output to the existing file. If the specified file doesn’texist, it’s created.
2> Creates a new file containing standard error. If the specified file exists, it’soverwritten.
2>> Appends standard error to the existing file. If the specified file doesn’t exist,it’s created.
&> Creates a new file containing both standard output and standard error. If the specified file exists, it’s
overwritten.
< Sends the contents of the specified file to be used as standard input.
<< Accepts text on the following lines as standard input.
<> Causes the specified file to be used for both standard input and standardoutput.
Someprog << EOF = causes someprog to accept input until it sees a line that contains only the string
EOF.
Tee: This command splits standard input so that it’s displayed on standard output and on as many
files as you specify.
$ someprog | tee output.txt
Piping data between programs
Programs can frequently operate on other programs outputs.
$first | second | third | fourth | fifth […]