|
||||
>> >> echo $SHELL /bin/bash >> |
$SHELL
will not always be
available and is not present with some shells or versions of unix. It
is also unreliable as it will not always identify the shell correctly
if different shell is started from the login shell.
|
||||
[loriotg@gollum ~] finger loriotg Login: loriotg Name: George B Loriot Directory: /mnt/homes/loriotg Shell: /bin/bash Office: Faculty, 20070118 Home Phone: 99991234^H On since Tue Nov 1 13:50 (GMT) on tty7 from :0 1 hour 31 minutes idle On since Tue Nov 1 13:50 (GMT) on pts/0 from :0.0 No mail. No Plan. |
finger
command for the current login name will
show the default login shell for that user. This will not show what
is currently being used if the user has started a different shell.
|
||||
[loriotg@gollum ~] ps PID TTY TIME CMD 2502 pts/1 00:00:00 bash 2827 pts/1 00:00:00 ps [loriotg@gollum ~] |
ps
command (covered below) will show all processes running in the current shell under your userid at the time the ps
command is invoked. In this example it shows that the shell is bash
, and the only other process is ps
.
tcsh
To exit this shell, enter ctl-d
or exit
as for any shell. In this case you will exit the tcsh shell and return to the bash shell. Selecting a new shell in this way will not chnage your default login shell; the next login will still have bash
as your login shell. To change the login shell, use the yppasswd -l
command to change your login shell permanently. NOTE: the ATM lab environment setup assumes that the login shell will be bash; changing the login shell will not setup the same environment for the usual ATM applications.
These files are shell scripts which contain Linux commands that are executed line by line to set the environment to one which is common to all users. This why all students have the same paths, aliases, and variables. The .bash file is actually a symbolic link to the file /mnt/homes/00links/.bashrc, which is not writeable by the users and therefore all users have the same environment.
To allow users to change their login environment, the ATM configuration includes a file .user.bashrc in their home directory. This file is always run at the end of normal login and my be edited with, for example, vi
to enter environment commands such as export
or alias
to customize a user's environment.
history
can be used to
show a listing of the commands that have been typed into the shell.
|
||||
mark@platypus:~> mark@platypus:~> history 1 ls 2 df 3 uptime 4 w 5 history | tail 6 history 7 last | head 8 env | grep PAGER 9 history mark@platypus:~> |
The number of commands saved in history can be limited (or expanded)
by setting the value of the shell variable "HISTSIZE".
The syntax is shown below:
|
||||
mark@platypus:~> mark@platypus:~> export HISTSIZE=5 mark@platypus:~> history 9 21:04 history 10 21:06 history 11 21:06 uptime 12 21:06 export HISTSIZE=5 13 21:06 history mark@platypus:~> mark@platypus:~> export HISTSIZE=250 mark@platypus:~> |
If you want your shell to remember your commands after you logout so that the next time you login they will appear in your history list, add the following command to your .user.bashrc file:
|
||||
mark@platypus:~> mark@platypus:~> export HISTSIZE=50 mark@platypus:~> |
!!
command will
repeat the last command entered.
|
||||
mark@platypus:~> mark@platypus:~> man history mark@platypus:~> !! man history mark@platypus:~> |
Specific items from the command history may be repeated by using the
exclaimation point followed by the history number of the command.
(ex. !30
would repeat the command number 30 from the
shell's history.)
|
||||
mark@platypus:~> mark@platypus:~> history |tail -10 18 set history=250 19 uptime 20 w 21 last | head -4 22 env | grep -i tuckerm 23 history 24 man history 25 man history 26 history 27 history | tail -10 mark@platypus:~> !19 uptime 21:14:37 up 34 days, 3:46, 1 user, load average: 0.08, 0.06, 0.01 mark@platypus:~> |
The !string command can also be used to repeat the last command that begins with 'string'. Entering !uptime will invoke the same command that !19 invoked.
The alias
command entered without any arguments will
show what commands are aliased in the current shell. Syntax for
the alias
is different for Bourne shell compared with
C shells.
|
||||
[loriotg@apollo unix] alias alias d='dir' alias dir='/bin/ls $LS_OPTIONS --format=vertical' alias fixfirefox='/mnt/homes/00links/scripts/fix_firefox.sh' alias ftp='ftp -p' alias garpa='/mnt/homes/CLASSES/MET2110/gempak/garpa' alias gemshell='/mnt/homes/00links/scripts/run_gempak_shell.csh' alias homer='ssh george@homer' alias idv='/mnt/homes/00links/scripts/run_idv.sh' alias ls='/bin/ls -c -F' alias nukeprofile='mv -v /mnt/homes/loriotg/.mozilla /mnt/homes/loriotg/.mozilla-20111101' alias pgi?='ps -ef|grep lmgrd' alias rm='rm -i' alias setenv='echo This is the Bourne shell, use export not setenv' alias sfstn='/mnt/homes/00links/gempak/sfstn' alias solo='/software/rdss/bin/soloii' alias sshx='ssh -X -Y' alias troy='ssh george@troy' alias v='vdir' alias vdir='/bin/ls $LS_OPTIONS --format=long' alias vmware='/mnt/homes/00links/scripts/run_vmplayer.sh' alias vortex00='ssh vortex00' alias weather='/software/weather/bin/linux/weather' alias xfortune='fortune|cowsay -W 60' [loriotg@apollo unix] |
Below is an example of creating an alias "lls" which would run the command "ls -l" when entered.
|
||||
tuckerm@apollo:~> tuckerm@apollo:~> alias lls="ls -l" tuckerm@apollo:~> lls wrf.tgz -rw-r--r-- 1 tuckerm tuckerm 13601558 Feb 18 18:18 wrf.tgz tuckerm@apollo:~> |
An alias may be removed from the shell with the command unalias.
|
||||
tuckerm@apollo:~> tuckerm@apollo:~> unalias lls tuckerm@apollo:~> lls lls: Command not found. tuckerm@apollo:~> |
|
||||
[tuckerm@metlab19:~] [tuckerm@metlab19:~] |
The prompt can be changed by setting the shell variable "PS1"
|
||||
tuckerm@metlab19:~> PS1="BOB# " BOB# BOB# PS1="Mark>>" Mark>> Mark>> |
\w | current working directory |
%~ | same as %c |
\u | username |
\h | host |
\T | time (12 hour format) |
\t | time (24 hour format) |
\@ | time (in AM/PM format) |
\! | history number |
Here we set the prompt back to the default for the lab:
|
||||
Mark>> Mark>> PS1="[\u@\h \W] " [tuckerm@metlab19 ~] [tuckerm@metlab19 ~] |
Below the prompt is set to show the command history number and current time in 24 hour format:
|
||||
tuckerm@metlab19:~> tuckerm@metlab19:~> PS1="\! \t>> " 112 1:41:27>> 112 1:41:30>> 112 1:41:34>> |