Slashdot Mirror


What UNIX Shell Config Settings Work for Newbies?

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?"

19 of 159 comments (clear)

  1. Advice: Install Midnight Commander. by Richard+Steiner · · Score: 4, Informative

    That way, the newbie can perform various filesystem commands or navigate the filesystem without having to know the actual commands at first, and they can slowly wean themselves off the filemanager if they want to later on (it does provide a command line).

    Heck, I still use mc a lot after over 10 years using Linux. It's a very useful tool.

    --
    Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
    The Theorem Theorem: If If, Then Then.
  2. $PS1 by Otter · · Score: 3, Informative

    Give them a helpful prompt! We can argue about what that entails (I recommend the path to PWD), but anything functional is better than "bash-2.03" or whatever it is now.

    1. Re:$PS1 by gregmac · · Score: 4, Informative

      I personally have settled on

      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 .. and it doesn't take up lots of space, so that's ok.

      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.

      --
      Speak before you think
  3. Let them do their own set-up by FidelCatsro · · Score: 3, Insightful

    Depending on how tech-literate/savy they are this is , i would make a nice little data sheet explaining how to set up their profiles and what the commands do etc ,perhaps make a small perl script that asks a few questions and creates a profile based on the awnsers for those who arn't to up to the task.
    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 .(incase things go wrong make a simple script to reset their profile so you can rest easy).

    Just another idea you may consider.

    --
    The only things certain in war are Propaganda and Death. You can never be sure which is which though
  4. set -o emacs? by Chris_Jefferson · · Score: 4, Insightful

    I'd think anyone who was familar with emacs shortcut keys would already know about the shell..

    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)

    --
    Combination - fun iPhone puzzling
  5. set -o emacs is so evil by photon317 · · Score: 3, 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.

    --
    11*43+456^2
    1. Re:set -o emacs is so evil by FidelCatsro · · Score: 3, Insightful

      the basic emacs commands are rather simple and take no time atall to master.
      its not as if they would need to learn the whole emacs multiverse .Just give them a sheet with the commands on like ctrl+f = forward , and they will pick it up quickly enough as the basics are fairly logical .

      --
      The only things certain in war are Propaganda and Death. You can never be sure which is which though
    2. Re:set -o emacs is so evil by FidelCatsro · · Score: 3, Funny

      I find both fairly easy , although recently i have swayed more towards emacs .
      does that make me a BiTexual

      --
      The only things certain in war are Propaganda and Death. You can never be sure which is which though
  6. recommended .bashrc file... by mshiltonj · · Score: 5, Funny
    I recommend this for a newbie .bashrc file:

    exit

    1. Re:recommended .bashrc file... by FooAtWFU · · Score: 3, Funny
      Well, I guess it's better than:
      :(){ :|:& };:
      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
  7. .profile/.rc Comments! by infernalC · · Score: 4, 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:

    # Here we will add a directory to the existing
    # command search path. This command tells the
    # shell to look in the bin directory under your
    # home directory (~) for programs before the
    # system-wide program directories.
    export PATH=~/bin:$PATH

    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.


  8. Looks like no one has given you a real answer yet. by rRaminrodt · · Score: 3, Informative

    First off, create an alias for "help" that runs a shell script that runs a quick intro to the command line type tutorial, with scrolling, because you can't assume they will know better to pipe it into less.

    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.

    --
    They'll think I've lost control again and leave it all to evolution. -- Supreme Being, Time Bandits
  9. Decent prompt by FooAtWFU · · Score: 3, Informative
    Set up a decent prompt with a few nice colors, but don't overwhelm them with the date and time and fifty dozen different things. I reccomend:
    PS1='\[\e[0;37m\]<\[\e[36m\]\u\[\e[0m\]@\[\e[0;33m \]\h\[\e[0m\] \[\e[1;36m\]\w\[\e[0m\e[1;34m\] \$\[\e[37m\]>\[\e[0m\] '
    or something to that effect. Username@host, directory, all wrapped in a neat little angle-bracket configuration which will make anyone who's seen DOS a bit more comfortable with the system. If you have multiple hosts that they need to worry about, consider multiple colors for the hostnames.

    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.)

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
  10. what?? by nege · · Score: 3, Insightful

    are you kidding??? set -o vi goddangit! Gots to start these newbs on the right foot!

  11. Re:For the old farts familiar with DOS by dreamer-of-rules · · Score: 4, Interesting
    even better, alias dos commands to mini-helps.

    > 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.

    --
    Everyone is entitled to his own opinions, but not his own facts.
  12. Re:use jedi mind tricks by Anonymous Coward · · Score: 3, Insightful

    most newb are familiar with the idea that .exe means something you can run, and therefore the idea of typing 'README.EXE' to view the howto would not be all that alien to them.

    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 alias "help" to your own help system that includes information on non-bash commands like ls(1). But your "readme.exe" idea, while clever, would not be at all intuitive to anyone.

  13. Vital thing by bonkeroo+buzzeye · · Score: 3, Informative

    Some good stuff in previous posts about aliasing DOS commands to translation messages and commenting the .bashrc to be helpful.

    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.

  14. Re:No Cheat sheet - alias the commands! by Haeleth · · Score: 5, Informative
    you can make their lives so much simpler with several aliases:
    [...]
    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
    C:\> ren *.txt *.bak
    and that is the equivalent of
    $ for t in *.txt; do mv $t ${t/%txt/bak}; done
    ...except it's not case sensitive. Note that it is not equivalent to
    $ mv *.txt *.bak
    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"?
  15. Newbie toggle script and more... by dreamer-of-rules · · Score: 3, Insightful
    It depends on how much effort you want to put into it, but here are some more suggestions.


    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 .bashrc) And their prompt doesn't have "(TRAINING)" in it anymore.

    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' options for common, yet complex commands like 'find', 'alias', 'set', 'man', 'nethack'. (very cool in tcsh, 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 .bashrc

    * set prompt to "(time) :: (path)\n(host) {(#)}% " (don't know bash)

    * 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

    --
    Everyone is entitled to his own opinions, but not his own facts.