What UNIX Shell Config Settings Work for Newbies? 159
Human_Diastrophism asks: "I'm involved in the roll-out of a new *x-based computing service in my previously Windows-centric organization. I want things set up so that newcomers will understand and like what they see. They should feel encouraged to behave appropriately, i.e. explore and extend the environment for themselves. We're talking about technically literate folk who are simply new to the demands and freedoms of the command line. No shell advocacy, please; it's going to be ksh or bash. What would you put in a .profile or .rc to make things work smoothly and give the user the capabilities and feedback they need? I'm thinking about stuff like 'stty erase ^H' and 'set -o emacs' so the edit keys work, and a compact but informative prompt. But what else would you put in? What would you leave out?"
Advice: Install Midnight Commander. (Score:5, Informative)
Heck, I still use mc a lot after over 10 years using Linux. It's a very useful tool.
Re:Advice: Install Midnight Commander. (Score:2)
If you don't know the directory layout, it's easy to change the directory using the Alt+S combination to jump to a specific letter. Also, Ctrl+X Ctrl+S creates a link, Ctrl+X T copies the current file to the command line, ctrl+O reveals the command line, has ftp browsing, supports most of the archive formats (rpm, zips, rar
Different people learn differently. (Score:2)
However, I still use mc under Linux (and FileJet under OS/2 and DOS, and @VSH under OS2200) to peruse the filesystem and to perform certain types of commands (mainly directory tree deletions and selective operations where point-and-shoot is more convenient for me than a series of filespecs).
Like text edi
$PS1 (Score:4, Informative)
use jedi mind tricks (Score:3, Interesting)
#!/bin/bash
echo"tutorial blah blah blah
ls does blah blah blah
to find more info use man blah blah blah
I think you get the idea.
most newb are familiar with the idea that
Re:use jedi mind tricks (Score:3, Insightful)
Nonsense. Anyone who associates ".exe" with running a program is a Windows power user, and they will NOT associate "readme.exe" with anything, because readmes are always "readme.txt".
The command to get help in a Windows command prompt is "help", just like in bash, and it works just like bash's. A useful thing to do would be to al
Re:use jedi mind tricks (Score:3, Interesting)
Re:use jedi mind tricks (Score:2, Informative)
The user would then sit for half an hour, trying to work out why typing 'readme.exe' doesn't start 'README.EXE'.
Once he is told that the new shell is case sensitive, three days will pass before he finds out that files in the current directory
Re:$PS1 (Score:3, Interesting)
Can and will.
A lot of the stuff that traditionally goes in shell prompts is outdated or inappropriate for newbies. If you're using using the shell in a terminal window (as almost everybody does these days, especially newbies), you don't need email notification, time, CPU load, and a lot of other crap you can have in a GUI window. The name of the machine you're on is helpful is you're access a lot of different machines -- but most newbies won't do that. (Let's all
Re:$PS1 (Score:5, Informative)
PS1='[\u@\h:\w]\$ '
as my prompt. I work on many different systems (it's not uncommon for me to have 3 or 4 different sessions to different machines), so the hostname is almost a requirment. Username is a bit handy as well
I also started using \w as my path (which prints the full path) simply because it would be too easy to lose track without it. When you come back to a window and it says "[root@ws005:bin]# " that doesn't really tell you a lot. I much prefer to see "[root@ws005:/usr/bin]#" or "[greg@hydrogen:/usr/local/someprog/bin]$".
Also handy is that the prompt is a valid source/target for scp or rsync.
Re:$PS1 (Score:2)
Re:$PS1 (Score:2)
Um, okaaay... is that:
or something I didn't think of in that list?
Re:$PS1 (Score:3, Insightful)
Another thing I do is set ls, ll, and lr aliases and include -aF switches in addition to the -l and -R for the latter two, respectively (I just set ls
Re:$PS1 (Score:2)
If you are using bash, setting PROMPT_COMMAND might be better than aliasing cd. Personally, I only put the hostname in the window title. Having the path in there annoys me.
declare -x PROMPT_COMMAND="echo -ne '\033]0;${HOSTNAME}\007'"
Re:$PS1 (Score:2)
Re:$PS1 (Score:2)
Re:$PS1 - multi-line prompt (Score:2)
Re:$PS1 (Score:2)
We know emacs is hard... you'd better just stick to something simple and leave the heavy lifting to us. Have you tried Pico?
pico? (Score:2)
I got by on pico for years, even for editing C source.
This was after giving up on JOVE in disgust, which our (blessed) Uni systadmins had installed because it was simpler than emac - well it was, but the everyday bits were just as complicated. ^X^C to quit,etc!
Now I use vi cos I have to.
The full set of commands I know are:
s I i A a ESC
And that brings me up to pico ability!
mad!
Sam
Ksh? Bash? (Score:2, Funny)
Let them do their own set-up (Score:4, Insightful)
Well if they are neading to get used to shell , then i would say this may be a good approach as it will educate them as well
Just another idea you may consider.
set -o emacs? (Score:5, Insightful)
I would say try to change the shell as little as possible from default, else you are going to confuse them if they have previously done a little command line work, or try to install it at home, or try to learn it from a book / web guide.
I would consider using aliasing to stick a "-i" on rm... nice for beginners (and experts as well to be honest)
Re:set -o emacs? (Score:2, Informative)
I second the suggestion for aliasing rm with "-i". After being bitten by the "unintentional deletion of files" bug in my early unix days, I have always aliased the rm/mv/cp commands and recommend all new unix users to do the same.
Re:set -o emacs? (Score:2)
It Depends (Score:3, Insightful)
It really depends on what sort of users you plan on having on your system. I understand you say that you have computer (read: Windows) literate people, but, I have seen people that I would consider have a decent ability to navigate and use various Windows okay, and just absolutely freak out when they see a CLI.
I'd really recommend a tutorial course given by yourself, or by some other member of IT, to familiarize your users with the CLI. I like my prompt very simple and plain, but informative enough for me, for example, in ZSH, I use: prompt='[%T][%n@%m][%~] ' and that is informative enough for me. If you do something simple like this in the global rc file, and then even personalize it a little more on per user basis.
set -o emacs is so evil (Score:4, Funny)
Right outta the box you're going to subject them to learning the semantics of the editor that wishes it was an operating system and requires 8 metakeys and 3 floor pedals to operate? Talk about BOFH.
Re:set -o emacs is so evil (Score:4, Insightful)
its not as if they would need to learn the whole emacs multiverse
Re:set -o emacs is so evil (Score:3, Insightful)
Funny, I'd say the same thing about vi commands.....and they're fewer keystrokes.
Re:set -o emacs is so evil (Score:4, Funny)
does that make me a BiTexual
Re:set -o emacs is so evil (Score:2)
As an aside... I don't know any emacs users who don't know how to use vi proficiently. Conversely, I don't know any vi users who do know how to use emacs proficiently.
I have my own theories on why, I'll let the reader draw their own.
Re:set -o emacs is so evil (Score:2)
Im not touching that one with a 16' barge pole
Re:set -o emacs is so evil (Score:2)
arrow keys? (Score:2)
Thankfully that last unix where these didn't work for me was SCO ODT3
And don't tell me about it being quicker to use ^F type keys because my fingers are already in that area, to make a great saving I'd have to be using them an awful lot for it to be worthwhile remembering to use ^F instead of right arrow (or is it down arrow? forward/next sortof seem the same)
Sam
Re:set -o emacs is so evil (Score:2)
But, no matter what, the arrow keys work almost univerally nowadays.
Re:set -o emacs is so evil (Score:2)
Wouldn't it be better to emphasize the arrow keys? I think you'll find that most keyboards have them nowadays.
Sarcasm aside, you've just demonstrated how big the mental gap can be between a hacker and a newbie, especially if the hacker has some complicated set of concepts -- like the EMACS or Vi command set -- hard-wired into his frontal lobes. Don't assume that something that comes natural to you is natural to somebody new to the subje
Re:set -o emacs is so evil (Score:2)
the reason i advocate that a new users learns a command set like vi or emacs is to get them into the swing of having to read up on things and helps get them into the mindest , I h
Re:set -o emacs is so evil (Score:2)
Now, why would any user need to know that? It's not like keyboards doesn't have arrow keys on them. Alright, it's happened to me on some weird occasions running emacs on a terminal through a telnet session, or something like that, but in that case, backspace would also bring up help, making the system completely useless for new users anyway.
The useful commands an
Re:set -o emacs is so evil (Score:2)
Re:set -o emacs is so evil (Score:2)
I love pico/nano dont get me wrong , but you hardly need to learn it and the keyboard shortcuts from VI or emacs really can boost your productivity on the shell when your use to them.
VI and emacs both generaly come with a tutorial that will hand guide you through the basics and let you start to feel comfertable with the enviroment
If y
Re:set -o emacs is so evil (Score:2)
Re:set -o emacs is so evil (Score:2)
(In point of fact, emacs doesn't wish it was an operating system. It wishes i
Compact AND informative prompt? (Score:2, Insightful)
alias setprompt 'set prompt="\\
`pwd`\\
`hostname`# "'
alias cd 'chdir \!* && setprompt'
setprompt
Re:Compact AND informative prompt? (Score:2)
Most prompts that show you pwd do it with backticks or something, afaik.
Re:Compact AND informative prompt? (Score:2)
Re:Compact AND informative prompt? (Score:2)
recommended .bashrc file... (Score:5, Funny)
exit
Re:recommended .bashrc file... (Score:4, Funny)
Re:recommended .bashrc file... (Score:2)
Re:recommended .bashrc file... (Score:2)
Re:recommended .bashrc file... (Score:2, Informative)
(I had no idea that ":" was a valid bash command, and so figured that maybe it'll come up with a particularly amusing error message... was I ever wrong
Re:recommended .bashrc file... (Score:2)
It worked on bash on VMS systems, it works on bash on Win 95/98 systems, and it works on bash in Win NT/2000/XP systems.
Re:recommended .bashrc file... (Score:2)
stty erase e
stty intr r
If you know what you're doing, it's fairly trivial to get out of that, but a newbie won't have a chance.
Re:recommended .bashrc file... (Score:2)
.profile/.rc Comments! (Score:5, Insightful)
1. Set up the skeleton .bashrc with just a few customizations. For each customization, include a comment so that they will learn how to customize too. For example:
2. Send them an e-mail telling them that they can customize their accounts by editing ~/.bashrc with an easy editor (nano/pico) or whatever. Point them to a nice tutorial on the web, too. Also, tell them that they can reset their settings to the default by typing reset_shell_defaults, and put a script in /usr/local/bin that prompts "Are you sure? Your settings will be lost!" and then overwrites .bashrc. That way, they won't be afraid to play. Nobody ever got 1337 without playing around.
3. Offer up Midinight Commander for those who need some curses.
4. Tell them about man/apropos/info.
Not from experience (Score:3, Informative)
Copy - cp
Move - mv
Help using a command - Man
you get the idea. Otherwise, everyone'll be requisitioning the newb command line books all at the same time. At least with a built-in reference, they don't need paper.
Noooooo! Help is a bash builtin. (Score:2)
No Cheat sheet - alias the commands! (Score:3, Informative)
alias dir="ls -al"
alias rename="mv"
alias move="mv"
alias copy="cp"
alias help="man" # this or
alias help="info" # this
These 5 or so commands will help them immensely. DOS / cmd.exe only has a very few commands anyway, and you can successfully alias all of them.
Midnight commander is an excellent idea as well.
ALSO: Create a couple
Re:No Cheat sheet - alias the commands! (Score:5, Informative)
[...]
alias rename="mv"
BAD idea. DOS commands are not just Unix commands with vowels in; they work differently.
For example, in DOS you can do and that is the equivalent of ...except it's not case sensitive. Note that it is not equivalent to which is what your dangerous alias will make people expect.
ALSO: Create a couple of directories in everyone's home dir named, "MyDocuments", "MyPictures", etc., so people don't even have to learn how to create a directory.
What - not just alias md="mkdir"?
Re:No Cheat sheet - alias the commands! (Score:3, Interesting)
dir is a DOS command, the most similar command in Linux is ls
type ls man ls for directions.
Most common usage is "ls -al"
or something to that effect. Also I would aliad ls to ls -F --color=auto (most distros will reasonably alias the common commands though).
By listing the propper command instead of auto-subbing you can encourage people to learn more about the commands (anybody using the command prompt will probably be at t
Re:No Cheat sheet - alias the commands! (Score:2, Insightful)
First of all, that doesn't describe the usual windows user, even among seemingly tech savy people. (Which, if you'll forgive a brief flame, is no surprise given the crippled and disgusting nature of the DOS shell... why would anyone use it for anything if they had a choice?)
Second, anyone who intuitively reaches for DOS commands will pick up a dozen unix commands in minutes. And, once they know the actual command, they'll instantly have acc
For the old farts familiar with DOS (Score:2)
Re:For the old farts familiar with DOS (Score:4, Interesting)
> copy old.txt new.txt
Try using 'cp <options> <source> <target>'. For example:
cp old.txt new.txt
Type 'man cp' for more help.
Consider AT, CHKDSK, CMD, COPY, DATE?, DEL, DIR, ECHO, EDIT, FC, MKDIR or MD, MOVE, RD, RENAME?, TIME?, XCOPY.
Re:For the old farts familiar with DOS (Score:2)
Re:For the old farts familiar with DOS (Score:2)
Looks like no one has given you a real answer yet. (Score:3, Informative)
If your users are familiar with dos you might also make "edit" an alias to "nano -w" or something similar. Forcing them to use vi right away might be offputting. (It was the first time I used unix)
Make sure rm is aliased to 'rm -i' if your distro doesn't do that already.
If you aren't using X, and everything is completely terminal based (or maybe even if it is). I'd make sure GNU screen is installed on those systems. Once your users get comfortable with the basics, screen adds some really nice features to the mix.
Re:Looks like no one has given you a real answer y (Score:3, Funny)
-h's & -i's (Score:2, Informative)
Re:-h's & -i's (Score:2)
Yeah, that's really nice... except after a while people get really tired of the endless "do you want to delete this? do you want to delete that?" and then go on to add -f to everything. Whoops, suddenly you get no warning when you rm something read-only (and when something is read-only in *nix, it's usually for a good reason)...
/* Steinar */
Re:-h's & -i's (Score:3, Insightful)
Then what is the use of the aliases? The main point is: Constant warnings like that are way too annoying to do any good; people start ignoring them in various ways all too soon, if only mentally.
/* Steinar */
Re:-h's & -i's (Score:2)
-f.
/* Steinar */
Please, no color ls. (Score:2)
Because nobody has a clue what the colors mean. Because the default colors always include something dreadful like dark blue (unreadable on a black background) or yellow (unreadable on a light background.)
Instead, use
so that it tacks on "/" on dirs, etc. Yeah, also not necessarily the most obvious thing in the world, but at least you can read them.please do NOT alias in '-i'. (Score:3, Insightful)
So, of course, as the systems I did support for were stock systems, we had the joy of explaining to people why 'rm *' didn't prompt them, just like they were expecting it to, as it did on the engineering school's computers.
Dumbing things down can have the exact opposite effect that was intended, when people think that's the way that the shell always works
Decent prompt (Score:4, Informative)
Additionally, if there's any chance they'd use a command that checks the EDITOR or VISUAL or whatever environment variable, make sure that they do not launch vi. Give them something simple and easy like nano.
Consider the colors that 'ls' uses. Consider whether or not they'd be helped by a default like ls -p (print / and the like on the end of directories, @ for symlinks, etc.)
Re:Decent prompt (Score:2, Informative)
I mean, at least GNU ls(1) will use terminfo to see if/what is possible to do...
What is it with people wanting their prompts (or les output!) colorized, anyways...?
Re:Decent prompt (Score:2)
It's pretty, and comfortable and color can make it easier for your mind to pick out what is important from something you're looking at.
My prompt contains my username and hostname in dark blue...because it's something I need to know the instant I hit the box but don't much care about after that (unless I hit the wrong box!). But the path is in violent-bright-red, because while doing anything it's really nice to get that
what?? (Score:4, Insightful)
Re:what?? (Score:2)
Create a 70's environment (Score:3, Funny)
I recommend (Score:2)
Also, I recommend setting your email to "out of office" and turning your cell phone off.
Vital thing (Score:3, Informative)
Additionally, make *sure* their home, end, backspace, delete keys work properly. I'm not sure if we're talking pure command line or xterm (it's more an issue with some distros and xterms) but it's a hell of a lot to figure out when it's busted and a hell of a pain for a Windows user. It's not exclusively a shell issue but relates to the CLI experience.
And I'd recommend *not* aliasing 'rm' to 'rm -i' because they're going to get sloppy and be really annoyed when they move to a box that doesn't have that set up and wipe stuff out.
Set up their pager with something nice like 'export LESS="-eFMRXj12"' (well, it's nice to me).
Stuff like 'shopt -s checkwinsize cmdhist extglob histappend histverify [etc]' - histverify is cool for new people not popping off the wrong command by accident when they're playing with the cool history tricks.
Basically, keep it simple - avoid extremely dangerous things like giving them a fuzzy concept of 'rm' and enable not-particularly-dangerous things like 'histverify'. But make sure things like their keyboard and display work like they expect - most important thing. Then just give some hints and enable them to explore for themselves.
Another way to do a cheat sheet (Score:2)
This is a short summary of useful commands.
To get around help:
Press space to move down
Press (command) to move up
Press q (quit) to leave help.
And if you have any suggestions, email me: blah@blah.com.
Just an idea. I might even move my cli cheat sheet into something like to this to help my creaking mem-o-reee
Extensive, smart tab completion (Score:3, Informative)
You said no shell advocacy, so I won't recommend zsh, but something like its tab-completion mechanism would be a really good idea. I believe some packages exist to give bash similar abilities, and I would highly recommend installing them.
Good tab completion makes using the command-line much easier for novice users, once they get the idea that any time they aren't sure what to type, they should just hit TAB. Don't remember the options to "ls"? Just type "ls -" and you'll get a nicely formatted summary. Don't remember the name of the directory you want to "cd" into? Just hit TAB and you'll get a list of the directories (not files!) in the current directory.
And good tab completion knows about lots more than just the shell builtins or common commands. It knows all about *lots* of command-line tools, their options, what types of files are reasonable parameters for them ("gqview " gives a list of IMAGE files and directories in the current directory, omitting any non-image files from the list -- gqview is an image viewer), etc. zsh tab completion even knows how to look at remote systems to get completion info. For example, typing "scp 10.0.1.1:f" gets me a list of the files on my home directory on my Linux router that begin with "f". If there's only one, it gets expanded for me.
Even when smart tab-completion can't tell you what to type, it often gives you a good hint. I think that would be very helpful to (smart, computer-savvy) command-line newbies.
For Newbies...Do Not Forget -i (Score:2)
Just so you don't get forlorn people asking about how to undelete things, retrieve them from wastebaskets, etc., you might want to alias rm, mv, cp to use the -i option.
Later, after they get tired of answering yes they can learn how to edit their profile and remove the training wheels.
[Even then, I hope you have a good automated nightly backup running on the user's home directories.]
stty dec (Score:2)
cp/rm/mv -i !!! (Score:2)
And set them up with a shell prompt that shows username, host, and current directory.
Some other useful things (Score:2)
alias -x vi='vim -T xterm-color' alias -x cd='Xcd'
Xcd()
{
if [ $# -ne 0 ]; then
'cd' "$@"
else
'cd'
fi
echo " ^[ ]0;${HOST}:${PWD} ^G "
}
Xcd
fi
I never finished the Xcd() function to perfection, but it generally does what I want. Note that the ^[ and ^G are binary, 0x
Re:Some other useful things (Score:2)
The nice thing about my .profile is this: rather than placing your suggestions in all the little dotfiles, I instead have a single file which is easy to scp/ftp/cut+paste. Who wants to fuck around with copying a whole crapload of dotfiles onto every box they use? I log into a new box and scp my .profile. 99.99999% of the time, I never have to touch it again. I have tailorings for Linux, FreeBSD, Solaris, AIX, HP/UX, and Cygwin.
To be fair, I typically use GNU tools on those OS's which are not fortunate
Let them change shells (Score:2)
Shells are a personal thing, and trivial to install and change. Make whichever you want default, but let the advanced users change shells. You might hire an old school Unix guy, like me, who likes his own personal shell. Make sure it is there. Not the default, but there for advanced users.
csh/tcsh is a must, because it is different and some people prefer it. (I still can't wrap my mind around bash, not that I've tried)
Install the adventure shell, because someone will want to try it.
The main re
Newbie toggle script and more... (Score:3, Insightful)
No matter what, make it absolutely clear whenever they use something that can bite them hard on a normal terminal. Don't train them to fail later. Aliasing 'rm' to 'rm -i' can hurt them bad when they get used to typing 'rm *' to be prompted for which files to delete.
If you want to get really advanced, include two scripts that will switch them to 'normal' mode or back to 'training' mode.
Start them out in training mode. When they log in, they get:
* an entire screen of help, including the command to leave training mode, and listing the safety nets you added.
* their prompt contains "(TRAINING)" or "(NEWBIE)" or something
* alias 'rm' to 'rm -i', etc.
* any other safety nets
* point out 'grep', 'find', 'head', 'tail', 'less' and the cute little 'wc' and where to discover more about unix commands.
When they switch to normal mode, after confirmation, their login only includes the command to return to training mode. (Which they can edit out of the
The idea is that you make sure that they know which safety nets you create, that aren't on other systems. They also get a transistion period for as long as they want. Leaving the "TRAINING" in the prompt is a continual reminder that there setup is more 'safe' than other systems, and may add motivation to go into normal mode.
The rest of this is from my tcsh experience:
* set up 'complete [freshmeat.net]' options for common, yet complex commands like 'find', 'alias', 'set', 'man', 'nethack'. (very cool in tcsh [freshmeat.net], is this feature in bash?)
* alias l=ls, ll=ls -l, la=ls -a (doesn't hurt anyone)
* set tab to autocomplete or list matches, if it doesn't already
* include apache-style comments (maximum verbosity) inside the
* set prompt to "(time)
* don't alias any DOS commands directly to Unix except for 'dir'. Alias the others DOS commands to mini-helps that remind them gently to use the proper Unix command.
* use nano
Tab completion, fortunes, and -i (Score:2)
Second, setting up a bunch of "-i" aliases is an extremely bad idea for newbies. Considering that they're starting with a blank slate, this is the time when they can most afford to learn that the machine will always do what t
Re:Tab completion, fortunes, and -i (Score:2)
So I tried it, it was crack, but I switched back. I like wildcards.
"set -e" (Score:2)
good editor (Score:2)
I'd like to suggest using joe -- it's a nice editor with a good user interface (in that it's easy to figure out how to use based on the interface, without resorting to man pages/tutorials/etc.). It's got a PICO emulation (invoked with "jpico") for those who insist on using keybindings from a badly licensed editor, but offers more commands than PICO and clones.
It's not guaranteed to be "all the editor you'll ever need", but it
Hmm... (Score:2, Informative)
My two cents:
The prompt should take the form "user@host:path % " - this is particularly important in environments with multiple machines, and a good idea anyway.
The shell should be set up for command-line editing (BASH comes this way IIRC, in KSH set -o emacs. If you have any *NIX users (probably not or you wouldn't be submitting this particular question) they can set -o vi if they prefer that.), and the backspace key should work properly (if you need to stty for
bash completion (Score:2, Informative)
- it helps newbies learn what options are available for commands. for pros, it saves a zillion keystrokes a day and is extendable
Modify the .inputrc (Score:2)
The ~/.inputrc I use:
$include /etc/inputrc
set editing-mode vi
set mark-directories on
set completion-ignore-case on
The editing-mode is up to you. I'm not going to fuel this holy war.
The mark-directories and completion-ignore-case are probably worth while, however.
Background processes and multiple consoles (Score:2)
If you make a cheat sheet, I suggest putting a detailed map of the *nix directory structure on the back side of it, with notes explaining what's in each directory.
Re:shopt -s checkwinsize !!!! (Score:2)
This is so that their commands will wrap to the next line when put in small windows
What's the problem?!?!? The only way to make small windows is small fonts right. Doesn't EVERYONE use the standard 80 columns?
Never had a problem.
Re:shopt -s checkwinsize !!!! (Score:2)
Re:One of the most useful things to include. . . (Score:2)