But then you ask if there are tutorials, and that I can't help you with. Having said that, I tried this search:
http://www.google.co.uk/search?q=command+line+tutorial
and I got lots of hits, including these:
* http://www.davidbaumgold.com/tutorials/command-line/
* http://stackoverflow.com/questions/8170/best-windows-command...
* http://www.tuxfiles.org/linuxhelp/cli.html
I'm not a beginner on the command line, so I can't assess how well they meet your needs.
Besides, VMS had a pretty nice "help" command. Barely had to crack open any of the orange binders in the 10 feet or so shelf of manuals.
(For entertainment purposes only. Do not attempt this at home. Get off my lawn ;-)
I really like this book, even today: http://shop.oreilly.com/product/9780596003302.do
The key to being proficient at the command line (as distinct from writing shell scripts) is to think of it as composition.
For example, run this:
$ file $(which $(man -k python | cut --delimiter " " --fields 1))
(The first '$' is your command line prompt, yours may differ; you don't type that. The other '$' characters you do type.)Now run each command from the inside out, starting with the man command. See what each command does. Build it up bit by bit, that's exactly what I did, like this:
- the man command
- the man command piped into the cut command
- the man command piped into the cut command after reading "man cut" to remember about the --delimiter option
- the output of that pipeline fed to which
- the output of which fed to file
Note that I didn't use any for loops or variables, the shell did the right thing for me.
Read the man pages for each of those commands.
set -o vi or set -o emacs (or their equivalent in .inputrc) helps a lot when you compose things incrementally. esc-k k k (etc) is your friend if you set -o vi.
Read man bash. It will take you a long time. For today, read the section on READLINE. While in man bash, search for the word READLINE at the front of the line, like this:
/^READLINE
Slash = search
^ = anchor the search to the front of the line
READLINE = what you're searching for in the current man page.
For now, all you need in your ~/.inputrc file is:
set editing-mode vi
This will give you vi command line editing in bash, as well as any other program that uses readline, like the python REPL.
For more info on .inputrc,
$ man readline
which is documentation for the C interface to readline, but is mostly about how readline is used by a user. For example, in man readline/VI Mode bindings
gives you all your command line editing commands when you use vi mode.
Get a mostly table of contents of man bash, for your searching pleasure:
$ man -P cat bash |egrep -v "^ " |egrep -o "^[^ ]+"
Sort it: $ man -P cat bash |egrep -v "^ " |egrep -o "^[^ ]+" |sortI realized/remembered while reading the other comments that knowing what's available is a necessary part of "just use the command line a lot."
So try this, to get a good list of what's available (and for more command line composition)
$ man -k $(ls -1 /usr/bin |egrep -v "\[") 2>&1 |egrep -v "nothing appropriate"
See if you can figure out what 2>&1 does (it's a very common idiom, probably easy to find), and figure out why it's needed here.That's a long list of stuff, look at it a page at a time:
$ man -k $(ls -1 /usr/bin |egrep -v "\[") 2>&1 |egrep -v "nothing appropriate" |less
That's still a lot of stuff, save it off in a file in your home directory for later: $ man -k $(ls -1 /usr/bin |egrep -v "\[") 2>&1 |egrep -v "nothing appropriate" > ~/wholelottacommands.txtDon't read, use it often!
There must be a strong reason to learn, and don't just learn for the sake of learning!
I have been using Linux daily, its around 5+ yrs. I play around with numerous VPS remote boxes and still I'm learning, but everyday getting better at it.
This way, it should only get better and better over time! The more you use in your daily workflows, the more you appreciate and understand the internals too.
And there are no other shortcuts to learn command line tools. Courses or short tutorials won't help much.
You have to involve command line tools in your daily workflow's. Its a long term process, so keep learning, improving and don't ever stop!
Eventually I grew to love bash. I am sure there are plenty of keyboard shortcuts I don't know, but I find using the command line to be quicker than any other form of communicating with the computer.
I use keyboard shortcuts in Firefox, and occasionally dream of an Awesome Bar that works like bash.
I also really like using the 'move-cursor-a-word-left/right' and 'move-cursor-to-end/beginning-of-line' and 'move-cursor-to-top/bottom-of-textarea' functions you can find in almost every GUI.
Finally, I use Spotlight to load all my applications: I hit cmd-space and then it's usually 1 key to load my most commonly used applications, and generally 3-4 in worst case.
My suggestion: use the Terminal for everything: Learn to edit text files in emacs or vi, use a command line SQL browser, do source control from the command line, and learn sed, awk, and cut (plenty of tutorials out there). Use the keyboard in the browser and in GUI textareas as much as possible.
Here is a neat site which has turned up in a few of my Google searches: http://www.commandlinefu.com/commands/browse
Finally, shameless self-plug, I have been using this simple piece of code every day for a couple of years, a command-line (tab-completed) notebook for bash: https://github.com/nchelluri/notes .
HTH.
Edit: I keep looking at this page every few months, but it never seems to be compatible with my version of Firefox: http://paulrouget.com/e/jsterm/ :(
This reminded me to check up on Ubiquity[1]. Mozilla doesn't even host a page for it anymore, but apparently someone adopted it[2]. I'm going to have to play around with this tomorrow; I'll be happy if it's half as useful as I remember.
[1]: https://en.wikipedia.org/wiki/Ubiquity_%28Firefox%29 [2]: https://bitbucket.org/satyr/ubiquity/overview
I could also recommend TUPE[1], it teaches you how to effectively use the command line and write shell scripts.
1. The Unix Programming Environment by Brian Kernighan and Rob Pike.
When I got my account, I given a user agreement paper with rules and regulations that, at the very bottom, had a dozen or so commands on it. There were some very terse and cryptic descriptions. ("cd: change directory; man: read a manual page; ps: print running processes; grep: search for a string")
Eventually I bootstrapped my way up to doing "ps -augx" to see what other people were running. Then I would try whatever they were doing.
In 1997, a friend of mine came to visit, installed Debian 2.0 on my 486 with a unsupported Intel i740 videocard, showed me how to log in, 'man -k <something>' and 'man man', then said "See ya next week, have fun". And I had.
Installers were typically batch files (the DOS equivalent of shell scripts), which was really cool: You could see exactly what they were doing [1], and you could improve your command-line-fu by seeing the techniques people used [2].
[1] Usually it was just copying the application files from directory to directory. Nowadays installers generally muck with the Registry, C:\Progra~1 [3], C:\Users\Applic~1 [3], the Desktop (who knows where that is), the Start Menu, and the Windows equivalent of /etc/init.d (I remember there are several of them, and your system will get slower...and...slow...er...if you don't clean them out regularly)
[2] Like environment variables or @ECHO OFF.
[3] Spaces in filenames need to die. Whenever possible I use the 8-character names Windows generates for backwards compatibility with DOS.
(1) At the terminal, via
man <command>
or apropos <command>
and
(2) online by googling.These are useful when you have a specific task you want to get done, not so much otherwise. Therefore,
(3) Try to do things at the command line that you would normally do via mouse. If you have no idea how, google or 'apropos'. If you learn of a tool and have no idea how to use it, google more or 'man'.
(3a) Do the simple stuff via the CLI--removing and moving files, examining directory contents, et cetera. (Be careful with rm! It will not warn you by default.)
(3b) More complex stuff too--try editing text with a terminal editor. Many people swear by emacs and vim. They have learning curves of their own but they are worth it. Pick one.
(4) Pipes and input redirection. Send the output of one command as the input to another, send the output to a file, etc. This is where your standard Unix shell gets really powerful.
Turns out it's a synonym for "man -k".
https://peepcode.com/products/meet-the-command-line
https://peepcode.com/products/advanced-command-line
Experimentation is another good option, and goes a long way, but it can be scary. If you're at all worried about doing permanent damage, install a virtual machine (i.e. VirtualBox + the server version of Ubuntu or whatever OS you want). That way you can experiment away without fear of doing permanent damage. If it happens just trash the the VM and start again.
Command line is not one of those self-contained "deep" knowledge bases where everything links together. It's broad, shallow, unlinked - the concepts and practices do not always imply themselves. For bodies of knowledge that fit that pattern, you have to learn by doing - you can't simply derive the knowledge through study and thought. And the best way to learn by doing is to immediately apply it to something useful.
Have an IRC connection to Freenode open so you can ask about these sorts of things that are more easily understood by humans (#bash, ##linux, ##workingset are good channels to be in). If you're really lucky, you have some knowledgeable mentor around who doesn't mind you asking them about the best way to perform some task (I was not so blessed).
Everytime I wanted to do something in the command line as well as everytime I had to do something in it, I would then write down what the command was in a text file as well as my understand of what the command did.
If you program a keyboard shortcut to launch the text file with but one keystroke it's a not as bad as it sounds.
The reason I did this was because I would always enter a command and totally forget it and then need to look it up again and so I forced myself to stop wasting time by compiling my own command line glossary.
If you are new to UNIX, don't go poking around the MAN pages because you'll be lost, discouraged and less likely to acheive your goal of terminal excellency.
It's really not something you can just pickup overnight unless you're very very diligent and proficient with another language and very familiar with all things computers. If you can take a Unix course some where in person, do that. always the best to have a pro help you out while you're starting.
And one last point of particular importance. Respect the Sudo. I can't tell you how much frustration I endured while messing with the sudo--it's not a good thing to be bushwhacking no the command like as the root user which I did at first because I am just a curious kid and didn't know any better.
My advice is to abstain from messing with things like the ACL, file ownership, and the wheel group until you know the hierarchy cold.
Years detached from those experiences with the XT, I picked up Linux in the late 90s. It was a bit of a learning curve from DOS. But I picked up some very dated book at the local library about Unix and it kind of set me straight.
The real revolution in my thinking came in 2001, when I was unfortunate enough to buy a motherboard with an ALI 1647 chipset (it's sad that I have brain cells devoted to remembering that model number). That chipset, when combined with an NVIDIA video card, would make X crash and lock up after about 30 minutes of use (before you start bashing on Linux, I'd been told the same thing would happen on Windows with this hardware combination). For six months months I was in denial of this problem. I kept thinking the next BIOS update or the next driver would fix the problem. In the meantime I used nothing but console mode, because it was the only thing that was stable.
Six months or so later I sold the old motherboard, paid my quarter to get myself a "real motherboard" (ok, it was more like USD$200), and got X working again. It was good and all to have a GUI again but one thing I did notice was that my command line skills were much improved.
This was over a period of years rather than weeks or months - I probably can't say that I was proficient on the CLI until around 1999 when I really started getting stuck into Linux and building everything from scratch. I find that young developers today expect to learn everything immediately, expecting a one-true-way to wisdom, rather than accepting that true mastery seeps in over time, largely through doing and getting things wrong. So, experiment, and don't give up when you can't figure out something immediately.
I had no choice -- for most of my computing career, there wasn't anything else. in fact, when I first got into computing, I would have sold my left arm to gain access to a command line interface.
When I see a typical modern command line (a shell session), it's enclosed in a separate window, and I'm reminded how far we've come in a short time.
Before I had access to a terminal, I was writing programs anyway --
http://arachnoid.com/programmable_calculators
-- and my first terminal's output (while working for NASA in the early 1970s) was a roll of paper.
So that's my answer -- I had no choice.
Oh, p.s., here's my Bash tutorial:
Start using linux and develop something. You'll use about 3 terminal instances all the time. That's the way to learn.
That said, I think the most important thing for you to learn is how to get help. Learn how to find man(ual) pages, and how to interpret the very precise language and syntax that programmer-authors like to use. Then try reading the man pages of the systems that you want to learn - like 'man bash'. Also, some tools have nicer pages accessible via the 'info' command, so try 'info emacs'.
That'll generally be the best way to learn how to use any tool. The only trick past that is to learn which tools exist, and google/stackoverflow will usually suggest appropriate tools when you tell it precisely which problem you want to solve.
Today, I'd recommend working through Linux From Scratch. You'll develop a rich understanding of how a UNIX-like OS fits together, including a fair bit of shell functionality: http://www.linuxfromscratch.org/lfs/
My favourite dead-tree UNIX book would be UNIX Power Tools, 3rd Edition (http://www.amazon.com/Power-Tools-Third-Shelley-Powers/dp/05...). It may be a while before it's a truly valuable resource, but keep it in mind.
XENIX (Microsoft's Unix) came with a program called "learn" which was a tutorial. It would show you how to do something, then give you a goal and drop you into a mock shell. Most of the commands had their usual effects inside the mock shell, but you could always quit the lesson and restart if you screwed up.
That's how I picked up the basics. When I discovered Unix machines -- and Linux -- on my university campus some eleven years later, all the old skills translated and I learned some new ones along the way.
There's a small book about shell by Zed Shaw, recommended: http://cli.learncodethehardway.org/book/
Then I started doing Learn Python the Hard Way, which taught me the easy stuff like ls, cd, rm, and so on. Then I had a course in Linux Systems Administration, where I had no choice but to master it as fast as possible.
-Sam's Teach Yourself Unix in 24 Hours
-Sam's Teach Yourself Shell Programming in 24 Hours
These won't make you a shell genius immediately, but they'll create a good basis for future, specialized learning.
Also, I try not to be a material snob, but buying the book instead of using a website or .pdf file made a world of a difference (especially during a morning commute).
By doing. Some reading, sure, but .. more doing than thinking. Like this;
I was a brand-new programmer (COBOL). The Marines assigned me to a billet in the LAN team at my new command. A corporal wrote down exactly what to type on the computer after the NIC was installed.
After that, I was off and running.
I didn't know SHIT! absolutely NOTHING. I was just a dumb Windows User. There was just this blinking cursor (that motherfucker) and me. i browsed the web and had to look up stuff like "cd" and "ls". Steep learning curve, i guess, but nothing teaches you better than "trial and error".
Funny sidenote: Not only was i totally overwhelmed with all the commands and quirks of the command line, but the web always mentioned vim as THE editor for Unix. So i also started messing around with the most obscure editor on this planet.
These were rough times for me, but i have learned so much, and i am thankful for that.
Then one day I saw and typed 'man man'
'apropos' was also written on the board that day
That day I learned about OS installation as well.
And then continued.
Type 'cd ' and press tab. 'cd' is like clicking on a folder.It was a bit hard to get out of the station in police quest and only years later did I understand why my dad didn't want to help me to get into this game where a "man" is floating from left to right and you need to answer a question to play.