June 29, 200818 yr Simple idea this one. We post alot of advice on this forum for "type this command" and tell us what it says. I was thinking it would be easy to maintain a .bashrc alias list of useful abreviated commands to help users. For instance im personally a fan of aliasing "l" to "ls -al" All it would take is a wiki page and Tom to sign on. What you all think?
June 29, 200818 yr What commands need to be aliased? I think if anything we need some form of diagnostic command that captures a number of outputs. If comprehensive enough it should be put into emhttp.
June 29, 200818 yr What commands need to be aliased? I think if anything we need some form of diagnostic command that captures a number of outputs. If comprehensive enough it should be put into emhttp. We discussed this exact topic in this thread: http://lime-technology.com/forum/index.php?topic=1804.msg12707#msg12707 I suggested "s" to aliased to a a command to capture a lot of diagnostic and syslog data in addition to deleting the "Registered To" name in syslog captures (for some additional privacy). I like the idea of a link in emhttp to collect the syslog/disk/status/ information and when clicked, just download it all to the user's browser. Unfortunately, half of the time, people who need assistance can't get to the management console, and there is where the single letter alias available at the command line would be a great help. Joe L. PS. I always liked "l" as well. Tom already has a number of aliases in place.
June 29, 200818 yr Perhaps a new thread on the most useful diagnostic commands? I see that the ethtool output is not part of that, nor the ifconfig which I think should be. If we create a shell script to create the diagnostic output ready to upload it may make it easier in the future. I.E. 1. we create a shell comamnd with all information needed. 2. have tom include it in the distro. 3. when help is needed the command is run by the user with a fully ready zip file to upload on his flash.
June 29, 200818 yr Author why not take it a step further and have the script optionally dump to pastebin.com or the like. As for aliases a simple one like "unraid" or "help" etc could list some helpful advice on commands. Other ones like du -h --max-depth=1 are handy as well
June 29, 200818 yr Tom already has a number of aliases in place. He does? Yup. root@Tower:/# alias alias d='dir' alias dir='/bin/ls $LS_OPTIONS --format=vertical' alias ls='/bin/ls $LS_OPTIONS' alias mc='. /usr/share/mc/bin/mc-wrapper.sh' alias v='vdir' alias vdir='/bin/ls $LS_OPTIONS --format=long' root@Tower:/#
June 30, 200818 yr A question from a neophyte: Being an old DOS command line guy, but a very lazy typer who prefers to never type the same thing twice (creates a macro for it), I started investigating bash aliases a few weeks ago, but gave up, unsuccessful. Below is a test macro'ing file I was trying to get working, just to start with. I first tried the bottom 3 lines (without the pound signs naturally), completely ignored, must be an incredibly limited scope on the alias command. Then I tried the top lines, to add them to /etc/profile, but that does not work either, gives errors on every Telnet start, about every space-separated group of parameters. I used the profile file because I could not locate any bash files like .bashrc, and wasn't sure where they should be put. And I would prefer to leave LS_OPTIONS just the way it is. I spent a day or two researching this, and got nowhere. So what is the correct way to set a group of aliases? #!/bin/bash echo alias dn='ls -Aogt --group-directories-first --time-style=long-iso'>>/etc/profile echo alias ds='ls -AogtR --group-directories-first --time-style=long-iso'>>/etc/profile echo alias tale='tail -f --lines=120 /var/log/syslog'>>/etc/profile ###alias dn='ls -Aogt --group-directories-first --time-style=long-iso' ###alias ds='ls -AogtR --group-directories-first --time-style=long-iso' ###alias tale='tail -f --lines=120 /var/log/syslog' From my DOS days, I would always have a doskey macro for dn=dir/p/o-d $*, full dir listing sorted by newest files first, and ds=dir/p/o-d/s $*, same as dn plus recursing through subdirs.
June 30, 200818 yr try it like this keeping the single quotes as is, but framing everything in the echo command in double quotes. This will need to be put into your go script to add this upon ever reboot. echo "alias dn='ls -Aogt --group-directories-first --time-style=long-iso' " >> /etc/profile Also .bashrc is typically in the home directory of the user.
June 30, 200818 yr Thank you, that worked perfectly. The double quotes preserve the single quotes. I've got lots more questions, but will try to learn and do as much on my own as I can. My sense of bash so far is it was built by a large committee with out a leader or discipline. Anything anyone wanted was added, even if redundant. That can be very powerful and flexible, but usually brings a lot of baggage and confusion for new users. Lots to learn... thanks again, a barrier eliminated...
June 30, 200818 yr Tom already has a number of aliases in place. He does? Yup. root@Tower:/# alias alias d='dir' alias dir='/bin/ls $LS_OPTIONS --format=vertical' alias ls='/bin/ls $LS_OPTIONS' alias mc='. /usr/share/mc/bin/mc-wrapper.sh' alias v='vdir' alias vdir='/bin/ls $LS_OPTIONS --format=long' root@Tower:/# Funny - I discovered these quite by accident. Back in my Solaris days I had at least 50 aliases set up and one of my first was "dir" (DOS dude) which I had set to "ls -al|more". Out of habit I typed "dir" when toying with my unraid and found a similar alias was already set up. Bill
June 30, 200818 yr Author Sounds like this idea is an undocumented feature already implemented. Who wants to sponsor a wiki page to track the new ones we want to add?
August 13, 200817 yr Author Opinions; what do you think would be better for users: a: lots of alias in the go script etc b: create a .bashrc copy it up and source it to load it I am thinking option b would be better. Does anyone have any suggestions for a .bashrc script they use or will i just use the generic one since root doesnt have one setup in the normal ~/.bashrc that i can see
August 13, 200817 yr Opinions; what do you think would be better for users: a: lots of alias in the go script etc b: create a .bashrc copy it up and source it to load it c: create a .profile, .kshrc and a .exrc and copy all three to /root
August 13, 200817 yr Author lol what moronic mistake am i making? root@:~# echo $SHELL /bin/bash root@:~# ls -al /bin/bash -rwxr-xr-x 1 root root 678832 Aug 13 10:09 /bin/bash* why do we need a korn shel config?
August 13, 200817 yr why do we need a korn shel config? I did add a smily... Because I installed korn shell. "ksh" has a much better command line history and editing ability for those of us who know either "vi" or "emacs" Joe L.
August 13, 200817 yr Author haha you really had me going there .bashrc it is then.. want more than me to benefit from this and i dont see many users going for korn
August 13, 200817 yr "ksh" has a much better command line history and editing ability for those of us who know either "vi" or "emacs" I've always thought that bash was quite comparable. In fact I've not seen any difference. Then again, I may only be using a smidgen of what is available. (I always use set -o vi).
August 13, 200817 yr "ksh" has a much better command line history and editing ability for those of us who know either "vi" or "emacs" I've always thought that bash was quite comparable. In fact I've not seen any difference. Then again, I may only be using a smidgen of what is available. (I always use set -o vi). No wonder I disliked the default "bash" command line editing, it defaults to "emacs" mode (yuck) Looking further, I see it is set that way in /etc/profile. Truthfully, I did not know bash had a "vi" command line mode. (I learned something new today ) To properly set it, apparently you create a file named .inputrc in your home directory, and in it put these two lines: set editing-mode vi set keymap vi-insert In our case, it goes in /root/.inputrc Now, if bash had associative arrays, it might equal ksh... until then, ksh might still come in handy at times. No matter, "awk" has them, and if I must, I can write a bit using that syntax. So... how about adding .inputrc and .profile to your list. Joe L.
August 13, 200817 yr Author Will do. This would be so much easier if we had some colaborative file editing system. SVN would be too much but something simpler would be a god send.
August 13, 200817 yr Truthfully, I did not know bash had a "vi" command line mode. (I learned something new today Wink) I feel proud. I taught YOU something! LOL btw, you don't have to use .inputrc. I usually just do set -o vi
August 13, 200817 yr Now, if bash had associative arrays, it might equal ksh... until then, ksh might still come in handy at times. No matter, "awk" has them, and if I must, I can write a bit using that syntax. This is what is missing. Then again, not all systems have the latest KSH either, so associative arrays are not available everywhere in shell land. I do think KSH array handling is better, plus the fact that you can JUSTIFY values in variable.
October 27, 200817 yr Author I have created a fairly simple .bashrc file and uploaded it to the addons site. This will make a big difference to telnet usability for general users and is highly recommended. Suggestins for more bashrc tweaks welcome. To install (assumes you have wget, if you dont then copy it up and move it manually) cd ~ wget http://unraid.yi.org/addons/bashrc.txt mv bashrc.txt .bashrc . .bashrc If it works your command prompt should change color. Enjoy
October 31, 200817 yr I have created a fairly simple .bashrc file and uploaded it to the addons site. This will make a big difference to telnet usability for general users and is highly recommended. Suggestions for more bashrc tweaks welcome. If it works your command prompt should change color. Enjoy I don't think you realized that you were opening a (small) can of worms! I was immediately interested when I saw this, and grabbed it, and opened it up for examination, expecting to learn much (and I still am). But I quickly realized there was so much I did not understand, and it was clearly going to make numerous changes to my system, that there was no way I could run it without being fully aware of the ramifications. I and any user with some computer experience and common sense (which of course includes all unRAID users!), are understandably reluctant to run or install unknown commands, until we feel comfortable with them and the changes they will make. Coloring the prompt is certainly harmless, but it was one of the very few changes I understood, and it is the only one you mention above. Your reputation is good, and your intentions and recommendation of it is fine, but I don't see how any one else can recommend it, without understanding it better. So as a way of enabling a better understanding, and learning some bash syntax at the same time, and making it easier for you to document .bashrc, I thought I would 'interview' you here, with the following questions. First, thank you for providing this, for all the effort put into it, and the collection of computer experience shared in it. # If not running interactively, don't do anything [ -z "$PS1" ] && return Coming from an MS-DOS background, having used unRAID for about a year, and reading all of Joe's and other's messages, and putting a little time into a bash manual, I like to *think* I've learned a little bash syntax, but this one is beyond me already. And I suspect most new users won't have a clue. I do recognize that it appears to be an AND'ed pair of evaluated expressions, but what does it do, and why is it necessary? # don't put duplicate lines in the history. See bash(1) for more options export HISTCONTROL=ignoredups I'm guessing that export is similar to the DOS set command, for setting environment strings, and this one applies to the command history? So this parameter causes some consolidation of the history, by searching the history for a copy of the current console command, and removing it? Or not pushing the current command onto the history? (I realize I could research much of this for myself, but that would only help me, so for the sake of many others who may be interested, and/or just introduced or wondering about bash...) Also, what is 'bash(1)'? And what does 'See bash(1)' mean? # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize Why would I need this? When is this a problem? export PS1='\h:\w\$ ' This looks like it could be analogous to the DOS 'set prompt=' command. But the colorized version of it occurs farther down. Is there a reason we need to set it here too? umask 022 It sets attributes for something, but what? What difference in behavior will I see after this? Are there other values I might be interested in, and why? # colourize ls export LS_OPTIONS='--color=auto' This appears to replace Tom's somewhat longer LS_OPTIONS. Why would I want to do that? The current default is "LS_OPTIONS=' -F -b -T 0 --color=auto '". eval "`dircolors`" What the ... ? If it's evaluating something, the answer does not appear to be used. alias ls='ls $LS_OPTIONS' If you type alias at a console prompt, it lists "alias ls='/bin/ls $LS_OPTIONS'", which seems like a better form to me, as it removes one path lookup. Is there a reason why yours is better? # variables for colours END="\[\033[0m\]" BLUE="\[\033[0;34m\]" ... WHITE="\[\033[1;37m\]" These look like defines for ANSI Escape sequences. If the first and last bracket needs a backslash, shouldn't the middle one also? Is END an equivalent for black? Or is it required to turn off the colors? #Prompt export PS1="\u@\h $GREEN[\W] $RED\@$END>"; Guessing this creates the prompt string: user name, @, host name, turn green on, show path, change to red, @, turn off color, >. Is the semi-colon necessary? # aliases alias df='df -h' alias dirtree='du -k | sort -nr' alias dum='du -h --max-depth=1' alias l='ls -alh' alias cls='clear' alias ..='cd ..' You did not mention these above, so the only way a user would be able to take advantage of them, is if they know enough to look inside of .bashrc, and understand what an alias is. So we will 'expose' them here. An alias is similar to a doskey command, with an assumed ' $*' at the end. So this provides a way to create shortcuts for commonly typed commands. I like your '..' alias, as I often type 'cd..' or 'cd...' or cd....' (a DOS trick), and have to back up and add the space. In a later post, I'll offer a few DOS-like ones I use. I did not know about .bashrc, so in my go file, I append them to /etc/profile. This should be easier. shopt -s cdspell No clue here. What is it, and what does it do for me? mn() { lynx "http://man.he.net/?section=all&topic=$*"; } Wow! I hope I can assume this is not a spam call, for a masculine enlargement product? Because it looks like a function definition, with a web call to a very masculine web site! I'm not sure I'm interested in whatever this line can do for me. # stop ^S hanging torrent/putty stty -ixon Finally, the last unknown. What is it, and why do I need it? Thanks for taking your time to teach us, whenever you can find the time to respond. I hope you don't regret too much, posting this .bashrc.
November 5, 200817 yr Author Sorry not sure how I missed this. Dont have the time to write a detailed reply this now but heres an overview. This basrc is minimal effort on my behalf. Its a copy and paste and edit of my master bashrc that i take with me bewtween all my servers. This has evolved over time and TBH is a bit of a mess with no real notes on what anything does. Everything was added for a purpose at one point but that may have been many many moons ago. It also may comtain dupes. Will take a look at it when i can. That shopuld answer one question right away... aliases. Since i take this with me its easier to have one file than 2 so there may be a better way this just fits better with how i work. Some of the more cryptuic stuff is to counter the new line proble bash has where you type and at EOL it wraps to the begining of the line again. Particularly annoying when you are copy and pasting. export HISTCONTROL=ignoredups From memory this just stops multiple sequential history lines showing the same command. Useful if you use the up key to scroll through history. Cdspell " If set, minor errors in the spelling of a directory component in a cd command will be corrected. The errors checked for are transposed characters, a missing character, and a character too many. If a correction is found, the corrected path is printed, and the command proceeds. This option is only used by interactive shells. " mn() { lynx "http://man.he.net/?section=all&topic=$*"; } this wont work since lynx isnt installed. Basically it allows you to lookup a manpage from the commandline even if you dont have the tool installed. For unRAID this could be handy if we could make it work. Perhaps when curl comes we can do somehting. stty -ixon A bug fix that likely isnt need on unRAID. Will probably remove. I might not even need it anymore. If we can do one question to one answer from now on I and other will likely be able to shed more light. Sorry i dont have a better memory or more time to explain right now
Archived
This topic is now archived and is closed to further replies.