122 Comments
- phaseblue, on 08/25/2008, -1/+50"Stop piping cats." Yeah! And stop clubbing seals! Both are just poor UNIX form.
- randomizer9, on 08/25/2008, -0/+27"The command line is the way God intended it"
--Cool older Unix guy I used to work with - inactive, on 08/25/2008, -0/+18man tar =>
SYNOPSIS
tar [ - ] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | u --update | x --extract --get [ options ] pathname [ pathname ... ]
The "-" is optional... So no differences! - Niubai, on 08/25/2008, -0/+1811 - Know how to use screen. Screen is almost mandatory for everyone working on a ssh terminal.
- d3matt, on 08/25/2008, -1/+18not much. Some older versions may require the -
- brisbin33, on 08/25/2008, -1/+17very good, concise list. i always forget to follow 1 and 2, i don't know how many times i've mv something.tar.gz, cd there, then extract, then rm -f something.tar.gz.... soo many steps. you don't even have to remember the -C flag just cd to the destination directory first then extract the full path/to/archive.tar.gz.
- sikrikar, on 08/25/2008, -1/+16#cd /pub && more beer
- sancho, on 08/25/2008, -1/+14The command line actually gives you immense flexibility and more power than any GUI I've ever seen. What it doesn't give you is ease of use. If you want a point-and-click interface, use one. I like the command line because once you know it, you can perform complex tasks quite easily.
- vade79, on 08/25/2008, -0/+13Here's a simple one: "cd -" to goto the previous directory you were in, and "cd -" again to jump back where you were...not too well known, but i use it all the time. (for bash anyways)
- skidooer, on 08/25/2008, -0/+13One is BSD style, the other is SysV. Depending on the system, only one style will work. Although some systems support both.
- SDNick484, on 08/25/2008, -0/+9The IBM tech library (and Sun's BigAdmin), always have solid articles. Even after having worked for a couple years as a professional Unix admin, I didn't know that the awk could be used almost like a grep (the ls -l | awk '$6 == "Dec"' example).
- rald84, on 08/25/2008, -2/+10what is the difference between
tar -xvf
and
tar xvf
?? - speedyrev, on 08/25/2008, -1/+9Dugg. If for no other reason, just the layout. I love that they give you the opportunity to click to just what you want to read, or quick scan the list and surf away if it doesn't interest you.
- evillawngnome, on 08/25/2008, -3/+10While it is true that we all need to cut down on using "cat", the author writes as if it's the end of the world if you do. Consider the following:
/var/log/messages contains all of the general error and informational messages for a particular Linux server. Investigating a hardware issue, this should be the first place you look:
cat /var/log/messages
results in the entire thing going into your terminal. On some systems, this will only contain a few items, such as the startup log and maybe a few other entries, and hopefully the information you're looking for. On other systems, it may contain every DHCP event, or other "white noise" that needs to be filtered out.
At this point, you have two options:
1. Start from scratch, typing "grep ERROR /var/log/messages"
2. Press the up arrow to get the "cat /var/log/messages" command that you just entered, and tack a pipe on that: "| grep ERROR"
I think you'll find that both methods have their merit when you are working on an issue "on the fly." - diggopolous, on 08/25/2008, -0/+7People with pet peeves are a pet peeve of mine. myself included.
- inactive, on 08/25/2008, -1/+7One has a dash and the other doesn't.
- BrainInAJar, on 08/25/2008, -0/+6if you were a CS major at a respectable school, then you'd understand that CS is a branch of mathematics concerning the science of computability, and had nothing to do with the operation of actual "computers" we use today
- enantiodromia, on 08/25/2008, -0/+5#12) Spend 3 hours getting CYGWIN, Active PERL/CPAN, apache, putty, and winscp, to be 1/10th as useful as a proper *nix machine.
#13) Wonder why your coworkers are getting more done in less time that you are
#14) Go back to Desktop Support, and leave the real work for adults - SteveMax, on 08/25/2008, -1/+6This has been on the front page as many times as MrBabyMan. It's still relevant, if only to have good tech content on the FP.
- evillawngnome, on 08/25/2008, -0/+5unfortunately, this style of article does not usually hit Digg. We're used to 10 items on 12 pages with a 2 minute load between each.
- ethana2, on 08/25/2008, -0/+5OSX and Linux are both VASTLY superior to windows. windows needs to go die so the real operating systems can duke it out with more developer resources.
- deadbaby, on 08/26/2008, -0/+5Some of those are kinda abstract for the typical CLI tasks...
1) Learn to use screen.
2) Learn to use your bash_history
3) Don't go wild with up/down command history and tab completion. It's great sometimes but it can actually slow you down other times.
4) If you're always typing the same arguments to a command just make an alias for it.
5) Use logging in your Terminal emulator to document changes and troubleshoot problems.
6) If you're using a GUI, use a empty text document to prepare especially long & complex commands. (easier to edit)
7) Using more, less complex, commands is usually easier than trying to string together some UNIX kung fu.
8) If you're pasting into a Terminal emulator watch out for trailing line breaks.
9) chmod 777 will fix many problems but it will create many more.
10) top is a stupid program. Use htop instead. - freezerburn666, on 08/25/2008, -0/+5shhh you're going to scare them away
- infiniphunk, on 08/25/2008, -2/+6Logged in, just to digg you down.
- MattBD, on 08/25/2008, -1/+5I was sceptical till I started using it, but now I'm hooked. IMHO the reason no-one uses the command line in Windows is because it's crap. The Unix shell, in comparison, is an 800-pound gorilla. Even in a beginner-friendly Linux distro such as Ubuntu, the shell is often the quickest and easiest way to get things done.
- inactive, on 08/25/2008, -0/+412 - Learn how to customize screen so you can show off to your friends.
http://gentoo-wiki.com/TIP_Using_screen#Tab-bar - dougmc, on 08/25/2008, -0/+4> While it is true that we all need to cut down on using "cat"
Actually, that's an opinion, not a fact.
Personally, I'm tired of people complaining about `useless use of cat'. If using cat in your pipeline makes it more clear, then it's not useless. If you're using a shell that lets you edit your command line (and most people probably do use such a shell) and you're repeatedly tweaking and re-running your pipeline to get the output right, using `cat file |' often results in fewer keystrokes needed than if you let the first component of the pipeline open the file.
Also, it's not even tenths of a second. In the example given, it's five hundredths of a second different, looking at the wall clock.
Ok, it might matter a small bit if it's in a script that's run 100,000 times a day. But for interactive use? Use cat all you like, even if somebody tells you it's `useless'. If it makes your commands more straightforward, saves you some typing or just makes you feel better, it's not useless. - init100, on 08/25/2008, -1/+5@HonestAbe
"No. It is not hard at all. But memorizing xzqkcf makes you l33t."
Those option letters aren't just random. The letters xvf means eXtract, Verbose, File.
@Zaggynl
"Is it that hard to make the program detect the filetype and just extract the damn thing?"
No, but you may not want to extract it. You might e.g. just want to list the contents of the archive, which is done through substituting the x for a t (as in test). - gcauthon, on 08/25/2008, -0/+4Since the author goes on about tar, I've got one for him. Why use "tar xvf" everywhere? Just use "tar xf". Printing out the name of every file to the console can take a long time, and it's usually pointless. Everyone does this and it's just a pet peeve of mine. I've even heard people complain that the command is too slow for large tar files. Well, not if you leave off the "v" option...
- Zaggynl, on 08/25/2008, -0/+4dugg
Is it that hard to make the program detect the filetype and just extract the damn thing? - jimtb, on 08/25/2008, -0/+4Wow that can be really useful, thanks.
- merlinus, on 08/25/2008, -1/+4There is no difference BUT, the '-' is unnecessary since, '-' denotes OPTIONS and those are not "OPTIONAL" with tar. In other words, you have to have something there for the first argument to tar, and thus it's not an "option".
This is also true for one or two other Unix commands where the option argument isn't "optional" and thus you don't need to use a '-'.
Does that make sense? - sancho, on 08/25/2008, -0/+3Plus, it's tenths of a second on modern systems.
The real savings come about when you're processing lots of files in a shell script, not working on the command line. If you were processing hundreds of megabytes of log files, using grep -c may save you noticeable time. - sancho, on 08/25/2008, -0/+3Bash is a shell, or command interpreter. You issue it commands, and it faithfully executes them. It offers some programming constructs, but at its heart, it's an interface that the user can use to run programs. Thus, it is a user interface.
- RaulMuadDib, on 08/25/2008, -1/+4loser
- Frostek, on 08/25/2008, -0/+3This answer makes the most sense.
- bevel, on 08/25/2008, -0/+3oh. you winder-upper, you!
- killerCoder, on 08/26/2008, -0/+3Use Ctrl+R to search backwards for a command instead of the up and down keys. This is the command I find myself using the most!
Also use "bang" shortcuts whenever you can e.g !!, !$, !^, !$:h, !$:t etc - BrainInAJar, on 08/25/2008, -1/+4just so you know, not all systems support the -z flag ( in adherence with "do one thing, do it well" )
The correct way of doing that operation is:
gunzip -c foo.tar.gz | tar -xf - - Ademan, on 08/25/2008, -1/+4Great article, however i'm positive this has been dugg before (whatever i guess). I've always known about xargs but i've never used it, and I can think of numerous times where it would have been nicer (usually relating to find...)
- dougmc, on 08/25/2008, -1/+4Perhaps you need a faster console.
It's useful to see what's going on. Get in the habit of using the v flag. Use it by default. Sure, there's times you don't want to use it, but most of the time, it's your friend or at worst and uninvolved bystander.
Personally, I also wish that more stock *nix commands supported the -v flag. If I'm doing a `rm -rf directory', that's fine, but `rm -rvf directory' is MUCH better -- if I see the wrong filenames scrolling across my screen, I can ^C it! Fortunately, the GNU commands add the -v flag pretty much everywhere it makes sense to do so. - elementop, on 08/25/2008, -1/+4You've never had to remotely administer anything over a satellite hop, have you? I'll take the (rubbing sticks together) command line interface over a GUI any day in my work environment.
For that matter, RealVNC/Remote Desktop piped through an SSH tunnel on a DSL line is painful enough...the satellite hop is actually overkill. - nosretap, on 08/25/2008, -0/+3~$ cd /pub && more beer
Glug Glug Glug, Ahhhh.....
/pub$
There, fixed it for you - tim620, on 08/25/2008, -0/+3Don't computer science majors use UNIX / Linux anymore? I was on a UNIX command line, long before I touched Windows...but then again, I'm an old fart, now.
- MtheoryX, on 08/25/2008, -0/+3If you're a CS major at my school, and you're above a freshman level...i'm ***** quitting now.
- tim620, on 08/25/2008, -0/+3I like "cool older UNIX guys (and gals, but they are hard to find)" and I like his motto.
- worminater, on 08/25/2008, -1/+4HonestAbe I take it you've never done any serious administration/debugging on a machine before. It shows.
- dougmc, on 08/25/2008, -0/+2Too concise. Any list of `Good Unix habits' that doesn't start with `Don't do things as root unless you have to -- and you probably don't have to nearly as often as you think' is too concise. Unless it's written at a high level where you can _assume_ that people know that, but I don't think this list qualifies.
- dougmc, on 08/25/2008, -0/+2There's a fair number of command that have mandatory `options' that start with a dash and must start with a dash. cpio, for example -- it's tar's less famous brother, and it requires dashes for it's mandatory options.
Though I do like that reasoning. But it sort of doesn't work, because `v' and `f' are options, and yet they're being specified without a dash. - dougmc, on 08/25/2008, -0/+2As long as God == Rob Pike, it's all good. Actually, there's a number of Gods that you can pick for this, but it's probably not the God most people think about.
(Granted, command lines were around before *nix.) -
Show 51 - 100 of 123 discussions



What is Digg?