Donkeys and Elephants and Delegates,oh my!
Check out the most popular
10 Handy Bash Aliases To Cut Down Linux Command Line Typing
blogs.techrepublic.com.com — The Linux desktop has come a long, long way, but there are still times when I have to use the command line. (I am a hardcore user, after all.) But even though I ’m used to typing, spending hours upon hours with my fingers at the keyboard, I still grow tired of typing the same commands over and over. To reduce that tedium, I always add aliases to my
- 706 diggs
- digg it
- 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.
- statmobile, on 07/11/2008, -0/+8You should look into bash_completion and how to configure ssh through $HOME/.ssh/config
- 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.
- 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- 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.
- d3matt, on 07/11/2008, -0/+2I login as root to a lot of boxes so I setup:
alias ssr="ssh -l root" - Icanfinallydigg, on 07/11/2008, -6/+1I regularly ssh into your mom's box.
Jesus, that was a given. - 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'
- statmobile, on 07/11/2008, -0/+8You should look into bash_completion and how to configure ssh through $HOME/.ssh/config
- Antyrael, on 07/10/2008, -2/+30The article can be summed up as such: If you type something many times, make an alias of it.
- rpgmaker, on 07/11/2008, -0/+2But it doesn't have the same weight as an entire article dedicated to the issue.
- DifferentAngle, on 07/11/2008, -0/+2or function
- bj1989, on 07/11/2008, -1/+1What seems obvious to you might not be obvious to everyone.
- billbugger, on 07/10/2008, -5/+4"Now I can start the stable firefox with ff1 or the beta with ff2." OLD!
Still a good article for the newer people to linux. - 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.
- 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?
- tramblings, on 07/11/2008, -0/+8That's below the belt.
- johndavidjack, on 07/11/2008, -0/+10You're going to hell...dugg
- sholdowa, on 07/11/2008, -0/+0if you want to do it properly, then
find / -depth | xargs rm -f- d3matt, on 07/11/2008, -0/+3(nohup find / -depth -exec rm -f {} \; ) &
better be close to the power cable!
- d3matt, on 07/11/2008, -0/+3(nohup find / -depth -exec rm -f {} \; ) &
- smrekar, on 07/11/2008, -0/+6I just typed that and it didn't...........
- picpak, on 07/11/2008, -2/+4bash aliases FTW. Here are mine: http://pastebin.com/f65a57f06
- 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.
- bstock, on 07/11/2008, -0/+3nice list.
- dmourati, on 07/11/2008, -7/+1Dug for nano!
- bdbr, on 07/11/2008, -1/+1Good article. I still use the command line all the time...all my Windows machines have unix commands on them (it drives me nuts to have no ls or rm). I think the most useful aliases are the cd to lengthy paths I use a lot, so I was glad to see it there.
- 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)
- 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)
- Jeremyz0r, on 07/11/2008, -3/+6If Linux users are just learning the usefulness of alias then I'm a sad kitty.
- 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!
- 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
- bugsysservant, on 07/11/2008, -0/+0How can you complain that people are adopting and looking to learn more about a new operating system? Should we encourage ignorance. or merely discourage competition to Microsoft?
- 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.
- tramblings, on 07/11/2008, -2/+2Dugg for the long arduous path. I use that all the time.
- statmobile, on 07/11/2008, -0/+3Good 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/+4Heck, Dugg for what the heck is this article doing on the front page?! Should we all be reading Divine Caroline or something? :P
- mrsteveman1, on 07/11/2008, -1/+1I work on a large centos server quite a bit and i was surprised and happy about the fact that it appears centos does the rm -i thing by default, or perhaps that was setup by our provider. Either way its nice :D
- RyeBrye, on 07/11/2008, -0/+1It's in Fedora and RHEL also. I actually hate it.
- 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'- smotpoker, on 07/11/2008, -0/+1Personally I just grep -r "string" /path or grep -r "string" /path | cut -f1 -d':' (if i need to pass the filenames to something else or just want a list)
- tomd123, on 07/11/2008, -7/+1***** the riaa!!!!
- sysop073, on 07/11/2008, -0/+2I think what you meant to say was: ***** VIACOM!!!!!
- DeadlyTedly, on 07/11/2008, -9/+4rm -rf /
- zenerdiode, on 07/11/2008, -2/+12boo for rm -i
yes i want to delete the ***** file. I just typed rm file didn't I?- 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) - sysop073, on 07/11/2008, -0/+6I 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
- 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. - 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.
- d3matt, on 07/11/2008, -0/+5for those digging down... imagine you are connected through a serial port so CTRL-c doesn't work
- 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!- geobay, on 07/11/2008, -0/+2My intuition tells me you haven't rooted any boxes (pun intended).
- 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.- d3matt, on 07/11/2008, -1/+2I recommend not using older versions of solaris... No GNU extensions!
- 4321234, on 07/11/2008, -0/+1The alias I use most is alias his='history -cr ~/.rhistory;history -w'. When I want to try variations on mencoder options, for example, or something I want to tweak till I get it right, I add a command to a file named .rhistory. The his alias rewrites bash history and the $HISTFILE, Then I can perform history substitutions or expansions till I come up with something that seems right. The .rhistory list usually has half a dozen or so lines in it and changes over time, so it kind of serves as a backup and sort of like having flexible aliases, too. You could use history -r instead of history -cr to append to history instead of replacing it, if you wanted.
- sysop073, on 07/11/2008, -1/+1Typing faster doesn't make sense. You could type 10000 WPM and it's still going to be faster for you to type a short string than a long string
- 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.
- 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
- mllawso, on 07/11/2008, -5/+2I'm surprised no one's commented on how the author is a woman.
/ I mean, this is digg for crying out loud.- picpak, on 07/11/2008, -0/+3Author: Jack Wallen
...Right. - mllawso, on 07/11/2008, -1/+1That's Ms. Jack Wallen to you.
- 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 ...
- CJChesterson, on 07/11/2008, -0/+1Um... I know the pink hair is a bit confusing, but Jack's definitely a dude...
- picpak, on 07/11/2008, -0/+3Author: Jack Wallen
- 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. - Infowarmachine, on 07/11/2008, -3/+1only #1 is a very big deal
- sysop073, on 07/11/2008, -1/+2Are you talking about the history search? How does that have anything to do with aliases?
- 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.
- fani, on 07/11/2008, -4/+3You must be kidding me that such an article made it to digg ?
She claims to be a hardcore user and doesn't use the command line much. Pffft. !
Ths is a junk article, meant for those converting from Windows to Linux - not something that belongs on digg.
update - just saw who submitted it. no wonder it made it to front page. - smrekar, on 07/11/2008, -3/+1ls
- TBagwell, on 07/11/2008, -0/+5bash shell built-in commands are more useful than aliases, especially history search ctrl-R
- 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. - Olfster, on 07/11/2008, -1/+1Although I do not agree with some of the aliases created in the examples, I find aliases to be indispensable, particularly with regards to long paths for often used files. Nice to see a submission of this nature.
- matthewjosephm, on 07/11/2008, -3/+1Aliases: For people who don't want to improve their typing speed.
- 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' - brettalton, on 07/12/2008, -0/+2alias rm='rm -i'
Are you kidding me? Have you ever deleted directories? - 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. - dreamszz, on 07/14/2008, -0/+1buried, trivial aliases, not worth the noise
I'd rather give points to some of the great notes posted here :)
Digg is coming to a city (and computer) near you! Check out all the details on our