|
||||
>>
>> echo $SHELL
/bin/tcsh
>>
|
$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.
|
||||
>>
>> finger tuckerm
Login: tuckerm Name: Mark Tucker
Directory: /mnt/homes/tuckerm Shell: /bin/tcsh
Office: Staff, 20030601
On since Tue Mar 2 17:44 (GMT) on :0 (messages off)
Mail forwarded to mark.tucker@lyndonstate.edu
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.
|
||||
>>
>> grep tuckerm /etc/passwd
tuckerm:x:3005:3005:Mark Tucker,Staff,20030601,:/mnt/homes/tuckerm:/bin/tcsh
>>
|
grep to filter on the unix username from the file
/etc/passwd will likewise show the default login shell. Entries in
/etc/passwd are delimited with the ":" character. The path
to the user's default login shell will be the last element of the line.
|
||||
>>
>> ps -ef |grep $$
tuckerm 19000 18951 0 17:50 pts/1 00:00:00 -tcsh
tuckerm 19040 19000 0 18:07 pts/1 00:00:00 ps -ef
tuckerm 19041 19000 0 18:07 pts/1 00:00:00 grep 19000
>>
>> ps aux |grep $$
tuckerm 19000 0.0 0.1 2928 1604 pts/1 S 17:50 0:00 -tcsh
>>
|
$$ variable will return the current process id (which
is the interactive shell in this instance). The ps command lists all
processes on the system and grep filters the current
shell's process ID to show the name of the executable which is running
with the PID (process ID), tcsh in this example.. The above example
shows the SysV and BSD
syntax for ps (respectively). This is the most reliable method for
determining the current shell in use.
chsh. This command will alter the
login shell in /etc/passwd permanently. NOTE: Do not do
this with your account in the lab since many of the settings for
the meteorology applications are made with the assumption that you
will be using the default login shell (tcsh) already configured for
your account.
3. use the command "passwd -s" to set the
login shell. This is the equivalent of using the chsh
command and has the same implications.
history can be used to
show a listing of the commands that have been typed into the shell.
|
||||
mark@platypus:~>
mark@platypus:~> history
1 21:03 ls
2 21:03 df
3 21:03 uptime
4 21:03 w
5 21:03 history | tail
6 21:03 history
7 21:03 last | head
8 21:04 env | grep PAGER
9 21:04 history
mark@platypus:~>
|
The number of commands saved in history can be limited (or expanded)
by setting the value of the shell variable "history".
The syntax is shown below:
|
||||
mark@platypus:~>
mark@platypus:~> set history=5
mark@platypus:~> history
9 21:04 history
10 21:06 history
11 21:06 uptime
12 21:06 set history=5
13 21:06 history
mark@platypus:~>
mark@platypus:~> set history=250
mark@platypus:~>
|
If you want your shell to remeber 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 .cshrc or .tcshrc file:
|
||||
mark@platypus:~>
mark@platypus:~> set savehist=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 21:07 set history=250
19 21:07 uptime
20 21:07 w
21 21:07 last | head -4
22 21:08 env | grep -i tuckerm
23 21:08 history
24 21:10 man history
25 21:13 man history
26 21:14 history
27 21:14 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 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.
|
||||
tuckerm@apollo:~>
tuckerm@apollo:~> alias
d dir
dir /usr/bin/ls $LS_OPTIONS --format=vertical
ls /usr/bin/ls $LS_OPTIONS
rm rm -i
solo /software/rdss/bin/soloii
v vdir
vdir /usr/bin/ls $LS_OPTIONS --format=long
weather /software/weather/bin/weather
tuckerm@apollo:~>
|
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 "prompt"
|
||||
tuckerm@metlab19:~> set prompt="BOB# " BOB# BOB# set prompt="Mark>>" Mark>> Mark>> |
| %C | current working directory |
| %c | current working directory only using "~" for the home directory |
| %~ | same as %c |
| %n | username |
| %m | host |
| %t | time |
| %T | time (24 hour format) |
| %P | time (24 hour format with seconds) |
| %h | history |
| %UTEXT%u | TEXT will be underlined |
| %BTEXT%b | TEXT will be bolded |
| %STEXT%s | TEXT will be in reverse text |
Here we set the prompt back to the default for the lab:
|
||||
Mark>>
Mark>> set prompt = "%n@%m:%c> "
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:~> set prompt="%h %P>> "
112 1:41:27>>
112 1:41:30>>
112 1:41:34>>
|
Set the prompt to use the underlined string "Linux"
|
||||
tuckerm@metlab19:~>
tuckerm@metlab19:~> set prompt="%ULinux%u> "
Linux>
Linux>
|