0% found this document useful (0 votes)
8 views19 pages

Using The Shell

Uploaded by

Aviral gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views19 pages

Using The Shell

Uploaded by

Aviral gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

USING THE SHELL


About Shells and Terminal Windows

Choosing Your Shell, Running Commands

Running commands

Recalling Commands Using Command History

Connecting and Expanding Commands

Using Shell Variables

Creating Your Shell Environment

Getting Information About Commands

Sample programs
About Shells and Terminal Windows
On UNIX systems, from which Linux was derived, the program used

to interpret and manage commands was referred to as the shell.


There are several ways to get to a shell interface in Linux. Three of the most
common are the shell prompt, Terminal window, and virtual console
Using the shell prompt :
If your Linux system has no graphical user interface (or one that isn’t working at
the moment), you will most likely see a shell prompt after you log in.
Typing commands from the shell will probably be your primary means of using the
Linux system.
The default prompt for a regular user is simply a dollar sign: $
The default prompt for the root user is a pound sign (also called a hash mark): #
In most Linux systems, the $ and # prompts are preceded by your username,
system name, and current directory name.
For example, a login prompt for the user named jake on a computer named pine
with /usr/share/ as the current working directory would appear as [jake@pine
• You can change the prompt to display any characters you like
and even read in pieces of information about your system — for
example, you can use the current working directory, the date,
the local computer name, or any string of characters as your
prompt
About Shells and Terminal Windows
Using a terminal window
With the desktop GUI running, you can open a terminal emulator program
(sometimes
referred to as a Terminal window) to start a shell. Most Linux distributions make it
easy
for you to get to a shell from the GUI. Here are two common ways to launch a
Terminal
window from a Linux desktop:

■ Right-click the desktop. In the context menu that appears, if you see Open in
Terminal, Shells, New Terminal, Terminal Window, Xterm, or some similar
item, select it to start a Terminal window. (Some distributions have disabled this
feature.)
■ Click on the panel menu. Many Linux desktops include a panel at the top or
bottom of the screen from which you can launch applications. For example,
in some systems that use the GNOME desktop, you can select Applications ➪
System Tools ➪ Terminal to open a Terminal window.
In all cases, you should be able to type a command as you would from a shell with
no GUI. Different terminal emulators are available with Linux. In Fedora, Red Hat
Enterprise Linux (RHEL), and other Linux distributions that use the GNOME
desktop,
Using virtual consoles
• Most Linux systems that include a desktop interface start multiple
virtual consoles running on the computer.
• Virtual consoles are a way to have multiple shell sessions open
at once in addition to the graphical interface you are using.
• You can switch between virtual consoles by holding the Ctrl and Alt
keys and pressing a function key between F1 and F7. For example,
in Fedora, press Ctrl+Alt+F1 (or F2, F3, F4, and so on up to F7 on
most Linux systems) to display one of seven virtual consoles.

The fi rst virtual workspace in Fedora is where the GUI is and the next
six virtual consoles are text-based virtual consoles. You can return to
the GUI (if one is running) by pressing Ctrl+Alt+F1. (On some systems
the GUI runs on the virtual console 7 or 5. So you’d return to the GUI
by pressing Ctrl+Alt+F5 or Ctrl+Alt+F7
About Shells and Terminal Windows
Choosing Your Shell
In most Linux systems, your default shell is the bash shell. To fi nd out what your
default
login shell is, type the following commands:
$ who am i
chris pts/0 2011-11-26 07:19 (:0.0)
$ grep chris /etc/passwd
cnegus:x:13597:13597:Chris Negus:/home/cnegus:/bin/bash
Common Shell Environment Variables

HOME

HOSTTYPE

MAIL(location of mailbox file)

OLDPWD

OSTYPE

PATH

PPID(The process ID of the command that started the current shell)
Common Shell Environment Variables

PROMPT_COMMAND

PS1(Sets the value of your shell prompt)

PWD

RANDOM

SECONDS

SHLVL

TMOUT
Creating and using aliases

alias p='pwd ; ls –CF'

alias rm='rm -i'

alias

unalias
Creating Your Shell Environment

Configuring your shell

Setting your prompt

Adding environment variables
Configuring your shell
Configuring your shell
Configuring your shell

nano $HOME/.bashrc

alias d="date +%D"

source $HOME/.bashrc
Setting your prompt
Setting your prompt

export PS1="[\t \w]\$ "
Adding environment variables

TMOUT

PATH

WHATEVER
Getting Information About Commands

Check the PATH

Use the help command

Use --help with the command

Use the info command

Use the man command
Manual page sections
This work is licensed under a Creative Commons
Attribution-ShareAlike 3.0 Unported License.
It makes use of the works of Mateus Machado Luna.

You might also like