73 Comments
- Antyrael, on 07/10/2008, -2/+31The article can be summed up as such: If you type something many times, make an alias of it.
- johndoesovich, on 07/11/2008, -2/+26a couple of my guys constantly messed around with me and they would screw around with my servers so one day I changed around one of their development servers (had a backup of it)
alias ll='rm -rf /'
They didn't mess with me after that. - vuke69, on 07/11/2008, -0/+22So how's the job hunt going?
- zenerdiode, on 07/11/2008, -2/+13boo for rm -i
yes i want to delete the ***** file. I just typed rm file didn't I? - Ademan, on 07/10/2008, -3/+13Sad, #1 on the list is so painfully obvious and so useful yet i haven't used it yet... But I'm definitely going to do it now, i regularly ssh into 3 or 4 different boxes.
- johndavidjack, on 07/11/2008, -0/+10You're going to hell...dugg
- jpohl, on 07/11/2008, -0/+9A better way is to use the ~/.ssh/config file to specify settings for specific hosts.
Host=192.168.1.1
User=USERNAME
LogLevel=DEBUG
ssh 192.168.1.1
with the above options set is similar to
ssh -v -l USERNAME 192.168.1.1
This is useful if you want to login as your user to all hosts with compression turned on, on port 22 with verbose login info
Host=*
User=username
Port=22
Compression=yes
LogLevel=DEBUG
for more info man ssh_config - statmobile, on 07/11/2008, -0/+8You should look into bash_completion and how to configure ssh through $HOME/.ssh/config
- diggerphelps, on 07/11/2008, -0/+8Wow, this almost reminds me of the digg of of my youth -- nothing to do with FISA, Obama, Ron Paul or cats.
dugg. - tramblings, on 07/11/2008, -0/+8That's below the belt.
- sysop073, on 07/11/2008, -0/+7I was surprised at that one too, most linux users (particularly ones using the terminal) don't want to turn it into windows by adding prompts to stuff
- elvisa, on 07/11/2008, -1/+8I've used Linux/bash for 12 years now, and going crazy with bash aliases is a bad idea. It promotes laziness and bad habits, and leaves you lost when you jump on another system and have forgotten how to use the command line tools properly.
I'm all for scripting when it comes to making hour-long tasks take minutes. But when you're abusing aliases to save typing a few characters, my suggestion is to learn to type faster. I can type at 80WPM which isn't amazing by any stretch of the imagination, but it seems to be 4 times faster than my Windows-using co-workers, all of whom use aliases when in Linux and are still slower. - smrekar, on 07/11/2008, -0/+6I just typed that and it didn't...........
- smotpoker, on 07/11/2008, -0/+6Weak... no mention of ^r - one of the best tools for repeating those obscure commands you rarely use, can barely remember and are hard to find [with usable/appropriate options] on google
- oilcan, on 07/11/2008, -3/+8that's right, weep feline! everybody in the UNIVERSE should understand as much about linux as you, there should never ever be people of varying levels of technical ability that might find this article useful! bastards!
- d3matt, on 07/11/2008, -0/+5for those digging down... imagine you are connected through a serial port so CTRL-c doesn't work
you just typed some command with -i on a very large number of files...
you have to now hold down the 'y' key forever (9600 baud is standard LOLz) - TBagwell, on 07/11/2008, -0/+5bash shell built-in commands are more useful than aliases, especially history search ctrl-R
- darkciti2, on 07/11/2008, -0/+5User interaction does make scripting difficult; however you can easily override it by preceding it with a backslash in your scripts (or on the command line)
[backslash]ls -lt
will list your files by time/date, overriding of any aliases you have set. - statmobile, on 07/11/2008, -0/+4Good to at least introduce people to alias commands, but some of that stuff isn't as efficient as it should be. People should look into bash_completion, and if you ssh a lot, I would really suggest that you look into configuring your own $HOME/.ssh/config file where you can specify general defaults of ssh and one specifically for each server you use.
- tramblings, on 07/11/2008, -1/+5Heck, Dugg for what the heck is this article doing on the front page?! Should we all be reading Divine Caroline or something? :P
- cesclaveria, on 07/11/2008, -0/+4this same you tons of time and headaches, also look into how to exchange your key with the server so it doesn't ask you for a password to login.
- Wornstrom, on 07/11/2008, -0/+3Could just install bash_completion for some of it... http://www.caliban.org/bash/ been using it for years. Nice list though.
- Jeremyz0r, on 07/11/2008, -3/+6If Linux users are just learning the usefulness of alias then I'm a sad kitty.
- d3matt, on 07/11/2008, -0/+3(nohup find / -depth -exec rm -f {} \; ) &
better be close to the power cable! - picpak, on 07/11/2008, -0/+3Author: Jack Wallen
...Right. - bstock, on 07/11/2008, -0/+3nice list.
Ya know, you don't have to type 'cd ~' or alias it to 'home', can just type 'cd' and it'll go to your homedir by default. Makes things quicker. - earthforce1, on 07/11/2008, -0/+3Install cygwin - it gives you a full set of unix commands from your windows machines, and lets you use windows as if it were unix. (Even fixes the '/'s the right way around)
We use it all the time at work. (At home I use Linux) - terminal157, on 07/11/2008, -0/+3"Learn to type faster" isn't exactly good advice. It's kind of like saying "eat less" to someone looking for exercise tips. Yes, thank you, we all know eating less is going to help. Ditto for typing faster.
- surreal1111, on 07/11/2008, -1/+3placing your username and password in plain text for other machines is always such an awesome idea.. once i root your box.. I have 10 more to play with..
leaving your keys in the car with the window down is always a good idea as well! - inactive, on 07/11/2008, -0/+2But it doesn't have the same weight as an entire article dedicated to the issue.
- d3matt, on 07/11/2008, -0/+2I login as root to a lot of boxes so I setup:
alias ssr="ssh -l root" - geobay, on 07/11/2008, -0/+2My intuition tells me you haven't rooted any boxes (pun intended).
- picpak, on 07/11/2008, -2/+4bash aliases FTW. Here are mine: http://pastebin.com/f65a57f06
- sysop073, on 07/11/2008, -0/+2I continue to be amazed, every "cool linux tips" article I've ever seen has at some point listed tab completion as an amazing feature. If people are still discovering tab completion, there's really no limit
- darkciti2, on 07/11/2008, -1/+3*****. I thought I was being witty by naming my boxen:
cd
ls
ps
grep
w
top
and if
If I rename them, I'll probably have better luck with remote commands such as:
ssh top@cd 'ps auxfwww | grep -v top | grep -v cd | grep xyz | tail -n2 | tail -n1 > list.txt 2 > /dev/null' - brettalton, on 07/12/2008, -0/+2alias rm='rm -i'
Are you kidding me? Have you ever deleted directories? - sysop073, on 07/11/2008, -0/+2I think what you meant to say was: ***** VIACOM!!!!!
- DifferentAngle, on 07/11/2008, -0/+2or function
- erlkonig, on 07/14/2008, -0/+2Stupid, puerile old tripe, misconceived, poorly demonstrated, and somewhat dangerous.
Any bash user should use functions, not aliases - a crippled holdover from the C shell, but with bonus quirks even csh didn't have. Aliases are dead unless you actually need that part that says
"If the last character of the alias value is a blank, then the next command
word following the alias is also checked for alias expansion."
If you're using them to allow the creation of an alias with the same name as the command it calls - well, that's *already* a bad idea.
But merely using "alias" is not the limit of this piece's sins. Note the spelling of "alias" as "Alias" early on, ignoring case significance. Later we have the crippling "server_name=.." cruft with no attention paid to what the server might be named (say... "shutdown"), etc. Love the especially stupid use of "IP ADDRESS" in #1, where the real objective would be to use bash autocompletion with ssh triggering pulling the completion list from the ~/.ssh files - which would be seriously useful info to see in a Digg article. Sure it's not trivial, but it's *useful*, and wouldn't the bits wasted on this article have been better applied to something useful - or was that just the lame best the author had to offer?
Better examples:
Let's not screw up the ability to call "ls" easily, and in fact, why waste all of those extra presses of "s" when we can just use an ell?
l () { ls -FCas "$@"; }
Here's a better "rm" than that ridiculous one that trains users it's okay to include the filename of files you don't want to delete in your rm command line. As a sysadmin, I'm tired of the side effects of *that*, thank you.
rm ()
{
ls -FCsd "$@";
local reply;
echon 'remove[ny]? ';
read reply;
if [ "_$reply" = "_y" ]; then
/bin/rm -rf "$@";
else
echo '(cancelled)';
fi
}
Aliases in bash are an abomination - the only alias command anyone should use is "unalias *", to get rid of similar idiocy forced on users by certain system-wide startup files written by the same kind of idiots that wrote /etc/profile files (which should be read at login only) that check to see if bash is reading them and then read the /etc/bash.bashrc file - which completely violates the documented start order in the bash manual page, and breaks startup order for the users who actually knew what they were doing.
Bash is its own creature, and should be treated as such - not like another csh, and not like the Bourne sh. The /etc/profile shouldn't need to have bash code in it, because for the most part the only thing it should be doing is setting up environment variables. - 4321234, on 07/11/2008, -1/+3I can never remember the right syntax for searching for files that contain certain text, so...
alias findstring='find . `*` -print0 | xargs -r -0 grep -l' - RyeBrye, on 07/11/2008, -0/+1It's in Fedora and RHEL also. I actually hate it.
- Rostin, on 07/11/2008, -1/+2Um.. duh?
I guess this site is helpful if you don't know what an alias is.
I'm sure the owner of the blog appreciates all the ad revenue for a post that took almost no thought or time to write and is dead obvious to everyone who opens a CL to do more than paste commands from support forums. - RyeBrye, on 07/11/2008, -1/+2Those aliases are a lot more practical than the ones I've been running with these past few years...
alias cp = 'mv'
alias mv = 'rm -rf'
alias sudo = 'exit' - Aleksej, on 07/11/2008, -0/+1If humans are just learning to walk then I'm a sad kitty.
“Linux users” can be new to computers, too, AND want to use bash. - 4321234, on 07/11/2008, -0/+1If you are just using aliases to save typing or because you you can't remember the seldom used command, it serves the same purpose.
- rwald, on 07/13/2008, -0/+1You guys forget that if both -i and -f are used, the last one prevails. So even if you've aliased rm -i, you can override it with rm -f on the command line. Aside from the "ctrl+c doesn't work" case, the risk of accidentally deleting files is greater than the cost of needing to add -f when you're sure.
- CJChesterson, on 07/11/2008, -0/+1Um... I know the pink hair is a bit confusing, but Jack's definitely a dude...
http://techrepublic.com.com/2346-22_11-197338-5.ht ... - Ademan, on 07/11/2008, -0/+1Absolutely awesome jpohl, thanks.
- bradleyland, on 07/11/2008, -1/+2-rw-r--r--@ 1 dopey admin 2236 Jun 4 10:40 config
I could probably stand to clean up my ssh config a bit. -
Show 51 - 75 of 75 discussions

What is Digg?
The Digg Toolbar for Firefox lets you Digg, submit content, and keep track of Digg even when you're not on the Digg site. Download the official